Wallpapers on desktop:

The script:

I have difficulties to find a solution to get a flexible diashow as wallpapers on the desktop. Previously I used to let “wallpapoz” work, but unfortunately, this program doesn't work with Mate or with Xfce environments.

I found this script very close to what I want to have: the diashow runs in a random and recursively way through the sub-folders. I only added the command for the Gnome3 desktop.

#!/bin/bash
function make_js {
js=$(mktemp)
cat > $js <<_EOF
var wallpaper = "$X";
var activity = activities()[0];
activity.currentConfigGroup = new Array("Wallpaper", "image");
activity.writeConfig("wallpaper", wallpaper);
activity.writeConfig("userswallpaper", wallpaper);
activity.reloadConfig();
_EOF
}
function kde_wallpaper {
make_js
qdbus org.kde.plasma-desktop /MainApplication loadScriptInInteractiveConsole $js > /dev/null
# sleep 2
xdotool search --name "Desktop Shell Scripting Console -- Plasma Desktop Shell" windowactivate key ctrl+e key ctrl+w
rm -f "$js"
dbus-send --dest=org.kde.plasma-desktop /MainApplication org.kde.plasma-desktop.reparseConfiguration
dbus-send --dest=org.freedesktop.DBus /org/freedesktop/DBus org.freedesktop.DBus.ReloadConfig
dbus-send --dest=org.kde.kwin /KWin org.kde.KWin.reloadConfig
# kbuildsycoca4 2>/dev/null && kquitapp plasma-desktop 2>/dev/null ; kstart plasma-desktop > /dev/null 2>&1
}
function xfce_wallpaper {
xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitor0/image-path -s "$X"
}
function lxde_wallpaper {
pcmanfm -w "$X"
}
function mate_wallpaper {
gsettings set org.mate.background picture-filename "$X"
}
function e17_wallpaper {
OUTPUT_DIR=~/.e/e/backgrounds
FileName="$X"
edcFile=~/tmp/SlideShow.edc
echo 'images { image: "'$FileName'" LOSSY 90; }' > $edcFile
echo 'collections {' >> $edcFile
echo 'group { name: "e/desktop/background";' >> $edcFile
echo 'data { item: "style" "4"; }' >> $edcFile
echo 'data.item: "noanimation" "1";' >> $edcFile
echo 'max: 990 742;' >> $edcFile
echo 'parts {' >> $edcFile
echo 'part { name: "bg"; mouse_events: 0;' >> $edcFile
echo 'description { state: "default" 0.0;' >> $edcFile
echo 'aspect: 1.334231806 1.334231806; aspect_preference: NONE;' >> $edcFile
echo 'image { normal: "'$FileName'"; scale_hint: STATIC; }' >> $edcFile
echo '} } } } }' >> $edcFile
edje_cc -nothreads ~/tmp/SlideShow.edc -o $OUTPUT_DIR/SlideShow.edj
sleep 2 && rm -f ~/tmp/SlideShow.edc
echo 'Enlightenment e17 SlideShow.edj file created'
enlightenment_remote -desktop-bg-del 0 0 -1 -1
enlightenment_remote -desktop-bg-add 0 0 -1 -1 $OUTPUT_DIR/SlideShow.edj;
}
function gnome3 {
#	gsettings set org.gnome.desktop.background picture-filename "$X"
gsettings set org.gnome.desktop.background picture-uri "$X"
}
function usage {
printf "%s\n%s\n\n%s\n%s\n\n%s\n\n%s" \
"Automatically set a random image as the desktop wallpaper,"\
"from the user's ~/Wallpaper directory."\
"Idea from a script by Just17. Written by Paul Arnote for PCLinuxOS."\
"Originally published in The PCLinuxOS Magazine (http://pclosmag.com), Jan. 2014 issue."\
"Works for KDE4, Xfce, LXDE, Mate, e17 and GNOME3 desktops."\
"Usage: $0 [arguments]"\
printf "\n %s\t%s" \
"-h, --help" "This help text"
printf "\n %s\t\tSetup for the %s" \
"--xfce" "XFCE4 Desktop"\
"--mate" "Mate Desktop"\
"--lxde" "LXDE Desktop"\
"--kde4" "KDE4 Desktop"\
"--e17" "Enlightenment Desktop"\
"--gnome3" "GNOME3 Desktop"
printf "\n"
}
DIR=$HOME/Wallpaper/
if [ "$1" == "--help" ] || [ "$1" == "-h" ] || [ "$1" == "" ]; then
usage
exit
fi
while true; do
X=`find $DIR -type f \( -name '*.jpg' -o -name '*.png' \) -print0 | shuf -n1 -z`
# For Xfce
if [ "$1" == "--xfce" ]; then
xfce_wallpaper
fi
# For LXDE
if [ "$1" == "--lxde" ]; then
lxde_wallpaper
fi
# For Mate
if [ "$1" == "--mate" ]; then
mate_wallpaper
fi
# For KDE4
if [ "$1" == "--kde4" ]; then
kde_wallpaper
fi
# For e17
if [ "$1" == "--e17" ]; then
e17_wallpaper
fi
# For Gnome3
if [ "$1" == "--gnome3" ]; then
gnome3
fi
#
# If using Cairo-Dock add the following line
# killall cairo-dock && sleep 0.3 && exec cairo-dock
sleep 5m
done
exit 0

