Setting script to be executed before and after
(suspend and resume) in hibernate on Debian Squeeze
I'm using a script called
/usr/sbin/restart_trackpoint.sh to
restart periodically my R61 Thinkpad trackpoint device.
Without this script my trackpoint often hanges and as a side effect
causes my whole Gnome desktop to disfunction.
This happens every now and then and it's deadly irritating
...
I've noticed that the problem where my thinkpad trackpoint breaks
happens most often after my notebook
system resume/suspend
hibernate functions are in use
I do use the
linux hibernate via
/usr/sbin/hibernate
almost every time I decide to stop my laptop and therefore the
hibernate function is something I do use on daily basis.
When suddenly as a consequence of the hibernations the trackpoint
problems appeared, I've realized that I need a way to place my
/usr/sbin/restart_trackpoint.sh script to be executed
everytime my system comes from a previous hibernate (e.g.
restores).
The documentation of hibernate was not too much clear to me but
after some experiments and thanks to something I read on
help.ubuntu.com I finally found how to achieve my desired
task.
For other people which might have a requirement to set a script to
be issued on
hibernate suspend or hibernate restore here is
how it can be done on Debian Squeeze and in testing/untsable
1. Create new file in
/usr/lib/pm-utils/sleep.d/100resume
debian:~# vim
/usr/lib/pm-utils/sleep.d/100resume
2.Place in it for instance the script:
#!/bin/sh
##
## 100resume
##
case $1 in
suspend)
## COMMANDS THAT YOU WISH TO RUN BEFORE SUSPEND
#COMMAND1
echo "Suspeding ...";
;;
resume)
## COMMANDS THAT YOU WISH TO RUN AFTER RESUME
/usr/sbin/restart_trackpoint.sh
;;
hibernate)
## COMMANDS THAT YOU WISH TO RUN BEFORE HIBERNATE
#COMMAND3
echo "Hibernating ...";
;;
thaw)
## COMMANDS THAT YOU WISH TO RUN AFTER RESUME FROM SUSPEND TO
DISK
#COMMAND4
;;
esac
Now you might need to modify the above script's each of the
sections to determine what kind of commands you would like to
execute before
resume) and hibernate)
When you're done with the file,
3.make it executable
debian:~# chmod +x
/usr/lib/pm-utils/sleep.d/100resume
4. Test if your script works with hibernate's resume and
restore
debian:~# /usr/sbin/hibernate
After the hibernate completes, launch the power on pc button and
checkout if the system instructions defined in
100resume are
being applied.