Pages

2013-12-25

Openbox and wallpaper

This topic kinda intriqued me - after relatively easy installs in FB - and I tried out some 10 different versions of scripts I found through links here.

Basically, there is two different kind of change - one that swaps wallpapers after some amount of time, and another that swaps wallpaper together with desktop change.
Scripts are the same but timed ones - obviously - have to have time-trigger.
For this, there also are two options: crontab or Conky (howtos can be found by those same already-mentioned-links).
I definitely do not want spastic desktop, so I went for new-desktop-new-wallpaper kind. This type needs desktop/execute type combo keybind.

The result of my experiments was kinda depressing fail but also ultimately victorious: Most of found scripts didn't work (in my environments), and one that did, went with Nitrogen in Debian, but had to have Feh in Slackware. Problem probably was version of Nitrogen in Slack - an investigative hour wasted nevertheless (no, not really - I got results). But after that I didn't feel anymore like shitting around with new compile, flags, optional dependencies etc.
So it's nitrogen in Debian and Feh in Slack. The friendly scriptlet is like that:
#!/bin/bash
## very simple random wallpaper picker, uses nitrogen or feh
## From Crunchbang forum ##

# directory containing images
DIR="/home/user/picsdir/wpdir"

# select a random jpg from the directory
PIC=$(ls $DIR/*.jpg | shuf -n1)

# use nitrogen to set wallpaper
nitrogen --set-scaled $PIC
# or comment prev nitrogen and outcomment next for feh
#feh --bg-scale $PIC

# and just for terminal fun
echo "$PIC"
exit

To mention - scripts should be executable (chmod +x) and preferably on PATH.
I used two of them, smartly named as randwp1.sh and randwp2.sh, with wpdirs like wp1 and wp2, and keybinded them to W-Left and W-Right.
Two because then I can have two different sets of 'randoms' - like steampunk/fantasy or pr0n1/pr0n2.
Why not to combine action with ready binds of 'GoToDesktop'-type? As much as I tried, this combination didn't work... I was even so crazy that I made 'execute' of GoToDesktop with xdotool (to have 2 similar executes) - and that was success alright... only... then I used xdotool'ed icon on my tint panel, and tint hung totally.
Out it went and in came that, and these entries have to be created:
    <keybind key="W-Left">
    <action name="Desktop">
    <desktop>1</desktop>
    </action>
    <action name="Execute">
    <startupnotify><enabled>true</enabled>
    <name>wp1</name></startupnotify>
    <command>sh /home/user/bin/randwp1.sh</command>
    </action>
    </keybind>       
    <keybind key="W-Right">
    <action name="Desktop">
    <desktop>2</desktop>
    </action>
    <action name="Execute">
    <startupnotify><enabled>true</enabled>
    <name>wp2</name></startupnotify>
    <command>sh /home/user/bin/randwp2.sh</command>
    </action>
    </keybind>

That works for me. No hangs. And jumping back-and-forth, new wallpaper every time!
Oh, and moral: you never know what works; when messing with scripts, bash for beginners is quite must... Me, have to dig in, seems, for less waste of time, less failures.
Merry Christmas.

No comments: