LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices

Reply
 
LinkBack Search this Thread
Old 08-06-2009, 07:13 PM   #1
xflow7
Member
 
Registered: May 2004
Distribution: Slackware
Posts: 103

Rep: Reputation: 16
"Automatic" X Layout for Dual Screen


Hi all,

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.

Dave

Last edited by xflow7; 08-06-2009 at 07:15 PM.
 
Old 08-08-2009, 04:10 AM   #2
GazL
Senior Member
 
Registered: May 2008
Posts: 2,377

Rep: Reputation: 478Reputation: 478Reputation: 478Reputation: 478Reputation: 478
Nice bit of engineering there David. Thanks for sharing.

I'm a single screen desktop user myself, but that doesn't stop me from appreciating a nice solution.
 
Old 08-08-2009, 08:15 AM   #3
Yalla-One
Member
 
Registered: Oct 2004
Location: Norway
Distribution: Fedora 15
Posts: 628

Rep: Reputation: 35
Thanks!

Any chance of you sharing your xorg.conf as well to see how this was put together in there?
 
Old 08-08-2009, 08:36 AM   #4
GrapefruiTgirl
Guru
 
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Rep: Reputation: 536Reputation: 536Reputation: 536Reputation: 536Reputation: 536Reputation: 536
Indeed, nice engineering for sure!

I've used multiple layouts before, but never investigated how to automate the task of choosing the appropriate one. Looks very handy

Sasha
 
Old 08-08-2009, 12:11 PM   #5
marrowsuck
Member
 
Registered: Sep 2006
Posts: 65

Rep: Reputation: 22
I was just about to write such a script when I discovered your post.
Merci!
 
Old 08-08-2009, 01:17 PM   #6
rouvas
Member
 
Registered: Aug 2006
Location: Greece
Distribution: Slackware.12.2
Posts: 36
Blog Entries: 1

Rep: Reputation: 1
I am facing a similar situation myself.
Good to know there is this path to follow.
Would it be too much to ask for your xorg.conf?
 
Old 08-08-2009, 02:58 PM   #7
xflow7
Member
 
Registered: May 2004
Distribution: Slackware
Posts: 103

Original Poster
Rep: Reputation: 16
Thanks for the compliments. I'm glad this looks useful to some of you.

As requested, my xorg.conf:

Code:
Section "ServerLayout"
    Identifier     "DualScreen"
    Screen      0  "T61pLCD" RightOf "ExternCRT"
    Screen      1  "ExternCRT" LeftOf "T61pLCD"
    InputDevice    "Keyboard0" "CoreKeyboard"
    InputDevice    "Mouse0" "CorePointer"
EndSection

Section "ServerLayout"
    Identifier     "LCDOnly"
    Screen      0  "T61pLCD"
    InputDevice    "Keyboard0" "CoreKeyboard"
    InputDevice    "Mouse0" "CorePointer"
EndSection

Section "Files"
    FontPath        "/usr/lib/X11/fonts/misc/:unscaled"
    FontPath        "/usr/lib/X11/fonts/100dpi/:unscaled"
    FontPath        "/usr/lib/X11/fonts/75dpi/:unscaled"
    FontPath        "/usr/lib/X11/fonts/misc/"
    FontPath        "/usr/lib/X11/fonts/Type1/"
    FontPath        "/usr/lib/X11/fonts/Speedo/"
    FontPath        "/usr/lib/X11/fonts/100dpi/"
    FontPath        "/usr/lib/X11/fonts/75dpi/"
    FontPath        "/usr/lib/X11/fonts/cyrillic/"
    FontPath        "/usr/lib/X11/fonts/TTF/"
EndSection

Section "Module"
    Load           "dbe"
    Load           "extmod"
    Load           "type1"
    Load           "freetype"
    Load           "glx"
EndSection

Section "ServerFlags"
    Option         "Xinerama" "0"
    Option	   "DefaultServerLayout" "LCDOnly"
EndSection