Notes:

the script is done to work with a pictures folder “~/Wallpaper”. So create and fill this folder with pictures (or create a link “Wallpaper” pointing to your pictures folder) or modify the line “DIR=$HOME/Wallpaper” according to your folder.

the change of the picture is set to 5 minutes. To modify it, adapt sleep 5m according to your wishes.

For Xfce, I had to modify the “function xfce_wallpaper”. The original command line is commented. To find out which parameter sweet to your system, run

$ xfconf-query -c xfce4-desktop -l | grep "last-image$"

and look at the output, it will give you the path put insert between “backdrop” and “last-image”

the script must be run in a terminal that must stay open until the end of the session. I don't have found a solution to make it to work as a daemon. Therefore, the script doesn't run if put in the autostart scripts.

Use and integration with MATE:

create a link to the folder of the pictures

ln -s /path/to/the/folder/ Wallpaper

save this script under /path/to/the/script_diashow and give it 755 permissions

create a script /path/to/the/script_diashow-mate:

#!/bin/bash
/path/to/the/./script_diashow --mate &
killall mate-panel
exit 0;

and give it 755 permissions

under “system”–>“preferences”–>“Personal”–>“Applications at startup” set /path/to/the/script_diashow-mate to be started automatically

Use and integration with GNOME3:

For Gnome3 the way is very simple: a desktop file must only be created and via the tweaktool be selected for an autostart.

[Desktop Entry]
Encoding=UTF-8
Type=Application
Name=activation du diaporama de fonds d'écran gnome3
Comment=activation du diaporama de fonds d'écran gnome3
Comment[fr]=activation du diaporama de fonds d'écran gnome3
Exec=/the/path/to/the/script_diashow --gnome3
Icon=/usr/share/icons/oxygen/base/32x32/apps/preferences-desktop-wallpaper.png
Categories=GTK;Utility;
Name[fr_FR]=activation du diaporama de fonds d'écran gnome3

TO BE DONE: change the picture by every changing of virtual desktop:

For MATE

This is only a draft in order to get another picture every time you go on another desktop (function present by “Wallpapoz”).

Script to know the number of the active desktop: source: http://askubuntu.com/questions/272566/wmctrl-ignore-other-workspaces

Ok, I came up with my own script. At least I learned some Ubuntu bash scripting ;)

#!/bin/bash
num=`wmctrl -d | grep '\*' | cut -d' ' -f 1`
name=`wmctrl -lx | grep $1 | grep " $num " | tail -1`
host=`hostname`
out=`echo ${name##*$host}`
if [[ -n "${out}" ]]
then
`wmctrl -a "$out"`
else
$2
fi

What it does: gets the current desktop number searches current desktop for the given name (parameter one) then, depending on the result: either switches to found app or launches given app (parameter two)