You are not logged in.
Hey all,
For some time now my systemd sleep hook has stopped working (e.g. only killing my program and not relaunching it when waking up). Only now I have time to look into it, though, so I can't really say if any update caused this.
I had a custom sleep hook in /usr/lib/systemd/system-sleep/dwmstatus.sh, which killed my dwm-status program before going to sleep/suspend and started it again when waking up. It looked like this:
#!/bin/sh
case $1 in
pre) killall dwm-status
;;
post) dwm-status
;;
esac
exitI've been looking into it and noticed the example on the Wiki (my previous script above was a direct copy of the old example) got updated, so I updated mine accordingly. It now looks like this:
#!/bin/sh
case $1/$2 in
pre/*)
echo "Going to $2, killing dwm-status"
killall dwm-status
echo "dwm-status killed"
;;
post/*)
echo "Waking up from $2, starting dwm-status"
exec /usr/bin/dwm-status &
echo "dwm-status started"
;;
esacBut that's not working either. (The echos are just here for debugging this). I first tried using just dwm-status to start it again, but it didn't work. Then I tried the full path without result too and now with exec I still am not getting anywhere. Can someone explain to me why it's not working anymore?
Last edited by Unia (2012-12-24 13:31:46)
If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres
Offline
I just updated the only other sleep hook I have (for my powersave script) to reflect the changes to the example file found on the Wiki and that's working. That means it's not the hook itself that's failing, but rather starting an application from it. For reference, here's my other sleep hook:
#!/bin/sh
case $1/$2 in
pre/*)
/usr/bin/powersave false ;;
post/*)
if cat /sys/class/power_supply/ADP1/online | grep 0 > /dev/null 2>&1
then
/usr/bin/powersave true
else
/usr/bin/powersave false
fi
;;
esacEDIT: That powersave file is a bash script, whilst my dwm-status is a C binary. Is that what's causing this issue?
Last edited by Unia (2012-12-03 17:02:29)
If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres
Offline
Now that I have solved all the outstanding issues and integrated quite a bunch of new features into dwmst (rename of dwm-status) it's only this issue that needs to be resolved. I still can't get dwmst to launch again after suspend/hibernate.
I checked journalctl but it comes up without any errors whatsoever:
┌─[jente @ lappy ~] 20:07:40
└─■ sudo journalctl -b -u systemd-suspend
-- Logs begin at wo, 2012-10-31 12:43:25 CET, end at wo, 2012-12-19 20:08:36 CET. --
dec 19 20:08:10 lappy systemd-sleep[1174]: xset: unable to open display ""
dec 19 20:08:10 lappy systemd-sleep[1174]: Suspending system...
dec 19 20:08:19 lappy systemd-sleep[1174]: System resumed.
dec 19 20:08:19 lappy systemd-sleep[1174]: ERROR: could not open display
dec 19 20:08:19 lappy systemd-sleep[1174]: xset: unable to open display ""Or is it that xset error?
EDIT: I just removed my script from /usr/lib/systemd/system-sleep to check the output, and I still get the xset error but not the ERROR line:
dec 19 20:12:12 lappy systemd-sleep[1329]: xset: unable to open display ""
dec 19 20:12:12 lappy systemd-sleep[1329]: Suspending system...
dec 19 20:12:21 lappy systemd-sleep[1329]: System resumed.
dec 19 20:12:21 lappy systemd-sleep[1329]: xset: unable to open display ""So I guess that ERROR: could not open display is the error dwmst generates when it tries to launch it? Further investigation will have to follow, but in the meantime I'm open for pointers!
EDIT2: The ERROR line is not related to dwmst. I put some echo lines before and after killing and launching dwmst and the ERROR line appears after the echo's:
dec 19 20:16:57 lappy systemd-sleep[1443]: System resumed.
dec 19 20:16:57 lappy systemd-sleep[1443]: starting dwmst
dec 19 20:16:57 lappy systemd-sleep[1443]: started dwmst
dec 19 20:16:57 lappy systemd-sleep[1443]: ERROR: could not open display
dec 19 20:16:57 lappy systemd-sleep[1443]: xset: unable to open display ""Last edited by Unia (2012-12-19 19:18:34)
If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres
Offline
I just tried with different things with su and DISPLAY=:0 etcetera but still, it will not start after waking up. I'm really running out of ideas here.
Perhaps I could make a service file instead of a sleep hook? I'd really appreciate it if someone with more knowledge of systemd could help me out here.
If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres
Offline
Using systemd's .service files work! I guess this is a cleaner way of doing this, after all. I take it I do need two .service files: one for stopping, and one for starting?
In case anyone's curious what I have now:
[Unit]
Description=restarts dwmst after suspend
After=suspend.target
[Service]
User=jente
Type=forking
Environment=DISPLAY=:0
ExecStart=/usr/bin/dwmst
[Install]
WantedBy=suspend.targetNow to make one for killing it. Also, say I want one to kill/launch dwmst after sleep, would I need two new service files or can I combine them?
If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres
Offline