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.

     sudo apt-get install xscreensaver 
  2. Disable the Gnome screensaver.

     gconftool-2 --type boolean \   -s /apps/gnome_settings_daemon/screensaver/start_screensaver false 

    Warning 

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

  3. Stop the running gnome-screensaver.

     sudo killall gnome-screensaver 
  4. 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:

     xscreensaver -no-splash 

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

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

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

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

    • 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

    • 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

    • Close all of the Menu Editor windows.

  6. 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:

     X-GNOME-Bugzilla-Bugzilla=GNOME X-GNOME-Bugzilla-Product=gnome-screensaver X-GNOME-Bugzilla-Component=general X-Ubuntu-Gettext-Domain=gnome-screensaver 
    Warning 

    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.

  7. 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.

    Note 

    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.

  8. 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.

     GL:                 fliptext -root                     \n\ GL:                 lattice -root                      \n\ 
  4. Search further down for fliptext (there will be a second line). Duplicate this line and change fliptext and FlipText to lattice and Lattice.

     *hacks.fliptext.name:            FlipText *hacks.lattice.name:             Lattice 
  5. 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!

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

  2. 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.

     nice /usr/lib/xscreensaver/lattice -root --circuits \     -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

Note 

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.

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

  3. 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.



Hacking Ubuntu
Hacking Ubuntu: Serious Hacks Mods and Customizations (ExtremeTech)
ISBN: 047010872X
EAN: 2147483647
Year: 2004
Pages: 124
Authors: Neal Krawetz

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net