Section "InputDevice"
    # generated from default
    Identifier     "Mouse0"
    Driver         "mouse"
    Option         "Protocol" "auto"
    Option         "Device" "/dev/psaux"
    Option         "Emulate3Buttons" "yes"
    Option         "ZAxisMapping" "4 5"
EndSection

Section "InputDevice"
    # generated from default
    Identifier     "Keyboard0"
    Driver         "kbd"
EndSection

Section "Monitor"
    # HorizSync source: edid, VertRefresh source: edid
    Identifier     "T61pLCD"
    VendorName     "Unknown"
    ModelName      "IBM"
    HorizSync       53.4 - 64.1
    VertRefresh     50.0 - 60.0
    Option         "DPMS"
EndSection

Section "Monitor"
    # HorizSync source: edid, VertRefresh source: edid
    Identifier     "AcerH213H"
    VendorName     "Unknown"
    ModelName      "Acer H213H"
    HorizSync       31.0 - 83.0
    VertRefresh     56.0 - 76.0
    Option         "DPMS"
EndSection

Section "Device"
    Identifier     "Device0"
    Driver         "nvidia"
    VendorName     "NVIDIA Corporation"
    BoardName      "Quadro FX 570M"
    BusID          "PCI:1:0:0"
    Screen          0
EndSection

Section "Device"
    Identifier     "Device1"
    Driver         "nvidia"
    VendorName     "NVIDIA Corporation"
    BoardName      "Quadro FX 570M"
    BusID          "PCI:1:0:0"
    Screen          1
EndSection

Section "Screen"
    Identifier     "T61pLCD"
    Device         "Device0"
    Monitor        "T61pLCD"
    DefaultDepth    24
    Option         "TwinView" "0"
    Option         "TwinViewXineramaInfoOrder" "DFP-0"
    Option         "metamodes" "DFP: nvidia-auto-select +0+0"
    SubSection     "Display"
        Depth       24
    EndSubSection
EndSection

Section "Screen"
    Identifier     "ExternCRT"
    Device         "Device1"
    Monitor        "AcerH213H"
    DefaultDepth    24
    Option         "TwinView" "0"
    Option         "metamodes" "CRT: nvidia-auto-select +0+0"
    SubSection     "Display"
        Depth       24
    EndSubSection
EndSection
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.

Last edited by xflow7; 08-08-2009 at 03:03 PM.
 
Old 01-17-2010, 09:51 AM   #8
GrapefruiTgirl
Guru
 
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Rep: Reputation: 536Reputation: 536Reputation: 536Reputation: 536Reputation: 536Reputation: 536
http://www.linuxquestions.org/questi...4/#post3829714

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..

Sasha
 
Old 01-17-2010, 10:28 AM   #9
adamk75
Senior Member
 
Registered: May 2006
Posts: 2,864

Rep: Reputation: 354Reputation: 354Reputation: 354Reputation: 354
Quote:
Originally Posted by GrapefruiTgirl View Post
http://www.linuxquestions.org/questi...4/#post3829714

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.

Adam
 
Old 01-17-2010, 10:40 AM   #10
GrapefruiTgirl
Guru
 
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Rep: Reputation: 536Reputation: 536Reputation: 536Reputation: 536Reputation: 536Reputation: 536
Quote:
Originally Posted by adamk75 View Post
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.

Adam
Thanks Adam for that correction.

Sasha
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Fedora Core 2: Screen Resolution can not change from "800X600" to "1024X 768" suhaimi_sj Fedora - Installation 18 12-17-2009 03:29 AM
How do I disable "shutdown" and "restart" options in KDE logout screen for all users? maxgsp Linux - Distributions 1 12-12-2008 03:18 PM
Remove "Timer" from dual boot screen? J-Alta-K MEPIS 9 01-13-2006 02:28 PM
how to disable "automatic screen saver" on thinkpad T21 jjonas Linux - Laptop and Netbook 2 07-28-2005 07:31 AM


All times are GMT -5. The time now is 09:29 AM.

Main Menu
 
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration