You are not logged in.

#1 2009-03-23 00:00:22

scooby
Member
Registered: 2009-03-19
Posts: 23

Ask for password after suspend / hibernate resume -how?

I am trying to make my netbook a bit more secure. Suspend and hibernate are working fine, but I would like to have the computer locked after I resume, having to enter my password to unlock it. How would I do this?

Offline

#2 2009-03-23 00:12:40

pointone
Wiki Admin
From: Waterloo, ON
Registered: 2008-02-21
Posts: 379

Re: Ask for password after suspend / hibernate resume -how?

What are you using to suspend/hibernate your computer? (pm-utils, gnome-power-manager, powerdevil, etc.)


M*cr*s*ft: Who needs quality when you have marketing?

Offline

#3 2009-03-23 00:25:02

scooby
Member
Registered: 2009-03-19
Posts: 23

Re: Ask for password after suspend / hibernate resume -how?

pm-utils

Offline

#4 2009-03-23 00:28:14

Gen2ly
Member
From: Sevierville, TN
Registered: 2009-03-06
Posts: 1,529
Website

Re: Ask for password after suspend / hibernate resume -how?

Unsure, what desktop environment your using.  In KDE you can set the screensaver to lock after a certain time and suspend-to-ram for a time after that.


Setting Up a Scripting Environment | Proud donor to wikipedia - link

Offline

#5 2009-03-23 00:32:07

scooby
Member
Registered: 2009-03-19
Posts: 23

Re: Ask for password after suspend / hibernate resume -how?

I'm using xfce 4.6

I don't have any screensaver installed, I will install xscreensaver and play around with it.

But I quite often use the hotkeys to suspend or hibernate, xscreensaver won't help with this.

Offline

#6 2009-03-23 04:05:59

pointone
Wiki Admin
From: Waterloo, ON
Registered: 2008-02-21
Posts: 379

Re: Ask for password after suspend / hibernate resume -how?

From the pm-utils manpage:

/etc/pm/sleep.d, /usr/lib/pm-utils/sleep.d 
    Programs in these directories (we call them hooks) are combined and executed 
    in C sort order before suspend and hibernate with as argument 'suspend' or 
    'hibernate'. Afterwards they are called in reverse order with argument 
    'resume' and 'thaw' respectively. If both directories contain a similar named 
    file, the one in /etc/pm/sleep.d will get preference. It is possible to 
    disable a hook in the distribution directory by putting a non-executable file 
    in /etc/pm/sleep.d, or by adding it to the HOOK_BLACKLIST configuration 
    variable.

From the xscreensaver-command manpage:

-lock     Tells the running xscreensaver process to lock the screen 
          immediately. This is like -activate, but forces locking as well, even if
          locking is not the default (that is, even if xscreensaver's lock resource 
          is false, and even if the lockTimeout resource is non-zero.) 

          Note that locking doesn't work unless the xscreensaver process is 
          running as you. See xscreensaver (1) for details.

Last edited by pointone (2009-03-23 04:08:24)


M*cr*s*ft: Who needs quality when you have marketing?

Offline

#7 2009-05-21 09:17:31

jarda-wien
Member
Registered: 2008-03-13
Posts: 104

Re: Ask for password after suspend / hibernate resume -how?

you could modify /etc/acpi/handler.sh to do what you need (I use this in conjunction with i3lock that works really good with acpid).

Offline

#8 2009-11-03 15:05:10

mokkurkalve
Member
From: Bergen, Norway
Registered: 2009-08-29
Posts: 60

Re: Ask for password after suspend / hibernate resume -how?

I was looking for this functionality and started with the points pointone points out. However I didn't find it immediately obvious how to do this. After some scratching of the back of my head I came up with this which works for me. I'll post it in case it be useful for others. Install as "/etc/pm/sleep.d/66screenlock" and don't forget chmod +x

#!/bin/bash
#
# 66screenlock: lock screen at suspend with xscreensaver
#

IS_ACTIVE="$( pidof /usr/bin/xscreensaver )"

 case $1 in
    hibernate)
        # not required.
        ;;
    suspend)
        # check if xscreensaver is running. if not, just skip on.
        if [ -z "$IS_ACTIVE" ]
        then :
        else
             # run the lock command as the user who owns xscreensaver process,
             # and not as root, which won't work.
             su "$( ps aux | grep xscreensaver | grep -v grep | grep $IS_ACTIVE | awk '{print $1}' )" \
             -c "/usr/bin/xscreensaver-command -lock" &
        fi
        ;;
    thaw)
        # not required.
        ;;
    resume)
        # not required.
        ;;
    *) exit $NA
        ;;
 esac

I didn't need it for hibernation as I have to enter passphrase for mounting encrypted disk at "thaw" (full reboot) anyway. I put the action at suspend rather than resume, as the latter leaves the screen exposed for around 20 seconds (time enough for someone with quick fingers to take action).


"ONLY THOSE WHO ATTEMPT THE IMPOSSIBLE WILL ACHIEVE THE ABSURD"
- Oceania Association of Autonomous Astronauts

Offline

Board footer

Powered by FluxBB