2009/4/3 Axel Beckert <[email protected]>:

> Though had one funny encounter:
>
> When I suspended the EeePC while the GDM login screen was displayed
> (but noone logged in), xtrlock was running in front of GDM after
> resume. I had to enter the root password to xtrlock before I could
> login with any user at GDM again.

I think this depends pm-utils or hibernate configuration...

> Not sure what caused this. If there's a setting to lock the session
> after suspend, I surely have enabled this, but that result is slightly
> too much. :-)

IIRC it's even worse, since xtrlock is started by the program that is
responsible of the suspend, which has usually root privileges, it asks
for the root password even if you have already logged in.
I use the following script in my /etc/pm/sleep.d (used by pm-utils)

#!/bin/sh

LOCK_CMD=/usr/bin/xtrlock

[ -x $LOCK_CMD ] || exit $NA

####
#Shamelessly copied from acpi-support

getXuser() {
        user=`w -hs | awk '{ if ($3 == ":'$displaynum'" || $2 ==
":'$displaynum'" ) { print $1; exit; } }'`
        if [ x"$user" = x"" ]; then
                startx=`pgrep -n startx`
                if [ x"$startx" != x"" ]; then
                        user=`ps -o user --no-headers $startx`
                fi
        fi
        if [ x"$user" != x"" ]; then
                userhome=`getent passwd $user | cut -d: -f6`
                export XAUTHORITY=$userhome/.Xauthority
        else
                export XAUTHORITY=""
        fi
        export XUSER=$user
}

# getXconsole gets the foreground (console) X user
getXconsole() {
        console=`fgconsole`;
        displaynum=`COLUMNS="" ps ax | grep -e 'X .* vt'$console | grep -v
grep | sed -re 's!.*/X .*:([0-9]+).*!\1!' | uniq`
        if [ x"$displaynum" = x"" ]; then
            # Second attempt: perhaps there's no X started with the "vt"
argument, some users
            # prefer to start X using startx instead. As a fallback we use
that X instance.
            displaynum=`COLUMNS="" ps ax | grep -e '/usr/bin/X .*' | grep -v
grep | sed -re 's!.*/X .*:([0-9]+).*!\1!' | uniq`
        fi
        if [ x"$displaynum" != x"" ]; then
                export DISPLAY=":$displaynum"   
                getXuser
        fi
}

###
lock_screen() {
        getXconsole
        if [ x"$XUSER" != x""]; then
        su -c "$LOCK_CMD &" $XUSER
        fi
}

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

It should fail if there's no user logged in...
Cheers,

Luca

_______________________________________________
Debian-eeepc-devel mailing list
[email protected]
http://lists.alioth.debian.org/mailman/listinfo/debian-eeepc-devel

Reply via email to