XFCE Workspace Background, redux

As I was writing yesterday, I realized that my code was sloppy, particular to my needs, and nearly unusable. I refactored the script to be more intuitive. When called, the script switches to the desktop specified by the first argument (it's zero-indexed), drops in a new background image list, and updates the background. The background changes a few hundred ms after switching, but it's good enough for me.

Here are directions for using it:

Script Setup:

  1. Download the script, and save it as switch.sh. Make sure it's executable.
  2. Install wmctrl from your distributions' repositories.
  3. Create an image list for each of your desktops. You can use XFCE to generate them (in Desktop settings, create an image list, then save it), or you can create it by hand (it's a text file whose first line is "# xfce backdrop list", followed by full paths to images, one per line)
  4. Save one image list for each of your desktops, and remember their locations.
  5. Edit switch.sh, and insert your image lists where prompted. The contents of the CURRENT variable should be the background list XFCE is set to use.

XFCE Setup:

  1. In the XFCE settings manager, go to Window Manager, click the keyboard tab, and disable the shortcuts for switching workspaces.
  2. Go back to the settings manager, and go into Keyboard settings, and click the application shortcuts tab.
  3. Create a shortcut for each of your workspaces. The first shortcut should run switch.sh 0 on the keyboard shortcut Ctrl+F1.
  4. Add a shortcut for each workspace.
  5. Make sure that XFCE is drawing images from the link set by CURRENT.

Here's the script!