Getting Graphical with Video Bling - Improving Performance - Hacking Ubuntu (2007)

Hacking Ubuntu (2007)

Part III: Improving Performance

Chapter 9: Getting Graphical with Video Bling


When you install the Ubuntu desktop, the video display becomes the single most important system. If the mouse doesn't work, you can use the keyboard. If the keyboard does not work, then you can remotely login. However, if the display does not work, then you cannot see what you are doing and are completely out of luck.

Some Linux versions install very basic VGA or SVGA graphics support. It is up to the user to upgrade the driver to something other than the default low resolution (for example, 800 × 600 with 256 colors).

Ubuntu takes the next step. During the installation of the graphical desktop, it tries to detect your video card. In most cases, you will end up with at least 1024 × 768 and 24-bit color (16 million colors). Although this is good for getting started, it might not be the best you can do.


If you start off with 800 × 600 and 256 colors, then you probably have an unsupported video card. Video cards have really come down in price-you can get a decent one that can do 1024 × 768 (or higher resolution!) with true color for under $30. See for a list of supported video cards.

With graphics come customizable elements such as screen savers and animated background. I've seen some people spend hours selecting and tuning screen savers. Other customizations that are becoming really common are dual-monitors and cross-desktop systems. With Ubuntu (and a little tweaking) you can enable two monitors on the same computer, or use a second computer as a second monitor.

Tuning Graphics

During the installation, Ubuntu detects the graphics card and installs a usable driver. The detection is done using the ddcprobe and xresprobe commands. For example, to list all of the resolution information about my video card and monitor, I can use:

$ sudo ddcprobe -?

vbe: VESA 3.0 detected.


vendor: NVIDIA Corporation

product: NV18 Board - p160nz Chip Rev A4

memory: 131072kb

mode: 640x400x256

mode: 640x480x256

mode: 800x600x16

mode: 800x600x256

mode: 1024x768x16


$ sudo xresprobe any

id: L1780U

res: 1280x1024 1024x768 800x600 720x400 640x480

freq: 30-83 56-75

disptype: crt


For xresprobe, you may also need to specify the type of driver. For example, sudo xre- sprobe ati works for the ATI driver. Other drivers include vesa, nvidia, nv, and i810.

These commands identify the video card and monitor. During the desktop install, they are used to identify the maximum resolution and to configure the /etc/X11/xorg.conf file.

Unfortunately, ddcprobe does not always know about your monitor, especially if you are using old equipment. If your graphics card supports 1280 × 1024 but your monitor supports only 1024 × 768, then you won't be able to see the display at 1280 × 1024. Unless you have a really old CRT monitor, your display probably supports 1024 × 768. Thus, this is usually the default resolution. To change the default resolution, use the System Image from book Preferences Image from book Screen Resolution applet (see Figure 9-1). From here, you can select the desired resolution and refresh rate. You can also choose to set new resolution for your login account or make it a system-wide change.

Image from book
Figure 9-1: The Screen Resolution applet

Changing Screen Resolution (xrandr)

The System Image from book Preferences Image from book Screen Resolution applet does not list all of your available screen resolutions and settings. The full list of supported screen resolutions can be found with the X-Windows rotate and reflection command: xrandr. For example, to list the screen resolutions supported by the video driver, you would use:

$ xrandr -q

SZ: Pixels Physical Refresh

*0 1280 x 1024 ( 342mm x 271mm ) *75 60

1 1024 x 768 ( 342mm x 271mm ) 75 70 60

2 800 x 600 ( 342mm x 271mm ) 75 72 60 56

3 640 x 480 ( 342mm x 271mm ) 75 73 60

4 1280 x 960 ( 342mm x 271mm ) 60

5 1280 x 800 ( 342mm x 271mm ) 60

6 1152 x 864 ( 342mm x 271mm ) 75

7 1280 x 768 ( 342mm x 271mm ) 60

8 832 x 624 ( 342mm x 271mm ) 75

9 640 x 512 ( 342mm x 271mm ) 75 60

10 720 x 450 ( 342mm x 271mm ) 60

11 640 x 400 ( 342mm x 271mm ) 60

12 576 x 432 ( 342mm x 271mm ) 75

13 640 x 384 ( 342mm x 271mm ) 60

14 512 x 384 ( 342mm x 271mm ) 75 70 60

15 416 x 312 ( 342mm x 271mm ) 75

16 400 x 300 ( 342mm x 271mm ) 75 72 60 56

17 320 x 240 ( 342mm x 271mm ) 75 73 60

In this example, my video driver supports 18 different screen resolutions, and up to 4 different refresh rates. These resolutions are not necessarily the same as the ones listed in /etc/X11/ xorg.conf (for X-Windows), and may not be supported by your monitor.


Your video card, video driver, and monitor many not all support the same resolutions. The xrandr command shows your video driver resolutions and allows you to set a screen resolution that is not supported by your montior. This could damage your monitor and video card!

You can use xrandr to change resolutions by specifying one of the listed sizes. Using the example, you can set the screen to 1024 × 768 with any of these commands:

xrandr -s 1 # screen size 1 is 1024x768

xrandr -s 1024x768 # specify by dimensions

xrandr -s 1024x768 -r 70 # for 70 Hz (default listed is 75 Hz)

xrandr -s 1 -r 70 # screen size 1 at 70 Hz


If you specify an invalid screen resolution or refresh rate, then xrandr will fail with a cryptic error message. However, it won't make any screen changes.

Thinking Safety

When the Screen Resolution applet makes changes, it gives you 20 seconds to undo the change. This way, if the resolution is not supported and the display becomes dark or unreadable, then you just need to wait 20 seconds for it to switch back. Unfortunately, with xrandr, you do not have that luxury. The xrandr command will change the resolution immediately and it assumes you know what you are doing.

If you want to test a screen change with xrandr, use a small script (see Listing 9-1) to save the current resolution, change the screen, and then change back. If you like the resolution, you can press Ctrl+C to kill the script, or run xrandr without the test script to set the resolution.

Listing 9-1: Script to Test a Screen Resolution


# Temporarily change resolutions (great for testing)

# Example usage: ./testres -s 1 (to set to xrandr screen setting #1)

# Save current resolution

Resolution=`xrandr -q | grep '*' | awk -F'*'

awk '{print $2 $3 $4}'`

