Ubuntu – How to customise one session for dual monitors, and another for single monitors

dualheadgnome

I run Ubuntu on my laptop. Roughly 75% of the time, I'm at work with a second monitor attached. The rest of the time I'm running with just the laptop screen. I can configure my panels (and a few misc things like Conky) fine with dual monitors, but then when I run with my laptop only things look messed up (multiple top and bottom panels, etc). If I set things up for a single monitor, then things aren't set up when I'm using dual monitors.

What I want to do is be able to define things like my gnome panels in a user choosable (or automatically selected) to get around this.

Is this possible, and if so, where do I start?

Best Answer

I use two scripts for using my notebook-monitor or an external monitor. Maybe you can use them as a starting point.

Note: My notebook has a nvidia graphic card, so i have to use disper instead of xrandr.

Script to switch to the external monitor and set gnome-panel to monitor 1:

#!/bin/sh
disper --displays=auto -e
lines=`disper -l|wc -l`

display_count=$((lines / 2))

if [ $display_count = 1 ] ; then

   gconftool-2 \
        --set "/apps/panel/toplevels/top_panel_screen0/monitor" \
        --type integer "0"
   disper -s
else
   gconftool-2 \
        --set "/apps/panel/toplevels/top_panel_screen0/monitor" \
        --type integer "1"
   disper -S

fi

Second script to switch back to Notebook-monitor:

#!/bin/sh
 disper -s  
 gconftool-2 \
        --set "/apps/panel/toplevels/top_panel_screen0/monitor" \
        --type integer "0"