I
I
ixSci2011-05-28 13:18:50
linux
ixSci, 2011-05-28 13:18:50

sleep\wakeup notifications in user space Linux

Good day!

I need to know when the system goes to sleep or returns from it. Is it possible to implement this without writing a kernel module, and if so, what should I use? You need a solution that will not depend on a specific distribution.

Thanks in advance!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
fenrirgray, 2011-05-28
@ixSci

In general, whatever you use, I advise you to switch to pm-utils, this is perhaps the most efficient way. It is _very_ easy to implement what you need in it.
pm-utils uses so-called hooks.
/usr/lib/pm-utils/sleep.d << system hooks
go here /etc/pm/sleep.d << put your hooks here.
example hook from the manual:
#!/bin/bash
case $1 in
hibernate)
echo "Hey guy, we are going to suspend to disk!"
;;
suspend)
echo "Oh, this time we're doing a suspend to RAM. Cool!"
;;
thaw)
echo "oh, suspend to disk is over, we are resuming..."
;;
resume)
echo "hey, the suspend to RAM seems to be over..."
;;
*) echo "somebody is calling me totally wrong."
;;
esac
create file /etc/pm/sleep.d/66dummy then do
# chmod +x
/etc/pm/sleep.d/66dummy it must be executable.
Accordingly, you need to substitute some commands instead of echo. What - depends on what you want to get.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question