From a20a1d8ec6e02baa9bc2c02713ef58a0e7215a09 Mon Sep 17 00:00:00 2001 From: Meutel Date: Tue, 2 Jun 2015 19:40:14 +0200 Subject: [PATCH] rotate wallpapers (use in cron) --- rotate_wallpapers.sh | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100755 rotate_wallpapers.sh diff --git a/rotate_wallpapers.sh b/rotate_wallpapers.sh new file mode 100755 index 0000000..d490012 --- /dev/null +++ b/rotate_wallpapers.sh @@ -0,0 +1,44 @@ +#!/bin/bash + +# repertoire de fonds d'ecran +export WALLPAPERS="$HOME/wallpapers/" + +# lxde +if [ -n "$(pgrep "^lxsession$")" ] ; then + export DISPLAY=:0 + pcmanfm -w "`find $WALLPAPERS -name '*.jpg' | shuf -n 1`" || echo "Error settings wallpaper" +fi +# gnome 2 +#gconftool -t str -s /desktop/gnome/background/picture_filename "`find $WALLPAPERS -name '*.jpg' | shuf -n 1`" +if [ -n "$(pgrep "mate-session")" ] ; then + # variable DBUS necessaire pour fonctionnement gconftool dans un processus lance hors gnome + if [ -z $DBUS_SESSION_BUS_ADDRESS ] ; then + . $HOME/.dbus/session-bus/`cat /var/lib/dbus/machine-id`-0 + export DBUS_SESSION_BUS_ADDRESS + fi + gsettings set org.mate.background picture-filename "`find $WALLPAPERS -name '*.jpg' | shuf -n 1`" || echo "Error settings wallpaper" +fi +if [ -n "$(pgrep "gnome-shell")" ] ; then + # variable DBUS necessaire pour fonctionnement gconftool dans un processus lance hors gnome + if [ -z $DBUS_SESSION_BUS_ADDRESS ] ; then + . $HOME/.dbus/session-bus/`cat /var/lib/dbus/machine-id`-0 + export DBUS_SESSION_BUS_ADDRESS + fi + # gnome 3 + export GSETTINGS_BACKEND=dconf + gsettings set org.gnome.desktop.background picture-uri "file:`find $WALLPAPERS -name '*.jpg' | shuf -n 1`" || echo "Error settings wallpaper" +fi +if [ -n "$(pgrep "awesome")" ] ; then + # pour que ça marche il faut les variables d'environnement DISPLAY et XAUTHORITY + # on les trouve dans l'env de dbus dont le pid est $DBUS_SESSION_BUS_PID + export `strings /proc/$DBUS_SESSION_BUS_PID/environ | grep -w 'XAUTHORITY\|DISPLAY'` + awsetbg -r $WALLPAPERS +fi +# xfce +if [ -n "$(pgrep "xfce4-session")" ] ; then + if [ -z $DBUS_SESSION_BUS_ADDRESS ] ; then + export DISPLAY=:0 + export $(cat /proc/$(pgrep "xfce4-session")/environ | grep -z "^DBUS_SESSION_BUS_ADDRESS=") + fi + xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitor0/image-path -s "`find $WALLPAPERS -name '*.jpg' | shuf -n 1`" +fi