Simple Display Switcher Script

From ThinkWiki
Revision as of 17:15, 13 October 2009 by Brianfinley (Talk | contribs) (←Created page with '== Executive Summary == Here is a very simple script that with switch your Thinkpad from the built-in display to an external display. It automatically selects the preferr...')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Executive Summary

Here is a very simple script that with switch your Thinkpad from the built-in display to an external display. It automatically selects the preferred resolution and requires no options.

Install disper

This script relies on the program "disper", which provides a simple command to change between multiple displays. So, the first step is to install disper (http://willem.engen.nl/projects/disper/).

If you are running Ubuntu or Debian, you should be able to simply download and install the deb from here: http://ppa.launchpad.net/wvengen/ubuntu/pool/main/d/disper/

If you are running some other distribution, you may need to download and build/install from the tarball: http://ppa.launchpad.net/wvengen/ppa/ubuntu/pool/main/d/disper/


Install this Script

You can simply cut-and-paste this:

cat <<EOF > /tmp/disper.simple_display_switcher
#!/bin/sh
#
# 2009.10.13 Brian Elliott Finley
# License: GPL v2
#
# This program uses disper to switch between the built-in and an
# external display on a notebook.  See
# http://willem.engen.nl/projects/disper/ for details on disper.

NOTEBOOK_DISPLAY="DFP-0"

disper --export 2>&1 | grep "metamode: $NOTEBOOK_DISPLAY"

if [ $? = 0 ]; then
    # enable the secondary display
    disper --secondary
else
    # enable the primary (notebook) display
    disper --single
fi
EOF

sudo install -m 755 -o root -g root /tmp/disper.simple_display_switcher /usr/local/bin/