SlackwareThis Forum is for the discussion of Slackware Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
I figured I'd share something I did with the group as I'd been wondering about this for a while and who knows, maybe someone else will find it useful.
I run a laptop with Slack 12.2, but occasionally have an external monitor connected as well.
When connected, I like to use both monitors but, for a variety of reasons, with the external monitor as a separate Screen in X (rather than with TwinView or similar)
I have two ServerLayouts in xorg.conf:
1) DualScreen
2) LCDOnly
The trouble was that if I set up the DualScreen server layout as default, then when the external monitor wasn't connected I had to manually start X with a -layout option or it would fail because it couldn't find the external monitor. And if LCDOnly was default I had to manually start X to get DualScreen.
Since it appears X does not have the ability to sequentially "try" server layouts in xorg.conf until one works I wanted a way to have the system detect whether the external was connected and start X with the appropriate -layout option by itself.
I discovered I could test the connection through /proc and wrote a script called XAutoLayout:
Code:
#!/bin/bash
#XAutoLayout
#Determine whether external monitor is connected and
#start X with DualScreen layout. Else, start with LCDOnly
BASE_COMMAND="/usr/bin/X -br"
CRT_LAYOUT="DualScreen"
NO_CRT_LAYOUT="LCDOnly"
# Determine whether an external CRT is connected and use it if available
CONNECTED_BIT_MASK=0x10
CRT_STATE_FILE=/proc/acpi/video/VID/CRT0/state
CRT_STATE=`cat $CRT_STATE_FILE | sed -ne "/^state/s/.*\(0x[0-9A-F]*\)/\1/p"`
#For debugging
#echo $CONNECTED_BIT_MASK
#echo $CRT_STATE
if [ $(( $CRT_STATE & $CONNECTED_BIT_MASK )) -ne 0 ]; then
LayoutOpt="-layout $CRT_LAYOUT"
else
LayoutOpt="-layout $NO_CRT_LAYOUT"
fi
CommandLine="$BASE_COMMAND $LayoutOpt"
exec $CommandLine
Then I edited /etc/kde/kdm/kdmrc to call this script rather than the default when starting X:
Code:
...
ServerCmd=/usr/bin/XAutoLayout
...
Presto! Seems to work a treat. Obviously, some things may need to be tailored to one's particular hardware - especially the path for testing the monitor connection. And who knows, this might not work on all hardware anyway.
I'm eager to get any feedback on if there's a cleaner way to do this, but this seems to have done just what I wanted.
The only strange thing I have noticed is that for some reason, the X server now starts on Virtual Terminal #2 rather than Virtual Terminal #7 as it used to. I'm sure there's a logical explanation, but I haven't bothered to investigate yet.
Edit: Be aware that when configured like this (2 separate Screens in xorg.conf), you cannot drag windows between screens. However, you can do that if you enable TwinView (on NVIDIA hardware). And I think that's what Xinerama does. I like the 2 separate screens, though because in my limited experience it seems like window managers deal with it a little better.
Since pointing an OP at the above link, to this thread, I am having another look at this thread.
Still very handy it is, but I wanted to give a thought on this, from the above post:
Quote:
Originally Posted by xflow7
Edit: Be aware that when configured like this (2 separate Screens in xorg.conf), you cannot drag windows between screens. However, you can do that if you enable TwinView (on NVIDIA hardware). And I think that's what Xinerama does. I like the 2 separate screens, though because in my limited experience it seems like window managers deal with it a little better.
So, on that, as far as I know, and in my experience, TwinView with nVidia hardware does not allow dragging windows between screens, but Xinerama does. With Twinview AND Xinerama, one can mouse between screens, but only Xinerama lets you drag windows..
Since pointing an OP at the above link, to this thread, I am having another look at this thread.
Still very handy it is, but I wanted to give a thought on this, from the above post:
So, on that, as far as I know, and in my experience, TwinView with nVidia hardware does not allow dragging windows between screens, but Xinerama does. With Twinview AND Xinerama, one can mouse between screens, but only Xinerama lets you drag windows..
Sasha
Twinview does let you drag windows between screens. Twinview is simply a xinerama like implementation, specific to multiple monitors attached to a single nvidia card.
Twinview does let you drag windows between screens. Twinview is simply a xinerama like implementation, specific to multiple monitors attached to a single nvidia card.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.