execute program on wake/ kill program on suspend

Hello,
I have problems to get it work. i have tried to use pm-utils, but it does nothing.

What is need is to kill application, when pc is going into suspend to ram and run that application again on wake. It’s a graphical application.

What i should do ? Thank you very much !

On 2011-04-15 17:06, wh1sp3r wrote:
>
> Hello,
> I have problems to get it work. i have tried to use pm-utils, but it
> does nothing.
>
> What is need is to kill application, when pc is going into suspend to
> ram and run that application again on wake. It’s a graphical
> application.

You have to put script in /etc/pm/sleep.d/:

Code:

#!/bin/bash

… /usr/lib/pm-utils/functions

case “$1” in
hibernate)
/bin/logger -t pm-utils -p syslog.warn “— Hibernating…”
;;
suspend)
/bin/logger -t pm-utils -p syslog.warn “— Suspending…”
;;
thaw)
/bin/logger -t pm-utils -p syslog.warn “— Thawing…”
;;
resume)
/bin/logger -t pm-utils -p syslog.warn “— Resuming…”
;;
*)
;;
esac

exit $?

Insert your coding in there - how you stop a graphical application is your
problem - and start it again is a double problem.


Cheers / Saludos,

Carlos E. R.
(from 11.2 x86_64 “Emerald” at Telcontar)

tried to do the above to cure internal mic fail on resume. killing alsasound before sleep and restarting on resume works.
Here’s my code of /etc/pm/sleep.d/sound

#!/bin/bash

case “$1” in
suspend)
/etc/init.d/alsasound stop
;;
resume)
/etc/init.d/alsasound start
;;
*)
;;
esac

exit $?

What am I doing wrong? Wiki for 12.1pm-utils is not available so I’m not sure of new syntax.

On 2012-01-02 20:27, kristyon wrote:
>
> tried to do the above to cure internal mic fail on resume. killing
> alsasound before sleep and restarting on resume works.
> Here’s my code of /etc/pm/sleep.d/sound
>
> #!/bin/bash
>
> case “$1” in
> suspend)
> /etc/init.d/alsasound stop
> ;;
> resume)
> /etc/init.d/alsasound start
> ;;
> *)
> ;;
> esac
>
> exit $?
>
> What am I doing wrong? Wiki for 12.1pm-utils is not available so I’m
> not sure of new syntax.

This is not clear. You first say it works, later you say “What am I doing
wrong?” Please explain.


Cheers / Saludos,

Carlos E. R.
(from 11.4 x86_64 “Celadon” at Telcontar)

Is there a way to execute a program on resuming the computer without superuser rights? (as changing /etc/… requires these superuser rights.)

The scripts to be executed only need user rights.

On 2015-01-12 09:36, Konfekt wrote:

Eum… Why do you hang your question at the end of a three years old
question, even if somewhat related? :-?

> Is there a way to execute a program on resuming the computer without
> superuser rights? (as changing /etc/… requires these superuser
> rights.)
>
> The scripts to be executed only need user rights.

It will depend on whether your desktop of choice implements suitable
hooks. I’m not aware of their existence.


Cheers / Saludos,

Carlos E. R.
(from 13.1 x86_64 “Bottle” at Telcontar)

I am using OpenSuse 13.2 with KDE desktop.