making a laptop mobile (dynamic display configuration) - mostly solved

Greg Rundlett (freephile) greg at freephile.com
Sun Oct 25 00:48:23 EDT 2009


Here is my writeup of how I enabled dynamic display configuration for
my laptop.  It may not work for you if you don't have an nVidia
display card.

I'm really happy with the fact that I spec'd my new laptops with the
nVidia card [1] b/c it just works better [2] than the previous machine
which had an onboard Intel graphics chip.

I'm really happy with the dual 22" monitor setup that I drive (one on
VGA, one DVI) using the Lenovo OEM docking station.  Having two
identical 22" monitors side-by-side makes it really easy for me to
open up the dozen or more applications that I typically use.  I can
spread them out on different virtual desktops and flip through those
desktops as fast as hitting ctrl+alt+<->  With compiz running, it even
looks cool.  Even cooler with Ctrl + Alt + mouse drag

I'm also happy with the nVidia X Server Settings app that lets me
easily configure the display(s) attached to my system.  It's way
better than having to manually configure xorg.conf and even better
than playing with XRandR scripts.

The problem is that I still can't just hit Fn+F7 to switch display
layouts for presentations when I'm at a conference and want to hook up
to the projector.  I can't simply undock my notebook to go into a
conference room and have my external displays collapse onto my
notebook screen.  I can't just boot my notebook in the conference
room, and then set it into the dock where it automatically extends the
display onto an external monitor.  Recently when I tried to give a
presentation, OpenOffice thought my screen was far bigger than what
displayed on the notebook, and so the audience could only see half the
presentation.  As a result, I had to give the presentation in
window'ed mode rather than full screen.  I was determined to fix all
this.

I actually have another dock at my home office with a single monitor
there, so the total number of configurations is:
notebook display alone (aka "free to go anywhere as long as I've got
battery mode")
notebook diplay plus one external monitor (aka "docked at home")
notebook (internal display off) two external monitors on (can't run
three displays) - (aka "docked at work")
notebook plus external projector (aka "giving a presentation")

I found the disper project http://willem.engen.nl/projects/disper/
(PPA at https://launchpad.net/~wvengen/+archive/ppa) [3] written by
Willem van Engen which is an on-the-fly display switching application.
 Disper is written in python and interfaces with the nVidia Settings
tool and other subsystems like XRandR (note: only nVidia cards are
currently supported, and the XRandR interface is minimal -- which is
immaterial for nVidia cards since they don't use XRandR).

After installing disper, I could see that it properly detected both my
laptop display, plus the external monitor.

$ disper --displays=auto --list
display DFP-0: LEN
 resolutions: 512x384, 576x432, 680x384, 720x450, 1024x768, 1152x864,
1360x768, 1440x900
display CRT-0: ViewSonic VX2235wm-3
 resolutions: 320x240, 400x300, 512x384, 680x384, 640x480, 720x450,
700x525, 840x525, 800x600, 960x540, 832x624, 960x600, 1024x768,
1152x864, 1360x768, 1280x960, 1440x900, 1280x1024, 1400x1050,
1600x1200, 1920x1080, 1920x1200, 1680x1050

And, it worked perfectly to switch from "Extended" display to "Single"
notebook display.  Yay, now I can undock my notebook via simple
command line (or key stroke via key binding) rather than having to
click, click, click through nVidia X Server Settings.

I also found this article
http://onlyubuntu.blogspot.com/2009/04/autodetecting-and-configuring-multiple.html
which describes the additional scripting you want to do to make it all
happen automatically - including moving the taskbar to the extended
display.

For me, that was as easy as making ~/bin/monitor.sh (and chmod 755 !$)

#!/bin/sh
#
# Detect displays and move panels to the primary display
#

# disper command will detect and configure monitors
disper --displays=auto -e

# parse output from disper tool how many displays we have attached
# disper prints 2 lines per displer
lines=`disper -l|wc -l`

display_count=$((lines / 2))

echo $display_count

echo "Detected display count:" $display_count

# Make sure that we move panels to the correct display based
# on the display count
if [ $display_count = 1 ] ; then
echo "Moving panels to the internal LCD display"
gconftool-2 \
--set "/apps/panel/toplevels/bottom_panel_screen0/monitor" \
--type integer "0"
gconftool-2 \
--set "/apps/panel/toplevels/top_panel_screen0/monitor" \
--type integer "0"
else
echo "Moving panels to the external display"
gconftool-2 \
--set "/apps/panel/toplevels/bottom_panel_screen0/monitor" \
--type integer "1"
gconftool-2 \
--set "/apps/panel/toplevels/top_panel_screen0/monitor" \
--type integer "1"
fi

Next, I added monitor.sh to the system startup scripts so that
monitor.sh would run on boot

# copy the script (or make a symbolic link)
sudo cp ~/bin/monitor.sh /etc/init.d/
# update various run-levels
sudo update-rc.d monitor.sh defaults

I found this script http://www.linux-depot.com/?p=projects&s=nvidia
that enables you to attach it to the Fn+F7 combo, but haven't tested
that yet.

[1] nVidia Corporation Quadro FX 2700M
[2] "works better" here is defined as having transparent console
windows.  Although I like the effects available in compiz, having
transparency in my konsole is the killer feature that I use all the
time to actually be productive.  Transparent konsoles used to work for
me a long time ago, and then went away, and now they're back.  I'd be
going off on a tangent here if I went on a rant about how I hate
upgraded software that breaks existing features with maybe the promise
to someday bring those old features back into the "better" software.
You know who you are Amarok, KDE, Konsole.
[3] for Ubuntu users who want to install disper:
sudo su -
cat >> /etc/apt/sources.list <<HERE
# add disper, a tool for dynamic display configuration
deb http://ppa.launchpad.net/wvengen/ppa/ubuntu jaunty main
deb-src http://ppa.launchpad.net/wvengen/ppa/ubuntu jaunty main
HERE
apt-key adv --recv-keys --keyserver keyserver.ubuntu.com F6EFB904
apt-get update
apt-get install disper


Best regards,

~ Greg
nbpt 978-225-8302
m. 978-764-4424
-skype/aim/irc/twitter freephile
http://profiles.aim.com/freephile


More information about the gnhlug-discuss mailing list