[pm-utils] run script on resume

Hi There,

I am new in Linux world. Hopefully this question is not very stupid. I wrote a script to make my machine suspend for 30 secs and then wakeup automatically.

#!/bin/bash
echo 0 > /sys/class/rtc/rtc0/wakealarm
echo date '+%s' -d '+ 30 seconds' > /sys/class/rtc/rtc0/wakealarm
pm-suspend

Is there any way to run a script on resume? I tried to put a script in /etc/pm/sleep.d but the messages that the script should print didn’t show on the screen. I figured those messages were dumped into /var/log/pm-suspend.log but I need them to be displayed right after resume.

My final purpose is to run 1000 suspend/resume cycles. Is there any method to show some messages on the screen and delay for few seconds after resume and then automatically suspend for another 30 secs?

I would appreciate any suggestion. Thanks!

I’m not into scripting but maybe you can clarify a few points so that others can understand better too.

What do you mean by printing the message to the screen? Do you want it to show in the command line or some other GUI notification? If you want it to show in command line just use the echo command

echo something

For delay a few seconds between command you can use sleep.

sleep seconds

For other pm-ultil related stuff you can look here:

Pm-utils - openSUSE

Hi, Thanks for responding!

I not using pure console, not a desktop like GNOME or KDE. I need the messages printed in command line. However the messages sent by echo in scripts under /etc/pm/sleep.d don’t show on the screen, they are pushed into /var/log/pm-suspend.log directly.

I can’t make my system suspend by inserting pm-suspend in script under /etc/pm/sleep.d either. Please see an example as below:

#!/bin/bash
case $1 in
    resume)
        echo "go suspend in 3 seconds..."
        sleep 3
        pm-suspend
        ;;
    *)  echo "do nothing."
        ;;
esac

What should I do to make my machine do suspend/resume 1000 cycles?

1 thing to check is whether you’ve made the script executable?

The other questions I guess I’m unfortunately unable to answer. Sorry :slight_smile: