Adding a gif-file as a screensaver to xscreensaver

If you want to have a gif as a screensaver there are probably a lot of solutions. For example this

Man Bowl

loop as a screensaver could easily be created as a screensaver with xscreensaver and gifview [part of gifsicle (ArchLinux)]. In the ~/.xscreensaver file is a section with “programs:”, in that one you can add programs, which can write into the root window and understands “virtual root” windows.

Now that part of xscreensaver looks like:

textURL:        http://twitter.com/statuses/public_timeline.atom

programs:                                                                     \
-                               maze -root                                  \n\
- GL:                           superquadrics -root                         \n\
                                sh /path/to/script/screensaver.sh           \n\
-                               attraction -root                            \n\

The script looks like:

#!/bin/sh

GIF=/home/knorke/.screensaver/screensaver$XSCREENSAVER_WINDOW.gif
OLDGIFS=/home/knorke/.screensaver/screensaver*.gif
GIFFILES=(/home/knorke/.screensaver/images/*.gif)

rm $OLDGIFS
ln -sf "${GIFFILES[RANDOM % ${#GIFFILES[@]}]}" $GIF
gifview --animate --min-delay 5 --window $XSCREENSAVER_WINDOW $GIF

This will set a symbolic link to a specific file of a set of gif images for each display. We get a random gif for the display in the line which stats with ‘ln -sf’. But there is still a lot of improvement to do, e.g. displaying them centralized and not repeated and so on. The minimum delay in gifview gives the time of 1/100s between the display of each frame, this helped me with one gif, which was otherwise running too fast.

If you now open the configuration panel of xscreensaver with

# xscreensaver-demo

You should see in the small preview window of Sh the gif, which is mentioned in the configuration file. The preview button should show you, how it would be too see your endless loop in action.

sources:

man 1 gifview
man 1 xscreensaver
https://bbs.archlinux.org/viewtopic.php?id=73902
http://stackoverflow.com/questions/701505/best-way-to-choose-a-random-file-from-a-directory-in-a-shell-script

~ by frankooh on 2013-08-01T12:35:02+01:00.

One Response to “Adding a gif-file as a screensaver to xscreensaver”

  1. Thank You for this, Using this,
    I have made a screensaver that downloads https://radar.weather.gov/Conus/index_loop.php
    into /tmp (im on arch and this is a tmpfs)
    and displays it.

    love it because im a snowboarder.

Leave a comment