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:
sleep 5m
according to your wishes.$ 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”
ln -s /path/to/the/folder/ Wallpaper
#!/bin/bash /path/to/the/./script_diashow --mate & killall mate-panel exit 0;
and give it 755 permissions
/path/to/the/script_diashow-mate
to be started automaticallyFor 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
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)