Compiz dual screen output problem

I got an HP laptop on work with an integrated Intel chip. I am of course running linux on it, but I want to be able to use an external screen. I have a docking station, so I have no problems just putting it in there, keeping the lid closed and starting up the machine with the external display. However, for some reason, Compiz sees only my screen size as the size of the laptop screen, thus making weird redraw issues on the rest of the screen. For instance, zooming only zooms the part outside the 1280×800 pixels (which is my laptop screen size), and rotating the desktop cube looks a bit weird. I found this solution to the problem:

First, run xrandr and check that xrandr sees two screens, one VGA and one LVDS screen.
Now, disable the LVDS screen with the command xrandr –output LVDS –off
Finally, restart compiz to calculate the new output area:
compiz –reload

This should do the trick. It’s a bit messy, so I’ve made this handy shell script to be executed at login.


#!/bin/bash
# auto-external-screen
# Disables the laptop display, if an external display is 

tmp_file="/tmp/screenlist"
xrandr | grep connected | grep -v disconnected > $tmp_file
num_screens=`cat $tmp_file | wc -l`
lvds_enabled=`cat $tmp_file | grep LVDS | ruby -ne 'if $_ =~ /\d+/; puts 1; else puts 0; end'`

function disable_lvds_screen {
/usr/bin/xrandr --output LVDS --off
}

function restart_compiz {
/usr/bin/compiz --reload
}

function cleanup_tmpfile {
rm $tmp_file
}

if [ $num_screens -ge "2" ]; then
    echo "Found $num_screens screens."
    if [ $lvds_enabled -eq "1" ]; then
        echo "Laptop display appears active, disabling output in 30 seconds."
        sleep 30 # Wait 30 seconds to make sure that everything has loaded
        disable_lvds_screen # Disable LVDS (Laptop) display
        restart_compiz # Restart Compiz to recalculate Output display
    else
        echo "Laptop display is already deactivated."
    fi
else
    echo "Only found $num_screens screen. Not doing anything."
fi
cleanup_tmpfile

The script can also be downloaded from http://agitate.dk/files/auto-external-screen.sh.gz

Tell me if it works for you. It’s not a fix, it’s a workaround, just so you know it.


About this entry