Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I need to lock the screen when my computer is waken up from memory suspend,

So I tried to put the following script to /usr/lib/pm-utils/sleep.d and /etc/pm/sleep.d, but it never got executed,

#!/bin/sh

case "$1" in
    hibernate|suspend)
        ;;
    thaw|resume)
        vlock -ans
        ;;
    *) exit $NA
        ;;
esac

P.S It's pm-suspend not pm-hibernate.

EDIT

Tried systemd service as well, no luck:

# /etc/systemd/system/resume@.service
[Unit]
Description=User resume actions
After=suspend.target

[Service]
User=root
Type=simple
ExecStart=vlock -ans

[Install]
WantedBy=suspend.target

And I called systemctl enable resume@.service too, vlock wasn't called still.

share|improve this question
3  
Are you sure it will not get executed? Can you try to just log it or do something like echo executed script >> /tmp/resume –  Ulrich Dangel Dec 26 '12 at 13:50

3 Answers 3

Did you set the permissions and owner as described in the wiki?

Make sure the script is executable (chmod 755) and owned by root:root

share|improve this answer

You're trying to create your own hook, right? I'm reading the Arch Linux documentation on pm-utils (link below) and I'd check these things first:

  • script name (start with two digits, obeying the scheme in the docs)
  • script location: /etc/pm/sleep.d is the right place
  • script modes: chmod +x /etc/pm/sleep.d/66scriptname

If you're sure you've got all those right, then consider the script itself.

Here's a link to the docs I'm reading about this: https://wiki.archlinux.org/index.php/pm-utils#Creating_your_own_hooks

Your script isn't quite like the one they show there. You invoke /bin/sh instead of /bin/bash. You use double-qoutes around $1 and they don't. You combine options and they don't. All of which should be OK, right? Except maybe the sh versus bash.

How about putting some logger or echo statements in there for debugging and then check the logs to see if you script is getting started. And if it is, how far it's getting.

share|improve this answer
    
Does systemd work with pm-utils? I'm not sure about that ;-) –  warl0ck Nov 6 '13 at 0:09

AFAIK ExecStart wants a full path to the executable.

Try with ExecStart=/usr/bin/vlock -ans in your /etc/systemd/system/resume@.service

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.