I am trying to make the wallpaper changing process easier in AwesomeWM with a script which reads a path to an image and replaces the existing wallpaper with the path I gave; and then restart the WM.
My code looks like:
#!/bin/bash
if [[ $1 != "" ]] && [ -f $1 ]; then
cp $1 /usr/local/share/awesome/themes/modded/background.png
xdotool key super+ctrl+r
else
echo 'Invalid file!'
fi
Unfortunately, xdotool won't work and I don't know why, because if I issue it from a terminal (outside of a script), it will restart my window manager perfectly (super+ctrl+r restarts AwesomeWM).
I know it would be better to use awesome.restart
function from rc.lua, but I don't know how to implement or include this code inside my shell script.