My script for switching/rotating displays on my laptop.
Richard Bronosky
BrunosJunk at Bronosky.com
Thu May 31 07:44:46 PDT 2007
I just thought I'd share this since this list gets archived and search indexed.
I have a script that I find very handy for using my laptop with an
external (rotation capable) LCD. The script intelligently decides
between internal display only, external rotated normal, and external
rotated left. It is customized to my needs, since I keep my LCD to
the right of my laptop, but you can easily tweak it to meet your
needs.
I have script run on login to detect my LCD and switch from display
mirroring to dual display mode. I also assigned this script to a
keyboard shortcut, since I regularly pivot my display to get an extra
tall terminal. This is also nice when I undock my laptop to go to a
meeting. I don't have to reboot to get my desktop resized. I just
hit the shortcut.
I love the new XRANDR! I just wish it wasn't DOG SLOW when running in
rotated mode on my "Display controller: Intel Corporation Mobile
945GM/GMS/940GML Express Integrated Graphics Controller (rev 03)"
Enjoy!
--
.!# RichardBronosky #!.
rbronosky at ubuntu:~$ cat bin/rotate.sh
#!/bin/bash
[ -z "$DISPLAY" ] && {
export DISPLAY=:0.0
echo "No DISPLAY defined, using default ($DISPLAY).";
}
dat=$(xrandr)
if printf "$dat"|grep --color=always 'VGA connected' 1>/dev/null 2>&1; then
if printf "$dat"|grep --color=always 'VGA connected[^(]*left' || \
printf "$dat"|grep --color=always 'VGA
connected[^0-9]*$' || \
printf "$dat"|grep --color=always
"current[[:space:]]*$(printf "$dat"|awk '/VGA connected [0-9x]/
{match($0,/connected [0-9x]+/); res=substr($0, RSTART+10, RLENGTH-10);
gsub(/x/," x ",res); print res;};')";
then
echo "Detected either no active resolution, no dual
display, or left rotation. Rotating VGA normal."
xrandr --output LVDS --auto --rotate normal --output
VGA --auto --right-of LVDS --rotate normal
else
printf "$dat"|grep --color=always 'VGA connected'; #
this is just here for effect
echo "Detected normal VGA rotation. Rotating VGA left."
xrandr --output LVDS --auto --rotate normal --output
VGA --auto --right-of LVDS --rotate left
fi
else
printf "$dat"|grep --color=always 'VGA \w*'; # this is just
here for effect
echo "Detected no VGA. Setting VGA to off."
xrandr --output LVDS --auto --rotate normal --output VGA --off
fi
More information about the xorg
mailing list