You are not logged in.
I've got a couple of timers which rotate my wallpapers and run daily backups and these seem to just stop working after I hibernate my laptop (so every night) - they aren't even displayed by list-timers --all. I've googled a fair bit and not found anything of any use. Below are the details:
[shw@omaha ~]$ systemctl status wallpaper-rotater.timer --user
● wallpaper-rotater.timer - Rotates wallpaper every 15 minutes
Loaded: loaded (/home/shw/.config/systemd/user/wallpaper-rotater.timer; enabled; vendor preset: enabled)
Active: inactive (dead)[shw@omaha ~]$ cat /home/shw/.config/systemd/user/wallpaper-rotater.timer
[Unit]
Description=Rotates wallpaper every 15 minutes
[Timer]
OnCalendar=*:0/15
Unit=wallpaper-rotater.service
[Install]
WantedBy=multi-user.target[shw@omaha ~]$ cat /home/shw/.config/systemd/user/wallpaper-rotater.service
[Unit]
Description=Regular wallpaper rotation
DefaultDependencies=no
[Service]
ExecStart=/home/shw/.scripts/set-wallpaper.sh
Type=oneshot
RemainAfterExit=noAny suggestions as to what I might have missed, or if I have conflicting flags set?
Last edited by analbeard (2016-04-06 11:01:30)
Offline
You put your timer/service files in $HOME/.config/systemd/user, so they are managed by the systemd user manager, not the system manager.
How do you start the timer?
systemd user units cannot have a dependency on multi-user.target which is a target under the system manager control.
Instead make them depend on 'default.target', or for a timer on 'timers.target'.
Could you post the script too?
Because 'Type=oneshot' causes the unit to wait for the end of the script.
Why did you choose 'DefaultDependencies=no' and 'RemainAfterExit=no' ?
Finally, you should choose to stop the timer while in hibernation state; you don't need to change the wallpaper then.
Last edited by berbae (2016-04-04 14:52:59)
Offline
You put your timer/service files in $HOME/.config/systemd/user, so they are managed by the systemd user manager, not the system manager.
How do you start the timer?
I have a systemd --user process running and I would start it with systemctl start wallpaper-rotator.timer --user
systemd user units cannot have a dependency on multi-user.target which is a target under the system manager control.
Instead make them depend on 'default.target', or for a timer on 'timers.target'.
Right, that makes sense - I've now corrected that (it may well be the ultimate cause of the problem).
Could you post the script too?
Because 'Type=oneshot' causes the unit to wait for the end of the script.
Sure, I've done this below for the sake of tidiness. oneshot shouldn't be a problem as the script usually takes milliseconds to run.
Why did you choose 'DefaultDependencies=no' and 'RemainAfterExit=no' ?
Honestly, I'm not sure - it's been quite a while since I wrote this and it worked ok for a while. I've just had a thorough read of the man pages and I suspect they should be removed.
Finally, you should choose to stop the timer while in hibernation state; you don't need to change the wallpaper then.
How would you achieve this?
#!/bin/bash
MONCOUNT=`xrandr | grep connected | grep -v disconnected | wc -l`
BG_DIR=$HOME/Dropbox/Wallpaper/1920x1200
# ensure array is empty
unset files
i=0
while read line ; do files[ $i ]="$line" ; (( i++ )) ; done < <(find $BG_DIR/ -type f \( -iname \*.jpg -o -iname \*.png \) | shuf -n $MONCOUNT)
if [ $MONCOUNT == "1" ]; then
feh --bg-fill ${files[0]} /dev/null 2>&1
elif [ $MONCOUNT == "2" ]; then
feh --bg-fill ${files[0]} feh --bg-fill ${files[1]} /dev/null 2>&1
elif [ $MONCOUNT == "3" ]; then
feh --bg-fill ${files[0]} feh --bg-fill ${files[1]} feh --bg-fill ${files[2]} > /dev/null 2>&1
fi
# clean up afer execution
unset files
exitOffline
It seems you forgot to enable the timer.
After changing the WantedBy parameter of the timer unit to 'WantedBy=timers.target' run as user:
$ systemctl --user enable wallpaper-rotater.timer
So your timer will automatically be started at user login.
Concerning the point about stopping the timer before hibernation, that might not be necessary, because the system is powered off in this state, and nothing keeps running then.
But if the timer doesn't restart after resume, you will need to stop/restart it using systemd sleep hooks:
see https://wiki.archlinux.org/index.php/Po … leep_hooks
If you have difficulties with this, post again here for help.
Last edited by berbae (2016-04-06 08:56:53)
Offline
It seems you forgot to enable the timer.
After changing the WantedBy parameter of the timer unit to 'WantedBy=timers.target' run as user:$ systemctl --user enable wallpaper-rotater.timer
So your timer will automatically be started at user login.
Sorry, I meant enable rather than start.
Concerning the point about stopping the timer before hibernation, that might not be necessary, because the system is powered off in this state, and nothing keeps running then.
But if the timer doesn't restart after resume, you will need to stop/restart it using systemd sleep hooks:
see https://wiki.archlinux.org/index.php/Po … leep_hooksIf you have difficulties with this, post again here for help.
Both timers (wallpaper and backup) seem to be running fine since the machine was hibernated overnight so thanks very much for your help!
Last edited by analbeard (2016-04-06 11:01:09)
Offline