Eliminating VGA and LVDS switching hiccups with bash, Zenity and xrandr

The Lenovo X61, with graphics chip-set from Intel, has an annoying feature in that it does not detect the size of an external screen properly. Nor is it possible to switch between internal and external screen with the magic Fn+F7 key-combination.

A small work work-around bash-script, that utilizes Zenity, which I grabbed from here (following a tip from Joar), eases the pain. I have modified it slightly, and here it is:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/bin/sh

ans=$(zenity  --list  --title=" Screen configuration" \
--text "Select desired screen configuration:" \
--radiolist  --column "Pick" \
--column "Output Type" TRUE LCD FALSE VGA \
 FALSE Both);

echo $ans

if [ "$ans" = "LCD" ]
then
        echo "LCD"
        xrandr --output VGA --off
        xrandr --output LVDS --auto
elif [ "$ans" = "VGA" ]
then
        echo "VGA"
        xrandr --output LVDS --off
        xrandr --output VGA --auto
elif [ "$ans" = "Both" ]
then
        echo "Both"
        xrandr --output VGA --mode 1024x768
        xrandr --output LVDS --auto
fi

Adjust the mode parameter in the "Both"-case to match your screen size.

blogroll

social