When I used Fluxbox it was dead easy to have different wallpapers on each desktop, using the changeworkspace entry in the configuration. It is easy enough to use keybindings to call eg feh/nautilus/fsetbg etc to change the background (loadsa threads on this out there), but I couldn't get it work with the mouse bindings as well. And having lots of identical <xml> entries seems a bit of an inelegant hack.
I tried using 'wmctrl', and got it working after a fashion with a bash script, but then tried 'xprop' :
'xprop -root _NET_CURRENT_DESKTOP' outputs the necessary info to work with, and I've now "finished" a python script to give me the same functionality that Fluxbox did
Using 'feh' to load the images every time isn't so efficient I suppose, but I only notice the cpu load when quickly mousewheel scrolling through the desktops.
There are commandline switches to set per desktop or random wallpapers, and the time lag or time between changes.
USAGE at the beginning of the py file, which can be found at switchbg.py
NB There is minimal error trapping so use at your own risk! (And any pythonistas out there please be gentle with my noob code )
For a barebones script to set per desktop backgrounds, this is what I started with (but you will have to hard-code your specific details)....
#!/usr/bin/env python #========================================================================================= # Written by damo, feb 2012 # Use as you like :) #========================================================================================= # # Python script to set per-desktop background wallpaper for Openbox WM, without the need to # add shell commands to key and mouse bindings. # # This code uses 'xprop' to get the current desktop, then 'feh' to set the wallpaper # # You need to create a background image for each desktop, named '0.jpg','1.jpg' etc, # (although you could change the code to read eg 'png' etc) # # See 'feh' man page for options, which can be entered as fields in the subprocess.call() #========================================================================================== # USAGE python switchbg.py [options] # # [option 1] : [/path/to/wallpaper/directory/] # [option 2] : [secs] (0.25 works OK) - time to poll xprop, # # Set the initial wallpaper background in autostart, using nautilus, feh, fsetbg etc # then add this script eg... # # (feh --bg-scale /path/to/wallpaper/directory/0.jpg) & # (sleep 2s && python /path/to/switchbg.py /path/to/wallpaper/directory/ 0.2) & # #========================================================================================= import time,subprocess,sys def xprop_pipe(wp,t): '''Params are path to wallpaper directory (from args, and passed to set_bg()), and time to wait between xprop calls; Run xprop subprocess in an endless loop. It gets the current desktop as a string from stdout. The desktop number (0,1,2,3...) is the last field (cardinal), which is extracted with 'tail'; communicate() returns a tuple, so we want the first value and discard the '\n'; If the cardinal has changed, call set_bg() to change the wallpaper''' dtop = 0 # set initial desktop number (flag) xp = 'xprop -root _NET_CURRENT_DESKTOP | tail -c -2'# set xprop shell command while True: proc = subprocess.Popen(xp,stdout=subprocess.PIPE,shell=True)# subprocess: pipe to stdout curr_dtop = proc.communicate() # output is tuple, so get first val (desktop number) curr_dtop = int(curr_dtop) # current desktop cardinal = 0,1,2,3... if curr_dtop != dtop: # if cardinal has changed.... set_bg(wp,curr_dtop) # ....call set_bg func dtop = curr_dtop # set the flag to current desktop time.sleep(t) # wait for t secs (from args) def set_bg(wpath,i): '''params are the path to wallpaper directory and current desktop number; Get file path for wallpaper directory (from args); Run 'feh' shell command to set wallpaper for current desktop''' #======= set image filetype here... ========================================================== bg = wpath + str(i) + ".jpg" #======= See feh man pages for options: each should be in its own comma-separated quoted field subprocess.call(['feh','--bg-scale',bg],)# sub.call can be passed a list of strings as # commandline input - no need to escape spaces etc if __name__ == '__main__': '''commandline arguments are filepath to wallpaper directory , and polling time (secs) Pass these on''' wp = sys.argv # path to wallpaper directory t = float(sys.argv) #convert commandline string input to float(required by sleep() ) xprop_pipe(wp,t) #run xprop to get current desktop
Looking at the number of times I switch between desktops, this would become quite an overhead Do you never run applications maximized? Transparent terminals?
I've got Pentium(R) Dual-Core CPU @ 2.30GHz, and the "rest" usage is about 3%. Compositing adds another 6-8%, and the switchbg script uses <1% when it is just polling xprop. It zaps up pretty quickly if I'm doing lots of desktop switching, but I can toggle it on/off with a keybind if I'm doing something processor-intensive like a graphics render.
I like to use terminal transparency (guake dropdown terminal) and I don't find the overhead much to worry about,but YMMV
The point of the script is to emulate the Fluxbox feature I miss, and extensive searching hasn't come up with anything I like, to use in Openbox. No doubt there is a better way to do it, but I'm too noobish to have found it yet .
It's easy enough to give it a go on your system, and I wouldn't be offended if it ended up in the wastebin! (Feedback would be good though)