2008-05-07 22:12:25

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     #!/bin/sh
 2 
 3     ans=$(zenity  --list  --title=" Screen configuration" \
 4     --text "Select desired screen configuration:" \
 5     --radiolist  --column "Pick" \
 6     --column "Output Type" TRUE LCD FALSE VGA \
 7      FALSE Both);
 8 
 9     echo $ans
10 
11     if [ "$ans" = "LCD" ]
12     then
13             echo "LCD"
14             xrandr --output VGA --off
15             xrandr --output LVDS --auto
16     elif [ "$ans" = "VGA" ]
17     then
18             echo "VGA"
19             xrandr --output LVDS --off
20             xrandr --output VGA --auto
21     elif [ "$ans" = "Both" ]
22     then
23             echo "Both"
24             xrandr --output VGA --mode 1024x768
25             xrandr --output LVDS --auto
26     fi

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


Posted by Knut Ingvald Dietzel | Permanent link | File under: Hacks