I've run into an annoyance on Lubuntu 11.10, described here:
http://ubuntuforums.org/showthread.php?t=1869357
I came up with a workaround, described here:
http://ubuntuforums.org/showpost.php?p=11714061&postcount=30
My workaround involves putting a script in /etc/pm/sleep.d to run on resume.
However, the workaround only seems to work when I suspend using pm-suspend. When I suspend by closing my laptop's lid, my workaround fails. How can I get a script to run when I resume from sleep, and that sleep was triggered by closing the lid?
Details:
I suspect this failure might be because scripts in /etc/pm/sleep.d are not getting executed when I suspend by closing the lid. Suspending with pm-suspend, then resuming by closing/opening the lid works fine. I believe Lubuntu uses xfce4-power-manager to handle suspension due to lid closing, perhaps this is important? I prefer to suspend by closing my laptop's lid, rather than typing a terminal command.
EDIT:
By inspecting /var/log/pm-suspend.log as suggested by andrewsomething, we can see that the reset_panel script runs on every resume, it just fails on resumes that follow lid-triggered suspends. I followed his further suggestion that I add an export statement to my script, and things are working now. The script triggers too early in the wakeup process, but that's not hard to fix. The current version of the script:
#!/bin/bash
case "$1" in
suspend|hibernate)
#do nothing
;;
resume|thaw)
export DISPLAY=:0 #What does this do? Are there side effects?
sleep 5 && lxpanelctl restart & #Delayed so the battery icon can finish wrecking shop.
;;
*)
exit 1
;;
esac
exit 0
andrewsomething, if you want to post an answer, I'll accept. Thanks for the help!
/var/log/pm-suspend.log
or/var/log/pm-suspend.log.1
? – andrewsomething Feb 25 '12 at 01:28/etc/pm/sleep.d/restore_brightness resume suspend: success. Running hook /etc/pm/sleep.d/reset_panel resume suspend: Cant connect to display: (null)
– Andrew Feb 25 '12 at 02:40sudo pm-suspend
from the terminal. You think thesudo
or the terminal make important differences? – Andrew Feb 25 '12 at 02:46export DISPLAY=:0
to your script. – andrewsomething Feb 25 '12 at 03:31