changing the cinnamon wallpaper from udev rule

31 Views Asked by At

I want to have a script change my wallpaper when my monitor is plugged into the system. Creating the udev rule wasn´t a problem and the .sh script works fine, when executing by myself.

My udev rule: 95-monitor-hotplug.rules

ACTION=="change", SUBSYSTEM=="drm", ENV{DISPLAY}=":0", ENV{XAUTHORITY}="/home/arthur/.Xauthority", RUN+="/home/arthur/.scripts/changeback.sh"

My shell script: changeback.sh

#!/bin/sh
#
# set the wallpaper
#
# all wallpapers in $BASE

export DISPLAY=:0
export XAUHORITY=/home/arthur/.Xauthority
BASE="file:///home/arthur/.wallpapers/"

echo "$(date) - wallpaper change started!" >> /home/arthur/.scripts/logs/wallpaperlog

resol=`xrandr | grep 'current' | awk '{print $8 $9 $10 }'`

if [ ${resol} = '3840x1762,' ];
then
        new="${BASE}HomeBack.png"
        options='spanned'
else
        new="${BASE}OneScreenBack.png"
        options='zoom'
fi
                                                                                                                                                                               
gsettings set org.cinnamon.desktop.background picture-uri \'${new}\'
gsettings set org.cinnamon.desktop.background picture-options ${options}                                                                                                                                                                      
                                                                                                                                                                                                                                              
echo "$(date) - wallpaper changed" >> /home/arthur/.scripts/logs/wallpaperlog    

The main issue is, that the udev rule starts the script but the wallpaper simply doens´t change. I have implemented a logger and the script is indeed called correctly (log entries are created). Sadly I don´t know, why this rather odd behaviour is occuring.

0

There are 0 best solutions below