Simple Display Switcher Script

From ThinkWiki
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 (

If you are running Ubuntu or Debian, you should be able to simply download and install the deb from here:

If you are running some other distribution, you may need to download and build/install from the tarball:

Install this Script

You can simply cut-and-paste the pre-formatted text below to install a copy of the script in /usr/local/bin:

cat <<EOF > /tmp/disper.simple_display_switcher
# 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
# for details on disper.


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

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

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

Bind it to a Hot Key

Use your window or desktop manager to bind a hot-key to this script. You only need one hotkey, as it has no options. The script will detect which display is in use, and will activate the other one. Easy!


You can do other nifty things with disper too. See "man disper" for more information.