Rate=`xrandr -q | grep '*' | awk -F'*'

echo "Old: Resolution: $Resolution Refresh rate: $Rate Hz"

# Set the resolution using the command-line options.

xrandr $*

echo "New: `xrandr -q | grep '*'`"

# Wait 20 seconds, then change back

sleep 20

xrandr -s $Resolution -r $Rate

echo "Switching back"

echo "Current: `xrandr -q | grep '*'`"

Flipping Cool!

Some video drivers support flipping the screen. If your video driver supports this, then you can use xrandr -x to flip the screen horizontally, making a mirror reflection. The xrandr -y command flips the screen vertically, and xrandr -x -y flips both. Similarly, the -o option can change the orientation from normal (-o normal) to rotated 90 degrees (-o right), 180 degrees (-o inverted), and 270 degrees (-o left).

However, not every video driver supports flipping and rotation. If your driver does not support these commands, then xrandr will give you a cryptic error message such as:

X Error of failed request: BadMatch (invalid parameter attributes)

Major opcode of failed request: 155 (RANDR)

Minor opcode of failed request: 2 (RRSetScreenConfig)

Serial number of failed request: 12

Current serial number in output stream: 12

Practical Uses for xrandr

By now you're probably thinking, "xrandr is cool, but it has no long-term practical use." Most people set the display and that's it. However, sometimes there is a need to switch between display resolutions. For example, web designers may want to quickly switch screen resolutions to see what their web pages look like with different settings. This is important since not everyone uses 1280 × 1024. On the laptop that I use for presentations, I use xrandr to quickly change the display to something that will work with the overhead projector; I've seen too many conferences where people spend more time fighting with the projector rather than actually presenting. And for this book, I used a quick script (see Listing 9-2) to change the screen resolution, set the background, colors, etc. to match the publisher's guidelines for screen shots. This script ensures that every screen shot is taken the same way.

Listing 9-2: The setbg Script for Taking Hacking Ubuntu Screen Shots


# Set background to white for a screenshot, then put it back.

# Publisher requirements:

# - White background (so hide my background)

# - 1024x768 (so lower the resolution from my normal 1280x1024)

# Wait for a key press, then put it all back.

# Save current settings (background colors, settings, and image)

RES=`gconftool-2 --get /desktop/gnome/screen/default/0/resolution`

BG1=`gconftool-2 --get /desktop/gnome/background/primary_color`

BG2=`gconftool-2 --get /desktop/gnome/background/secondary_color`

BG=`gconftool-2 --get /desktop/gnome/background/draw_background`

BGI=`gconftool-2 --get /desktop/gnome/background/picture_filename`

# Set change

xrandr -s 1024x768

gconftool-2 -t str --set /desktop/gnome/screen/default/0/resolution "1024x768"

gconftool-2 -t str --set /desktop/gnome/background/primary_color "#ffffff"

gconftool-2 -t str --set /desktop/gnome/background/secondary_color "#ffffff"

gconftool-2 -t boolean --set /desktop/gnome/background/draw_background "False"

gconftool-2 -t str --set /desktop/gnome/background/picture_filename ""

# Wait

echo "Use Control-Alt-D to hide all windows (and later restore)"


# Put it back

xrandr -s 0 # this is my default resolution

gconftool-2 -t str --set /desktop/gnome/screen/default/0/resolution "$RES"

gconftool-2 -t str --set /desktop/gnome/background/primary_color "$BG1"

gconftool-2 -t str --set /desktop/gnome/background/secondary_color "$BG2"

gconftool-2 -t boolean --set /desktop/gnome/background/draw_background "$BG"

gconftool-2 -t str --set /desktop/gnome/background/picture_filename "$BGI"

Changing Video Drivers

X-Windows supports dozens of graphics cards. For a quick list, use apt-cache search video driver. Most of these video drivers are installed on the system during the default Ubuntu installation and are found in /usr/lib/xorg/modules/drivers/. The enabled graphic card is listed in the /etc/X11/xorg.conf file, under the "Device" section. For example:

Section "Device"

Identifier "ATI Technologies, Inc. Rage 128 RL/VR AGP"

Driver "ati"

Option "UseFBDev" "true"


This specifies the use of the ati driver found in /usr/lib/xorg/modules/drivers/ If you want to change the driver, then you will need to change the xorg.conf configuration and restart the X-server.


You can restart the X-server by either rebooting or pressing Ctrl+Alt+Backspace. Since this will kill all your X-Window applications, you should logout before restarting the server.


If you install the wrong video driver, then X-Windows will fail to start. Be sure to make a backup of the xorg.conf file before making modifications. This way, if X-Windows breaks, then you will have a working configuration that you can put back.

Enabling OpenGL

The Open Graphics Library (OpenGL) provides a set of extensions for accelerated 2D and 3D rendering. Without this extension, some graphics must be explicitly drawn by each application, leading to slower graphic rendering.

Some video card drivers support OpenGL without any additional steps. For example, if you have an Intel, SiS, or Matrox video card, then OpenGL may already be supported and enabled. However, if you have an NVIDIA or ATI video card, then you will need to change drivers and install the accelerated graphics extensions.

To tell if you need to enable OpenGL, use the glxinfo command:

$ glxinfo | grep "direct rendering"

direct rendering: No

If it says yes, then OpenGL is already enabled. However, if it says no, then either OpenGL is not supported, or you need to enable it.

1. To enable OpenGL, make sure your video card is either NVIDIA or ATI. Use the lspci command to list your video cards. If the result does not say "nVidia" or "ATI" (in lowercase, uppercase, or mixed case), then you do not need these steps.

2. $ lspci | grep -i -e Display -e VGA # on an iMac

3. 0000:00:10.0 Display controller: ATI Technologies Inc Rage 128 RL/VR

4. AGP

5. $ lspci | grep -i -e Display -e VGA # on a PC

6. 0000:01:00.0 VGA compatible controller: nVidia Corporation NV18

7. [GeForce4 MX 4000 AGP 8x] (rev c1)

Not every ATI and NVIDIA card is supported. Make sure the model listed by the lspci command matches a supported card:

o ATI must be a 9xxx series, 9500 series (or higher), or have TV-out support. Your monitor must also support at least 60 Hz.

o NVIDIA supports GeForce, nForce and Quadro models with AGP, TV-out, and flat panel displays.

o NVIDIA supports older TNT, TNT2, and GeForce models with legacy drivers.


The two example lspci commands show an ATI Rage 128 video card in an iMac system that is not supported, and a NVIDIA GeForce4 MX 4000 card in a PC system with AGP that is supported.

8. Back up your xorg.conf file. If anything does not work, you'll need this backup copy to return to a working display.

9. sudo cp /etc/X11/xorg.conf /etc/X11/xorg.conf.bak

10. Regardless of your video card, you will need to install the restricted drivers for your kernel (if they are not already installed).

11. sudo apt-get install linux-restricted-modules-`uname -r`

At this point, you must perform some card-specific configurations.

If you have an ATI video card…

1. Install the ATI drivers:

2. sudo apt-get install xorg-driver-fglrx fglrx-control

3. Run these commands to configure your xorg.conf file:

4. sudo aticonfig --initial sudo aticonfig --overlay-type=Xv

5. Reconfigure the X-server:

6. sudo dpkg-reconfigure xserver-xorg

This auto-detects your video card. Be sure to select fglrx and not ATI. For the remaining prompts (and there are a lot of prompts), you can just press enter and select the default values. (Since you're already running the X-server, the default values work.)

7. Check your /etc/X11/xorg.conf settings and make sure the driver in the "Device" section says: Driver "fglrx".

8. Restart your X-server. You can do this by rebooting or by logging out and then pressing Ctrl+Alt+Backspace.

If all goes well, then your display will start. Otherwise, you should be stuck at a text prompt- skip to the "Debugging X-Windows" section for resolving the problem.

If you have an NVIDIA card…

1. Install the NVIDIA drivers for the current or legacy card. Do not install both. (Actually, apt-get will not allow you to install both.)

2. sudo apt-get install nvidia-glx nvidia-kernel-common

If you have a legacy card, use:

sudo apt-get install nvidia-glx-legacy nvidia-kernel-common

3. If you previously made changes to your xorg.conf file, then make sure it is archived:

4. md5sum /etc/X11/xorg.conf | sudo tee /var/lib/x11/xorg.conf


While archiving xorg.conf is always a good thing, the NVIDIA configuration script will not continue if it is not archived.

5. Configure the driver:

6. sudo nvidia-glx-config enable

7. Edit xorg.conf and check the "Device" section. The driver should be nvidia and not nv. If it says nv, then change it to nvidia.

8. When you are editing xorg.conf, add the following line to the "Device" section to disable the NVIDIA splash screen (and speed up the boot time):

9. Option "NoLogo" "true"

The full Device section should look something similar to this example (although your video card model and BusID may be different):

Section "Device"

Identifier "NVIDIA Corporation NV18 [GeForce4 MX 4000 AGP 8x]"

Driver "nvidia"

BusID "PCI:1:0:0"

Option "NoLogo" "true"


10. Restart your X-server. You can do this by rebooting or by logging out and then pressing Ctrl+Alt+Backspace.

If all goes well, then your display will start. Otherwise, you should be stuck at a text prompt- skip to the next section, "Debugging X-Windows", for resolving the problem.

Debugging X-Windows

When X-Windows fails, it either drops you at a text prompt, or leaves the screen blank. In the worst case, you will need to reboot the computer in order to get to a text login prompt. The X- Windows system logs everything-including cryptic error messages-in /var/log/Xorg.0.log. Check the log for a place to start debugging. Fortunately, problems usually fall into one of four categories:

1. Human error. Make sure you didn't type something wrong. The xorg.conf file is not very forgiving of typographical errors.

2. Your card is not supported.

3. You installed multiple, conflicting drivers.

4. Your card was not recognized properly.

The first problem can be resolved by checking everything that you entered into the xorg.conf file. The other items are a little more complicated and are covered in the next subsections.

Putting Things Back

If your card is not supported or your changes were not correct, then put back your xorg.conf file. You should be able to run startx from the command line. This will start the graphics system and let you know if you put it back correctly.


Hopefully you made a backup of /etc/X11/xorg.conf. If you didn't, then all is not lost. Some drivers make backups automatically when they install. Look in the /etc/X11/ directory for files like xorg.conf˜ and xorg.conf.backup. These are probably functional configuration files. In the worst case, you can run sudo dpkg-reconfigure xserver-xorg to generate a new configuration file.

Although startx is good for running the server and debugging the xorg.conf file, it runs the server from your text login. This means that logging out or shutting down from the graphical desktop will return you to your text command prompt; it will not actually log you out or reboot the system. To get the automatic login working, use:

sudo /etc/init.d/gdm restart

Debugging the Wrong Driver

Usually people will blindly install one driver and, if it does not work, then try the other. (Ok, I admit that I've done that.) If you're going to do this, be sure to remove the unused driver first; otherwise, neither driver will work.

§ To remove the ATI drivers, use:

§ sudo apt-get remove xorg-driver-fglrx fglrx-control

§ To unconfigure the NVIDIA drivers, use:

§ sudo /usr/bin/nvidia-installer --uninstall

§ sudo apt-get remove nvidia-glx # for current cards

§ sudo apt-get remove nvidia-glx-legacy # for legacy cards

§ To copy back your xorg.conf file, use:

§ sudo cp /etc/X11/xorg.conf.bak /etc/X11/xorg.conf

§ Restart your X-Windows system by either rebooting or logging out and pressing Ctrl+Alt+Backspace.

Forcing Drivers to Install

For ATI, some cards are claimed to be unsupported even through they will work. For example, the Radeon Mobility 9600 (found in laptops) is reported as unsupported by the ATI drivers. You can change the PCI ID and try to fake the driver into thinking the card is supported. For example, the Radeon Mobility 9600 uses PCI ID 4e53 (found using the lspci -n command). You can add a line to the xorg.conf"Device" section to specify a supported ID (for example, 4e50-the Radeon 9600 M10-is supported and seems to be compatible with the 4e53). For example:

Section "Device"

Identifier "ATI"

Driver "fglrx"

ChipID 0x4e50



The full list of PCI IDs is found in /usr/share/misc/pci.ids. Vendors usually follow a consistent ID convention, so the 4e50, 4e51, 4e52, and 4e53 are all ATI Radeon cards. If one does not work, try another. However, forcing an ATI ID onto a non-ATI card (for example, Cirrus GD 5440) has virtually no chance of working.

Adjusting with xvidtune

Many newer computers come with flat LCD displays. This means the picture is usually centered. (And if it isn't, then there should be an auto or manual adjustment setting.) However, CRT monitors are not always centered. The desktop may appear slightly cut off at the top, bottom, left, or right. (In the case of some monitors, the desktop may be cut off by more than a little.) The xvidtune program allows you to adjust the screen width, height, and position by tuning the horizontal and vertical scan frequencies.

The xvidtune program does not actually perform the system changes (although it does allow you to test the settings). Instead, it generates code that can be inserted into /etc/X11/xorg.conf for adjusting the monitor automatically.

1. Open a terminal and run the xvidtune program. This will display a warning about possible damage to your monitor (see Figure 9-2). Take this warning seriously, then smile, and click OK.

Image from book
Figure 9-2: The xvidtune warning screen


You will need to run xvidtune from a terminal window (for example, Applications Image from book Accessories Image from book Terminal). This is because the final output from xvidtune will be printed in the terminal window.

2. The xvidtune menu may not be pretty, but it is functional (see Figure 9-3). At the top of the window are the actual horizontal and vertical scan synchronization values used to denote the start of an analog video scan. I usually ignore these. The more important items are the buttons. These enable you to adjust the screen.

Image from book
Figure 9-3: The xvidtune configuration settings

The xvidtune adjustment options are:

o Left, Right, Up, Down-These shift the screen's position.

o Wider, Narrower, Shorter, Taller-These options adjust the screen's width and height.

o Test-This temporarily applies the changes to the screen so you can see what it looks like.

o Auto-Rather than making adjustments and clicking Test, you can click Auto to automatically apply the changes as you make them. These changes are not permanent, but they allow you to see what they will look like.

o Restore-If you think you really screwed up, you can click this button to return to the current settings.

o Show-This displays the current settings in the text console where you started running xvidtune.

o Quit-This exits the program. You can also type q to quit.

3. Make your adjustments. Use Test or Auto to view your changes.


On some monitors, clicking Left or Right may really swing the display over to the side. Before making adjustments, move the xvidtune window into the middle of the screen. This way, it will not accidentally go out of view.

4. After finding a good adjustment setting, click Show. The terminal window should display a line with your settings. It should look similar to:

5. "1024x768" 78.80 1024 1040 1136 1304 768 769 772 796 +hsync +vsync

This line lists the resolution (in quotes) and the scan settings.

6. Edit /etc/X11/xorg.conf and scroll down to the Monitor section. Add a ModeLine option that includes the output from xvidtune. For example, mine (including a very long line that wraps on the screen) looks like:

7. Section "Monitor"

8. Identifier "iMac"

9. Option "DPMS"

10. HorizSync 60-60

11. VertRefresh 75-117

12. ModeLine "1024x768" 78.80 1024 1040 1136 1308

13. 768 769 772 796 +hsync +vsync

14. EndSection

15. Save your changes, log out, and restart the X-server using Ctrl+Alt+Backspace.


If you use multiple screen resolutions, then run xvidtune after changing each resolution. You can have multiple ModeLine entries in the xorg.conf file-as long as they all have different resolutions. Don't change screen resolutions while running xvidtune since it will not detect changes.

Improving Performance

When you have a slow display, everything else can seem to be slow. Much of this may be because the display is consuming CPU and memory resources. Fortunately, there are a few things you can do to improve the display's performance.

§ Install the accelerated drivers-The NVIDIA and ATI accelerated 3D drivers (mentioned in the Enabling OpenGL section) significantly improve performance. If you have the option to install either of these, then do it!

§ Disable the Nautilus background-Nautilus is used to place icons on the background (see Chapter 2). If this is disabled, then memory and CPU resources are freed up. Otherwise, Nautilus may need to redraw the background every time something on the screen changes. To disable it, use:

§ gconftool-2 --type bool \

§ --set /apps/nautilus/preferences/show_desktop FALSE

§ Disable Gnome background images-Drawing a background takes time and memory. If you don't need a background image, then turn it off. This can either be done by the background applet (System Image from book Preferences Image from book Desktop Background, select No Wallpaper) or with gconftool-2.

§ gconftool-2 --type string \

§ --set /desktop/gnome/background/picture_options none

§ Disable thumbnails-Nautilus can generate thumbnail icons and preview audio. If Nautilus opens a directory with lots of images in it, the overhead from creating thumbnails can be very noticeable (especially on slow systems). To disable previews, use:

§ gconftool-2 --type string \

§ --set /apps/nautilus/preferences/show_image_thumbnails never


If you want some thumbnail icons, use local_only instead of never. This gives you icons in local folders, but disables it for networked file systems. This way, you don't need to wait for the network to transfer all of the images-an action required for making thumbnail images.

§ Disable icons in menus-By default, every menu items includes an icon. While these icons are cached, they can take time to load (especially on a slow system). You can disable the icons using:

§ gconftool-2 --type bool \

§ --set /desktop/gnome/interface/menus_have_icons FALSE


Not everyone optimizes the display for cool graphics and speed. People with sight disabilities can optimize the display for their own needs. By default, Ubuntu includes many themes for addressing accessibility. For example, under System Image from book Preferences Image from book Theme, you can select High Contrast Large Print, Low Contrast Large Print, Large Print, Low Contrast, and so on. Even without my glasses, I can read the screen using the High Contrast Large Print theme without being inches from the monitor.

For people who have little or no sight, the default Ubuntu installation supports Braille displays. This is done using brltty. The brltty driver supports many different Braille displays and input devices. You can start it by opening a terminal window and running sudo brltty.

After you connect your Braille terminal, you can use Orca to map specific events, such as window actions, to the Braille terminal.

1. Install Orca using sudo apt-get install gnome-orca.

2. Configure it in a terminal by running orca-setup. It will ask you questions such as:

3. Use key echo? Enter y or n:

Orca supports some text-to-speech systems. If you have more than one speech server installed, it will ask you to select one of them.

4. After it is configured, Orca will finish tuning Gnome and create a $HOME/.orca directory. You will need to log out and log back in for the changes to take affect.

5. (Optional) You may also want to change the default init level in /etc/inittab from run-level 2 to run level 3.

6. id:3:initdefault:

Run level 3 is intended for accessibility needs and automatically starts the Braille display. See Chapter 3 for modifying init scripts and the run level.

Switching Screensavers

Under Dapper Drake, the default screen saver is gnome-screensaver. (Prior to Dapper, Ubunty Hoary and Breezy used xscreensaver.) Although gnome-screensaver does the basic job of preventing the screen from being burned in, it has some serious limitations. For example, it is missing many of the configuration options found in xscreensaver, and more importantly: it sometimes kicks in while applications are running full-screen. When I first upgraded to Dapper, I started playing my favorite game: bzflag. This is a full screen networked tank game. Ten minutes into the game, the screen would fade to black! At first I thought it was the game, then I realized that it was the screen saver. The game was intercepting all keyboard and mouse inputs. As a result, the screen saver thought the computer was inactive.

While I could have chosen to write a script around the game to temporarily disable the screen saver, I opted for a better solution: replace gnome-screensaver with xscreensaver. This gave me all the missing functionality, as well as a screen saver that was game-aware. This change requires a couple of steps:

1. Install xscreensaver.

2. sudo apt-get install xscreensaver

3. Disable the Gnome screensaver.

4. gconftool-2 --type boolean \

5. -s /apps/gnome_settings_daemon/screensaver/start_screensaver false


Do not try to uninstall gnome-screensaver since there are dependencies that will remove the entire desktop!

6. Stop the running gnome-screensaver.

7. sudo killall gnome-screensaver

8. Configure xscreensaver to start when you log in. Go to System Image from book Preferences Image from book Sessions Image from book Startup Programs. Click Add and enter:

9. xscreensaver -no-splash

Then click Close. This makes the new screen saver start when you login.

10. Change the menu preferences so that they use xscreensaver:

o Right-click the System menu and select Edit Menus. This brings up the Menu Editor applet.

o In the Menu Editor, scroll to the bottom of the left window and click Preferences.

o In the right window, scroll down and right-click Screensaver (see Figure 9-4). Select Properties from the item menu.

Image from book
Figure 9-4: The Menu Editor properties for the Screensaver item

o Change the command from gnome-screensaver to xscreensaver-demo. (see Figure 9-5).

Image from book
Figure 9-5: The properties for the Screensaver menu item

o Close all of the Menu Editor windows.

11. As root, edit the file /usr/share/applications/gnome-screensaver-preferences.desktop. Near the bottom you will see the line, Exec=gnome-screensaver- preferences. Change this line to Exec=xscreensaver-demo. Also, comment out (or delete) the following lines:

12. X-GNOME-Bugzilla-Bugzilla=GNOME

13. X-GNOME-Bugzilla-Product=gnome-screensaver

14. X-GNOME-Bugzilla-Component=general

15. X-Ubuntu-Gettext-Domain=gnome-screensaver


If you use sudo apt-get upgrade (or Synaptic's automatic upgrade) and refresh the screen saver package, then you may need to do this change again.

16. Open the screen saver preferences (System Image from book Preferences Image from book Screensaver) and deselect all of the grayed out screensaver options. If you do not disable them, then the default random screensaver may try to run missing screensavers, resulting in errors.


If you open the preferences before starting the screen saver (per these instructions), then you will receive a pop-up saying that the XScreenSaver daemon is not running. Click OK to launch it now. If the daemon is already running, then you won't see this pop-up message.

17. Select your desired screen saver, adjust the properties as you see fit, and close the window.

Now, xscreensaver is your default screen saver and will start from boot.

I have only found one limitation from installing xscreensaver: it does not work from the System Image from book Quit… menu. This menu normally brings up a window with options including Log Out, Restart, and Shutdown. The Lock Screen option breaks when you install xscreensaver. To get around this limitation, I installed an applet on the top panel that runs the command: xscreensaver-command -lock. (When you install xscreensaver, it even gives you an icon that looks like a monitor with a flame coming out of it.) In order to quickly lock the screen, I can click the xscreensaver icon on my top panel. Although this does not fix the Lock Screen option in the Quit… window, I find it is more convenient to click-and-lock rather than drill down menus in order to lock the screen.

Adding New Screensavers

The default Ubuntu installation includes some screensavers that are not installed under xscreensaver. For example, Lattice (my favorite GL screensaver) is not installed by default. To install Lattice, you'll need an OpenGL video driver (see the section on "Enabling OpenGL"). However, non-GL screensavers can also be added with the following steps:

1. As root, edit /etc/X11/app-defaults/XScreenSaver. This file lists all the screen- savers that xscreensaver knows about.

2. Search for fliptext-this is another screensaver that does exist. You'll use it as a template.

3. Duplicate the line and change fliptext to lattice. Keep the GL: since Lattice is a GL screensaver.

4. GL: fliptext -root \n\

5. GL: lattice -root \n\

6. Search further down for fliptext (there will be a second line). Duplicate this line and change fliptext and FlipText to lattice and Lattice.

7. * FlipText

8. * Lattice

9. Save your changes.

When you are all done, log out and restart the desktop using Ctrl+Alt+Backspace. When the graphics comes back up, it will be using your new screen saver and Lattice will be installed. You can select this screen saver using System Image from book Preferences Image from book Screensaver. If you followed the previous section on installing xscreensaver then this will run xscreensaver-demo and allow you to select Lattice-the interlocking rings.

Animating the Desktop Background

The default Ubuntu desktop can either be a solid color or a static image. With a few simple scripts, you can change the background image or color (see Chapter 2), but this isn't real animation. The secret to really animating the desktop is to run an X-Windows application that draws the background. Here's an example where the background is drawn by a screen saver.

1. You'll need to tell Nautilus to not draw the desktop. This means that you will lose all your desktop icons, but who needs icons when you can animate the desktop!

2. gconftool-2 -t bool /apps/nautilus/preferences/show_desktop -s false

3. Start the X-application that will draw the background. In this case, I'll use the Lattice screen saver, tell it to draw the full background (-root window), render rings that look like circuits (as apposed to doughnuts, brass, etc.) and consume fewer CPU cycles (-n and nice). The other options specify the rendering rate (20 frames per second), motion speed (-e 1), field of view (-o 30), and a background fog (-f). All of these options are detailed in the man page for lattice.

4. nice /usr/lib/xscreensaver/lattice -root --circuits \

5. -n -s -e 1 -f -o 30 -x 20

This creates an animated background with moving rings (see Figure 9-6).

Image from book
Figure 9-6: An animated background using the lattice screen saver


Lattice is a GL screen saver. If your video driver does not have GL support, Lattice will not work. In addition, if your OpenGL video driver does not have direct rendering enabled, then Lattice will consume all of your CPU resources, making the system sluggish. You can always choose a different screen saver that is better supported by your display.

Any application that can render to the root window can be used as a background image. However, there are a few caveats:

§ Applications do not store the images behind them-As a result, a background that does not redraw the screen (for example, /usr/lib/xscreensaver/sonar -root) can have large gaps when a window is moved or closed. The best backgrounds render the entire screen at least 5 times per second-20 times per second is better.

§ Some background applications consume lots of resources-For example, running /usr/lib/xscreensaver/colorfire –root can noticeably slow down your system. Good backgrounds consume few resources, and many screen savers have options to lower their resource consumption.

§ As funny as it may sound, moving backgrounds can give some people a sense of motion sickness-Although sonar probably won't cause a problem, the constant motion from lattice can be both fun and not so fun. Consider testing the background before you make it permanent.

Disabling Animated Backgrounds

If you decided to turn off the animated background, you'll need to follow a few steps:

1. Kill the background animation. For example, if you are running lattice then use killall lattice. This will stop the background from being drawn. However, it won't put back your default background and moving windows will start erasing parts of the background.

2. Tell Nautilus that it is OK to draw the background.

3. gconftool-2 -t bool /apps/nautilus/preferences/show_desktop -s true

4. Even though Nautilus now has permission to draw the background, you still need to force it to redraw the background once. You can do this by logging out and logging back in, or running: nautilus -q ; nautilus. This will quit Nautilus and-if it does not automatically restart-start it.

Configuring Dual Monitors

The graphical display has a limited amount of screen real estate. As more windows are opened, space on the desktop becomes an issue. Using the Workplace Switcher (see Chapter 8) is a good start, but eventually you will find yourself rapidly switching back and forth between desktops as you try to use two applications at once. For serious power users, one monitor is usually not enough. Ubuntu offers a couple of different options for adding multiple monitors:

§ Two headed systems-One computer can have multiple graphics cards. This is an ideal solution for people with extra hardware. Alternately, some graphics cards are capable of driving more than one monitor.

§ Networked desktops-Two different computers combine to form one virtual desktop. This is a great option when you have spare computers lying around.

§ Shared desktops-There is no reason why all of the desktops need to run the same operating system. This is a must-have for anyone with a need to use Windows, Mac OS X, and Linux at the same time.

Using Two Heads

If your computer has multiple video ports, then you can frequently use them to drive two different monitors. Although most workstation computers don't have multiple video cards installed, you can always plug in an extra one. However, many laptops include two video sources: one for the LCD display and one for an external monitor. In some cases, these video ports can be configured to work together, forming one large display, while other laptops must display the same thing on both ports.


The computer display is commonly called a head. A computer with two displays is a dual-headed system. Many servers are headless, since they have no display attached.

There are two ways to have a dual-headed system. The first is to combine monitors using TwinView. However, TwinView is strictly limited to nVidia video cards. The more universal option is Xinerama.

Using Two Heads with TwinView

If you have an NVIDIA graphics card and it supports two monitors, then you can use TwinView to combine both monitors into one desktop. TwinView is an NVIDIA-specific graphics extension for managing multiple monitors.

1. Create a backup of your working xorg.conf file.

2. sudo cp /etc/X11/xorg.conf /etc/X11/xorg.conf.orig

3. Tell X-Windows about the second monitor. In the file /etc/X11/xorg.conf is a section titled "Device". This contains the video card attributes. Add in TwinView options for the second monitor. For example:

4. Section "Device"

5. Identifier "NVIDIA Corporation NV18 [GeForce4 MX 4000 AGP 8x]"

6. Driver "nvidia"

7. BusID "PCI:1:0:0"

8. Option "TwinView"

9. Option "MetaModes" "1280x1024,1280x1024; 1024x768,1024x768"

10. Option "TwinViewOrientation" "RightOf"

11. Option "ConnectedMonitor" "CRT,CRT"

12. Option "SecondMonitorHorizSync" "UseEdidFreqs"

13. Option "SecondMonitorVertRefresh" "UseEdidFreqs"

14. # Option "SecondMonitorHorizSync" "24-80"

15. # Option "SecondMonitorVertRefresh" "50-75"

16. EndSection

These options include pairs of video resolutions (one for each monitor), the location of the second monitor (right of the first), and the monitor scan rates (either using defaults or specifying range).

17. Save your new xorg.conf file and restart the X-server. Log out and use Ctrl+Alt+ Backspace to restart the server. If it does not come up, then refer to the section "Debugging X-Windows" earlier in this chapter. (If it does come up, then you're done and you should have two working displays.)

Using Two Heads with Xinerama

If your system has two different video ports, then you can use Xinerama to link them into one virtual display. Before you can use two monitors, you will need to make sure the computer actually has two video devices. Use the lspci command to list all display devices:

lspci -X | grep -i -e VGA -e DISPLAY

If only one display controller is listed, then you won't be able to use this option. However, if you see multiple video cards, then you can configure your X-server to use both cards. This requires editing the /etc/X11/xorg.conf file.

1. Create a backup of your working xorg.conf file.

2. sudo cp /etc/X11/xorg.conf /etc/X11/xorg.conf.orig

3. Tell X-Windows about the second monitor. In the file /etc/X11/xorg.conf is a section titled "Monitor". This contains a unique identifier and monitor attributes. Create a second one for your second monitor. For example:

4. Section "Monitor"

5. # Default monitor

6. Identifier "LCD"

7. Option "DPMS"

8. EndSection


10. Section "Monitor"

11. # Second monitor that I added

12. Identifier "CRT"

13. Option "DPMS"

14. HorizSync 31.5 - 57.0

15. VertRefresh 50-100

16. # You may want to add ModeLine items later

17. EndSection

18. Each monitor in the xorg.conf file may display different desktop screens. You need to tell X-Windows about the second screen. In the file /etc/X11/xorg.conf is a section titled "Screen". This contains a unique identifier and information about the graphics modes. Create a second screen section with a different identifier for the second monitor. For example:

19. Section "Screen"

20. # Define the first screen

21. Identifier "Default Screen"

22. Device "NVIDIA Corporation NV18 [GeForce4 MX 4000 AGP 8x]"

23. Monitor "LCD"

24. DefaultDepth 24

25. BusID "PCI:1:0:0" # optional for distinguishing cards

26. SubSection "Display"

27. Depth 24

28. Modes "1024x768"

29. EndSubSection

30. EndSection


32. Section "Screen"

33. # Define the second screen

34. Identifier "Second Screen"

35. Device "ATI Technologies, Inc. M9+ 5C63 [Radeon Mobility 9000 (AGP)]"

36. Monitor "CRT"

37. DefaultDepth 24

38. SubSection "Display"

39. Depth 24

40. Modes "1280x1024"

41. EndSubSection

42. EndSection


Be sure the labels in your Screen section's "Monitor" lines match the unique identifiers from the Monitor sections. The Device name and option BusID value should match the results from the lspci -X command.


Use the BusID option when you have two of the same type of video card in one computer. This distinguishes one card from the other.

45. In the /etc/X11/xorg.conf file is a section titled "ServerLayout". This is where you will specify the geometry of the desktop. Using the screen identifiers, you need to specify the X-display number (for example, 0 for DISPLAY=:0, 1 for DISPLAY=:1, and so on) and their relationship in forming the desktop: Above, Below, LeftOf, or RightOf. For example, if my CRT monitor is located to the right of the LCD monitor, then I can use:

46. Section "ServerLayout"

47. Identifier "Default Layout"

48. Screen 0 "Default Screen"

49. Screen 1 "Second Screen" RightOf "Default Screen"

50. InputDevice "Generic Keyboard"

51. InputDevice "Configured Mouse"

52. InputDevice "stylus" "SendCoreEvents"

53. InputDevice "cursor" "SendCoreEvents"

54. InputDevice "eraser" "SendCoreEvents"

55. InputDevice "Synaptics Touchpad"

56. EndSection

57. (Optional) If you want to have the displays linked as one desktop, rather than being treated as individual displays, then you will need to add a Xinerama option. This can be done by creating a section titled "ServerFlags" and setting the Xinerama option to true.

58. Section "ServerFlags"

59. Option "Xinerama" "true"

60. EndSection

Alternately, you can add the Option line to the "ServerLayout" section.

61. If you have everything in place, then you should be able to save your new xorg.conf file and restart the X-server. Logout and use Ctrl+Alt+Backspace to restart the server. If it does not come up, then you'll need to go to the section in this chapter titled "Debugging X-Windows." (If it does come up, then you're done and you should have two working displays.)


The big trick to making a multi-display desktop is the Xinerama extensions to X- Windows. This library is installed by default and allows you to chain multiple X- Windows displays into one large, virtual desktop. Without the flag, multiple displays can be used, but they do not appear as one coherent desktop.

How can you tell if you need the flag?

§ If you cannot drag a window across the desktop, from one monitor to the other, then you need the Xinerama flag.

§ If your graphical desktop (Gnome or KDE) replicates the background image and panels in every window, then you need the Xinerama flag. Without the flag, each display is treated independently. With the flag, they are linked into one large desktop. However, as one large desktop all panels will only appear in the first display. This allows the secondary displays to be used for presentation projectors and not be cluttered with panels and widgets.

Using Two Computers and One Desktop

If you have a high-end computer or two high-end video cards in one system, then connecting two monitors to one computer is definitely the way to go. However, there are some situations where it is more desirable to use a second computer to run the second display. For example:

§ You do not have a second video card to put into your system. In my case, I have no spare video cards available, but I have plenty of spare computers that have video cards built into their motherboards.

§ Your computer does not have available expansion slots for a second video card. Some low-end PCs are not expandable. Many times, motherboards have only one high-bandwidth slot for a high-end video card. You may have extra expansion slots, but may be unable to use them for graphics.

§ Your second monitor is built into a stand-alone computer (for example, My grape iMac has a monitor built into the computer housing.)

Whatever your situation might be, you can extend your virtual display such that it spreads across computers. All you need are two or more networked computers running X-Windows.


Ideally you'll want the network to be fast. In some corporate environments, physically adjacent computers may actually be on different subnets. Since transmitting video consumes bandwidth, consider investing in a cheap router and putting all of the display computers on the same subnet. Latency across a slow network can be very noticeable.

1. Your virtual display will have one primary display (for the mouse and keyboard) and one or more secondary displays that will provide the desktop. Install the Distributed Multihead X Project server (Xdmx) on the primary computer. This will be used to bridge different X-Windows systems.

2. sudo apt-get install xdmx

3. Each of the machines that will be part of the virtual desktop will need to allow remote access to their X-Windows system. The problem is, the default Ubuntu installation disables all remote access. Thus, you will need to enable it. How you enable it depends on your desktop.

o For Ubuntu's default window manager, Gnome, you must edit

o /etc/gdm/gdm.conf. Change DisallowTCP=true to DisallowTCP=false.

o For the Kubuntu KDE window manager, you must edit /etc/kde3/kdb/kdbrc and change ServerArgsLocal=-nolisten tcp to ServerArgsLocal= (no parameters).

o For other window managers, such as TWM, you will need to edit

o /etc/X11/xinit/xserverrc and change exec /usr/bin/X11/X -dpi 100

o -nolisten tcp to exec /usr/bin/X11/X -dpi 100.

After making this change, you will need to restart the X-server. Pressing Ctrl+Alt+ Backspace won't cut it (that only re-reads configuration files). Instead, you will need to either reboot the system or restart the display. For example, to restart Gnome you can use:

o Stop Gnome using: sudo /etc/init.d/gdm stop.

o At the text screen, press Alt+F2 to get to a text login screen.

o Log in.

o At the command-line prompt, run: sudo /etc/init.d/gdm start.

4. Use xhost +hostname to enable remote access for the display server. For example, if my primary server is named alpha, then I would use xhost +alpha. You can also specify an IP address such as xhost +

5. On the primary display server, enable local access.

6. xhost +local:

7. Now you can use Xdmx to link all of the displays together. For example, if my secondary display is on the computer named bravo, then on the primary system I would run:

8. Xdmx :1 -display :0 -display bravo:0

This assigns the virtual desktop as display :1. The virtual desktop spans :0 on the primary system (the normal display) and bravo:0 is located to the right. If I had a third system (for example, charlie), then I could use:

Xdmx :1 -display :0 -display bravo:0 -display charlie:0

Xdmx takes a variety of different options. For example, the primary display does not need to be on the left. However, if it is not on the left, then you will need to specify which display will provide the keyboard and mouse input.

Xdmx :1 -input :0 -display bravo:0 -display :0 -display charlie:0

Other useful options include:

§ +xinerama-If you need to enable to Xinerama flag, then use Xdmx +xinerama.

§ -ignorebadfontpaths-It's not uncommon to have default font paths in the X configuration when they don't actually exist. This flag tells Xdmx to ignore bad font paths.

§ -configfile and -config-The virtual display does not need to be horizontal. You can also specify vertical alignment. The -configfile option identifies the configuration file, while the -config option allows you to choose which virtual display layout you would like. Listing 9-3 shows an example configuration file with different layouts.

Listing 9-3: A Sample Xdmx Configuration File (xdmx.conf)

# A basic horizontal (left to right) alignment. Use -config l2r

virtual l2r


display :0 @0x0; # the top corner will be at 0x0

display bravo:0 @1024x0; # place it 1024 pixels to the right


# A vertical alignment using a 1x2 grid. Use -config virtual_stack

virtual vertical_stack { wall 1x2 bravo:0 :0; }

# A huge 3x3 display. Use -config grid3x3.

virtual grid3x3


wall 3x3

bravo:0 charlie:0 delta:0

echo:0 :0 foxtrot:0

golf:0 hotel:0 india:0;


# Specify two displays with absolute position 200x200

# This will overlay the displays (good for projection systems)

virtual overlay { display alpha:0 @200x200; display :0 @0x0; }

The Xdmx command creates the X-Windows desktop, but does not start any window managers. This means that every display will have the plain X-Windows gray color. For a more usable desktop, you will need to start a window manager. Listing 9-4 is an example startup script that runs Xdmx and starts the Gnome window manager. You can extend this script to start specific applications like a terminal or graphical monitor.


To quickly shut down Xdmx, press Ctrl+Alt+Q. This will kill the Xdmx system and immediately close all windows.

Listing 9-4: Sample Startup Script for Xdmx with a Window Manager


# Give permission to open an X application.

xhost +local:


# Save the displays


export NEWDISPLAY=:1

# Start Xdmx (use -configfile or -display to specify the virtual


Xdmx $NEWDISPLAY +xinerama -ignorebadfontpaths \

-input $REALDISPLAY -configfile xdmx.conf -config l2r &


sleep 2 # give it time to come up

# Select your window manager

# Gnome should not have a SESSION_MANAGER variable set.


gnome-session --sm-disabled &

#startkde & # run KDE as the window manager

#twm & # run TWM as the window manager

#xterm & # run a plain terminal


If you always want to run the virtual display, then you can add the startup script to your $HOME/.xinitrc. This way, it will always start up after you log in to a graphical desktop.

The Xdmx command has two significant limitations. First, if the network goes down or one of the virtual desktop computers crashes, then the program will abruptly exit. If you lose one of the desktops, then you will lose all of them. Second, creating a virtual desktop between two very different hardware platforms (for example, PC and Mac) can result in screwed up colors- even if all of the platforms are running Ubuntu with true 24-bit color. For best results, stick with the same hardware platforms.

Using Two Computers with Different Desktops

In the corporate world, few Linux users work strictly with other Linux users. Usually you need to interact with a wide variety of Windows, Linux, and Unix users (and the rare OS/2 fanatic). I know plenty of people who run two computers, one Linux and one Windows, for full compatibility. The problem is, they spend a lot of time either transferring files or using shared hard drives. Taking output from a Linux program and pasting it into a Microsoft Outlook e-mail is definitely a multi-step solution. While Part II of this book (and Chapter 6 in particular) covered many of the ways to share information between different operating systems, there is another option.

Using a tool called Synergy, you can connect the desktops from completely different operating systems. Although you cannot drag applications off desktops, you can use one mouse and keyboard to navigate the linked desktops. And most importantly: you can share the clipboard. This way, you can copy text from a Linux application and paste it into a Windows program without a dozen steps.

Installing and configuring Synergy is much simpler than using Xdmx.

1. Install Synergy on each of the virtual desktop systems. Under Ubuntu, this is simply sudo apt-get install synergy. For other operating systems, you will need to visit They have precompiled binaries available for Windows (from Windows 95 to Windows XP and Windows ME), Linux, and Mac OS X. If you need other platforms, then you can download and compile the source code.

2. Synergy uses a central server as the primary system, and one or more clients for the shared desktops. The server is the system that has the mouse and keyboard, and this system uses a configuration file to manage the screen relationships. Unlike Xdmx, Synergy can handle non-rectangular relationships and loops where, for example, moving off the far left takes you to the far right.

o For an Ubuntu Synergy server (and Mac OS X server), the configuration file is a text file that contains hostnames and relationships. My configuration file (Listing 9-5) has three hosts: a Windows client named willy, a Mac OS X named matt, and an Ubuntu system named udo. The computers are arranged with the Windows box (willy) sitting above the Ubuntu system (udo), and the Mac (matt) is to the right of the Ubuntu system.

o For Windows systems, the Synergy server uses an application for specifying systems and relational positions (see Figure 9-7).

Image from book
Figure 9-7: The Microsoft Windows Synergy server configuration window showing the same relationships as Listing 9-5

3. Regardless of the server's platform, the configuration has three main components. First, all of the possible clients are listed. Second, the links between the displays are defined. Finally, any special options can be listed. The links form the most complicated part; they define what happens when the mouse goes off the edge of a screen. You can specify left, right, above, and below relationships. Only defined relationships exist--nothing is assumed.


Synergy links do not have to be symmetrical. For example, my system named matt may be located to the right of udo, but udo may not be left of matt. You can also create loops. For example, moving right from udo goes to matt, and continuing to the right can cycle back to udo.


Be sure to define both directions of a link. If I only define matt as being right of udo without specifying the return link (for example, udo is left of matt) then I will not be able to move the cursor back.

6. Listing 9-5: A Sample Synergy Configuration File (synergy.conf) with Three Systems


8. # The layout:

9. # willy -- is above udo

10. # udo matt -- matt is right of udo


12. section: screens

13. # List every known client by name, and any special mappings

14. udo:

15. matt:

16. meta = super # this is a Mac and uses the command/super key

17. willy:

18. end


20. section: links

21. # Define every link relationship.

22. # It does not need to by symmetrical!

23. udo:

24. right = matt

25. left = matt # make a horizontal loop

26. up = willy

27. matt:

28. left = udo

29. right = udo # make a horizontal loop

30. willy:

31. down = udo

32. end


34. section: options

35. # Make all screensavers turn on at the same time

36. screenSaverSync = true

37. end

40. Check your client configuration. Synergy supports pretty much any Windows, Mac OS X, Linux, and Unix system. For X-Windows systems, be sure to have the XTEST extension enabled. You can check this with xdpyinfo | grep XTEST. This should display the word XTEST. For Windows and Mac systems, no special configurations are needed.

41. Start the client. Each client requires two elements. First, it needs to know the host name of the server. Second, it needs a unique name that is listed in the server's configuration (in the screenssection). By default, the name is the client's host name. However, you can specify an alternate client name.

o Under Linux, Unix, and Mac OS X, the client is synergyc. The server's name is specified on the command line. You can also include an optional name for the client. Following the example above, I used this command to connect my Mac (matt) to my Ubuntu server (udo).

o synergyc --name matt udo

o Under Windows, use the Synergy client to specify the server's name and optional client's name (see Figure 9-8).

Image from book
Figure 9-8: The Microsoft Windows client configuration for Synergy

42. Start the server. On Ubuntu, Mac OS X, and other Unix and Linux systems, the command is synergys. You specify the configuration file using:

43. synergys --config synergy.conf

On Windows systems, open the Synergy application, select Share this computer's keyboard and mouse (server) and click Start.


By default, syngergys and synergyc detach from the console and run in the background. To prevent the process from becoming a daemon, use -f. For example, synergys -f –config synergy.conf.

Although the server and clients all need to be started, the order does not really matter. Clients regularly poll the server until a connection is achieved. As each system connects, the rules for the links are applied. Following the example, the cursor will be unable to move off the right side of udo until matt connects. When matt connects, the movement to the right will follow the established link.


Under Synergy, systems are either clients or a server. You do not need to run a server on the client.

When all of the clients connect to the server, you can start sharing desktops. Moving the mouse between windows allows you to set the focus for the keyboard. And most importantly: if you copy text from any desktop then you can paste it into application on any other desktop.


With Xdmx, if any system disconnects for any reason, the entire Xdmx session aborts. In contrast, Synergy allows all clients to connect and disconnect without notice. If you have systems that crash or reboot often, Synergy is definitely a good productivity solution since you can continue working while one part of the desktop is down.

Dual heads, Xdmx, and Synergy are not independent solutions. You can actually run two displays on one computer (a dual head solution) and use Xdmx to link it to more displays and use Synergy to link in desktops from other operating systems. The only limitation to your virtual desktop size becomes your physical desktop. Just how many monitors can your desk hold?


Consider installing a Synergy client in a virtual machine, such as Qemu (see Chapter 6). This enables you to cut and paste between the virtual computer and the real desktop. In many cases, this is much more convenient than transferring data across a network or through a shared partition.


Although the basic Ubuntu desktop is good for beginners, its flexibility enables you to change it from good for most things to excellent for your specific requirements. Whether you simply want a different screen resolution, display adjustment, or something more complicated, there are hacks for customizing the system to fit your needs. Using these tweaks, you can enable cool screen savers, animated backgrounds, and even massively large desktops that span multiple screens and operating systems.