Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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?

share|improve this question
add comment

2 Answers

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"
share|improve this answer
add comment

Someone may wish to embellish this answer but I hope its useful as a starting point and might involve a bit of learning.

  1. Your panel settings are stored somewhere in your GNOME settings in your /home/user/ directory. Probably .gconf/ or .gnome2/, you can see these directories by opening a terminal and typing ls -a or just by pressing ctrl+h in nautilus while in your home directory. Hopefully if you root around in there and on the internet you should be able to find them in a file.

  2. Once you know while file it is make a copy of it with the single monitor set up, then plug in your external monitor and set everything up again and make a copy of it again.

  3. Finally you could write a script which would run straight after login and check to see if there is an external display plugged in (or just look at how many displays there are), and then copy the relevant configuration file into place just before GNOME starts up and hopefully everything should look as it should.

Unfortunately I don't know exactly where the relevant configuration settings are or how to check for external displays in a script and some of that will depend on what scripting language you're used to (if you're not used to any I'd suggest just a bash script for this, or maybe python). Good luck!

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.