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.
If you want to set the wallpaper, better just use feh or another external wallpaper setter. Also, you don't have to (and should not) restart Awesome to set the wallpaper. The "awesome way" is
echo 'require("gears.wallpaper").maximized("'${1}'")' | awesome-client
Where ${1} is the path. But again, feh
or a similar tool is better for this job. Until version 3.4, Awesome even called that command itself until a native wallpaper support was added.