How to Change Linux Displays on the Fly with Disper

Using Linux on a laptop has always been a hit and miss affair. With sometimes obscure proprietary hardware, many laptop manufacturers have showed no interest in supporting the free operating system. Nevertheless, through hard work by developers and support from some hardware manufacturers, Linux now supports a wide variety of laptops and netbooks.

Many laptop owners often connect their machines to external displays, whether monitors, televisions, or projectors. For display chips that support XrandR, the setup is usually rather simple. For users with Nvidia chips, it is still easy but not quick. To switch to an external display, you either have to configure it in the xorg.conf file to automatically recognize it or use nvidia-settings and click through a series of options each time you want to use it.

With Disper, a free on-the-fly display switching utility, you can quickly and easily switch to an external display, clone your screens, extend a display, and choose from any of the supported resolutions. Disper is a command line utility, but after a few initial command entries, you can easily bind it to a shortcut key or run it from a single command by using a basic script.

Installation

The Disper website lists binary package archives for Ubuntu, ArchLinux, and OpenSUSE. Follow your distribution’s normal installation procedures to install. For all other distributions, Disper uses python and is easy to install from source. To install:

1. Download the latest version

2. Open a terminal window

3.. Extract the contents of the archive:

tar zxvf disper_0.2.3.tar.gz

4. Go to the src/ directory:

cd trunk/src

5. Type:

make install

Alternative, you can run the program without installing, directly from the src directory:

./cli.py

Initial Setup

Disper should recognize your VGA, DVI, or HDMI connection right away. The first thing to do with Disper is to identify your displays. Enter the following command:

disper --list

The output will look like this:

display DFP-0: HannStar Display Corp HSD121PHW1
resolutions: ...960x540, 832x624, 1024x768, 1366x768
display DFP-1: SONY TV
resolutions: ...1400x1050, 1600x1024, 1680x1050, 1280x720, 1920x1080

Note: I truncated the lower resolutions, but the full list will show all of them.

Usage

If you just want to clone your display, you can enter one command:

disper -c
Cloned displays in 1024x768

Unfortunately, if your device has an odd maximum resolution like my netbook (1366×768), this will result in both screens switching to something like 1024×768. That may be fine for projectors, but if you want to play movies, TV shows, or games on your television, for example, you will want to use custom settings.

For example, if I wanted to display only on my television in 720p resolution, I would enter:

disper -S -r 1280x720

The uppercase “S” refers to the external display. To switch back to the default netbook display, I would enter:

disper -s

This will automatically detect the default resolution and return to it. (Notice the lowercase “s”).

At any time, you can have Disper display the current settings with:

disper -p

The output will look like:

backend: nvidia
associated displays: DFP-0
metamode: DFP-0: 1366x768 @1366x768 +0+0
scaling: aspect-scaled

Extending the displays takes advantage of Nvidia’s Twinview, all with a single command. For example, if I wanted two screens, with my TV screen above my laptop, I would type:

disper -e -r 1366x768,1920x1080 -t top

This would give me a normal laptop screen plus a 1080p full resolution TV screen.

Netbook screen with TV screen in 1080p

Simplifying

While typing in disper commands may be simple for some, others may not see it as having much of an advantage over using nvidia-settings or a graphical frontend for XrandR. To truly make it simple, you need to create a script and/or menu shortcuts.

For switching to the Sony TV, as in the example above, the script could be as simple as:

#!/bin/sh
disper -S -r 1280x720

Make sure to make your script executable with:

chmod a+x script-name
KDE menu editor, adding disper custom script

You could also come up with something more complex that will automatically detect displays and switch back and forth. You could then bind the command to a shortcut using your desktop environment (For example, in KDE, use kmenuedit, where you can assign a keyboard shortcut to a command). You can also create a script for each setting and then easily switch to the one you need from the run command dialog (Alt+F2).

Subscribe to our newsletter!

Our latest tutorials delivered straight to your inbox

Tavis J. Hampton

Tavis J. Hampton is a freelance writer from Indianapolis. He is an avid user of free and open source software and strongly believes that software and knowledge should be free and accessible to all people. He enjoys reading, writing, teaching, spending time with his family, and playing with gadgets.