Toggling xwinwrap on and off in GNOME
xwinwrap is a cool utility that will allow you to run a screensaver or mpeg video on your desktop (root window). There are some issues with xwinwrap though. First, the command line to run it is impossibly long, and a PITA to type. Second, my screensaver of choice, electricsheep looks like hell with most wallpapers, so I like to run it without one.
There are other issues with xwinwrap, but the other issues are due to some incompatabilities between nautilus and xwinwrap. In metacity, this means that you cannot see your desktop icons.
In Beryl, this means that you will want to run the hack with a relatively high level of transparency (-o 0.11 is the parm that I use) , so desktop icons can be seen and used. This still leads to an issue with drag and drop onto the desktop, which doesn’t work, but otherwise xwinwrap works well and is stable.
Contrary to common wisdom, running xwinwrap does not suck up a significant amount of system resources. Like I said, I use electricsheep, which doesn’t create much of a cpu load, so your mileage can vary. On my system though, the combination of xwinwrap/electricsheep only takes about 6% of my cpu, and with “nice” it scales down easily. Since my cpu rarely runs over 60% (on a 3 year old AMD 3.8), the 4-5% isn’t significant.
I’ve written a script that will:
- Remove the current background and start xwinwrap, if xwinwrap is not running
- Restore the current background and kill xwinwrap, if xwinwrap is running
I use this script as a launcher on my gnome panel, so I can toggle my background between a wallpaper and xwinwrap. The script is currently hard coded to run the electricsheep screensaver hack. If you use xwinwrap, You can modify the script for whatever your preferred hack is by editing the xwinwrap_string.
#!/bin/bash
#
# xwinset.sh version 1.0
# Created: 3/23/07 by mugwump67
#
# This script will:
# turn on xwinwrap if it is off and set background option to 'none'
# turn off xwinwrap if it is on and set background option to stretched
#
# future enhancements
# Currently only switches between none and stretched
# - better to save all current background settings to config file and restore from there
# Add right-click integration with nautilus (i.e. click mpeg/hack to set)
#
#---------------------------
# outline:
#---------------------------
# If xwinwrap is running,
# shut off xwinwrap
# set background option to stretched
# If xwinwrap is off
# If current background is not "none"
# set current background to "none"
# start xwinwrap
# --------------------------
xwinwrap_string="nice -n 15 xwinwrap -ni -o 0.11 -fs -s -sp -st -b -nf -- /usr/bin/electricsheep --root 1 --nick mugwump67 --zoom 1 --max-megabytes 5000 -window-id WID"
# if xwinwrap is running,
if [ -n "$(ps | grep xwinwrap)" ]
then
# shut off xwinwrap, set backgound option to 'stretched'
killall xwinwrap
gconftool-2 --type string -s /desktop/gnome/background/picture_options stretched
else
# xwinwrap is off
# save current background option to 'none'
# set to 'none'
# start xwinwrap
gconftool-2 --type string -s /desktop/gnome/background/picture_options none
$xwinwrap_string &
fi
This is the first significant shell script that I’ve ever written, and its missing a few things because I couldn’t figure out how to do them yet (these are listed in future enhancements). Nonetheless, I hope others find it useful.



Thanks for posting this! I was looking to build this functionality…you saved me time.
question:
what is: –nick mugwump67
and: –max-megabytes 5000 -
?
Those are both parameters for the electricsheep screensaver.
-nick mugwump67 is just a nickname to track your contributions to the electric sheep rendering project. It is totally optional
-max-megabytes is the maximum amount of storage you want electricsheep to use. I’ve found that the more storage you devote, the smoother electricsheep will run. More storage = more sheep which makes it more likely that the edges that link sheep will find the sheep on either end of the edge.
I love the electricsheep screensaver, and find that it makes a great beryl desktop as long as you turn opacity down pretty far (the -o parameter). If you are using ubuntu, its in the repositories. You can check out http://www.electricsheep.org for information.
I am new to Ubuntu. What what are all the steps to get this script to work? (what file to save it as, where to save it, how do I link it to xwinwrap and electric sheep?)
1.) Save it as a text file (I used the name “xwinswap.scr” and saved it to a folder in my home directory)
2.) Right click the file in nautilus, select properties, select permissions tab and click the “allow executing file as program” box.
Assuming your paths and stuff are correct, you should now be able to call the script from a command line or double click it to execute.
From there I added a launcher to one of my GNOME panels so I could more easily launch it. I’m sure you can find a how to for this somewhere on the ubuntu forums.
You don’t need to remove and restore the background now. I have restarted the xwinwrap development and fixed this. Plus fixed a few more issues and added a couple of new features..Check it out at http://tech.shantanugoel.com/projects/linux/shantz-xwinwrap