The Temple of Fu

code, systems and games

Slackware – Fluxbox (random background slideshow)

with one comment

I have used Fluxbox in the past and Loved It! At some point I decided to play with XFCE and meh, it’s ok {grin} I made the switch back recently to FB. As anyone who has used FB before it is a pretty barren environment to begin with but I did find a style I liked so I applied it but I was missing a nice background. You can set a background using the following (note some sites will say to use the backgrounds folder under ./fluxbox but I don’t, I am a rebel like that). Make sure that any images you put under this directory adhere to Unix file naming conventions (no spaces etc), I also do not do scaling on these images so what you put under there is what will be displayed, so get wallpapers that fit your resolution.

$fbsetbg -l path_to_image

I thought cool but I want rotating images every X minutes. I found a bash script on the web that I modified a little.


#!/bin/bash
# Reads a given directory and set a random
# wallpaper using the images on that dir.

WALLPAPERDIR="$HOME/wallpapers"

if [[ -d "${WALLPAPERDIR}" ]]
then
while(true)
do
files=$(ls "${WALLPAPERDIR}")
file_matrix=($files)
num_files=${#file_matrix[*]}
#feh --bg-scale
fbsetbg -c "${WALLPAPERDIR}/${file_matrix[$((RANDOM%num_files))]}"
sleep 10m
#sleep 5s
done
fi

exit 0

I left the original call to feh in there but commented it out, it is not part of the standard Slackware install and I could not find a package that I wanted to use, and really didn’t feel like making my own at this time. fbsetbg is part of the core install so that is good enough for me for right now, there was however one tiny little thing. After creating the script, allowing execution of it and then running it, I would receive a weird warning.

$chmod +x random_wallpaper_slideshow.sh
$~/chmod +x random_wallpaper_slideshow.sh
wmsetbg warning: could not open domain file /home/fu/GNUstep/Defaults/WindowMaker

Simply typing the following command in a terminal setup the needed directories so that the warning went away.
$ wmsetbg

Now I can run the following and get a nice wallpaper slideshow after logging in.
$ ~/scripts/random_wallpaper_slideshow.sh &

Instead of running the above command I opted for editing the following file.
~/.fluxbox/startup

My fluxbox startup file now looks like the following, every time I startx my script will run and provide me a nice slideshow.

#!/bin/sh
#
# fluxbox startup-script:
#
# Lines starting with a '#' are ignored.

# Change your keymap:
xmodmap "/home/fu/.Xmodmap"

# Applications you want to run with fluxbox.
# MAKE SURE THAT APPS THAT KEEP RUNNING HAVE AN ''&'' AT THE END.
#
# unclutter -idle 2 &
# wmnd &
# wmsmixer -w &
# idesk &

# Start DBUS session bus:
if [ -z "$DBUS_SESSION_BUS_ADDRESS" ]; then
eval $(dbus-launch --sh-syntax --exit-with-session)
fi

# And last but not least we start fluxbox.
# Because it is the last app you have to run it with ''exec'' before it.

fluxbox &
fbpid=$1
# or if you want to keep a log:
# exec fluxbox -log "/home/fu/.fluxbox/log"

sleep 1
{
. ~/scripts/random_wallpaper_slideshow.sh &
} &

wait $fbpid

Hope this helps!

Advertisements

Written by lordfu

March 9, 2013 at 8:44 pm

Posted in Linux, Slackware

One Response

Subscribe to comments with RSS.

  1. A different way to change x. Via “user styles”: clones itself and the style just change the wallpaper. [google translate]

    manuchelo

    March 10, 2013 at 1:35 pm


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: