You are not logged in.

#1 2010-05-11 21:45:49

count-corrupt
Member
From: Germany
Registered: 2009-02-01
Posts: 111

[SOLVED] lock screen on when suspending/hibernating

Hi,

I'm trying to make my x200s to greet me with a login prompt after resuming from suspend since it's BIOS password-on-resume doesn't work.
I'm starting pm-suspend through acpid hook when my suspend button is pressed. I also have a pm hook that issues xlock upon hibernate.

When I run pm-suspend from a terminal as root everything works as expected. When I hit the button however, the system suspends, the log shows that it's parsing the hooks but xlock is not started.

/var/log/pm-suspend.log:

Tue May 11 23:38:41 CEST 2010: Running hooks for suspend.
/etc/pm/sleep.d/00_lock suspend suspend:success.

/etc/pm/sleep.d/00_lock:

#!/bin/bash
case $1 in
    hibernate)
                sudo -u corrupt -b xlock -mode matrix
        ;;
    suspend)
                sudo -u corrupt -b xlock -mode matrix
        ;;
    thaw)
        ;;
    resume)
        ;;
    *) 
        ;;
esac

/etc/acpi/handler.sh:

<snip>

case "$1" in

<snip>

    ibm/hotkey)
        case "$4" in
            00001004)
                pm-suspend
                ;;
                esac
            ;;
<snip>

esac

Any help is appreciated

Last edited by count-corrupt (2010-07-30 19:21:49)


Desktop: Arch64/Gentoo | XMonad | E6600@2x3Ghz | 4G RAM | Geforce 9800 GTX+ | 2TB 4-Disk Raid 5
Laptop: Arch64 | XMonad | Lenovo X200s with AFFS display mod | L9400@2x1.86Ghz | 4G RAM | 945G

Offline

#2 2010-05-11 22:45:04

demian
Member
From: Frankfurt, Germany
Registered: 2009-05-06
Posts: 708

Re: [SOLVED] lock screen on when suspending/hibernating

You don't need sudo in that script. Actually you don't need that seperate script at all.
I just use
pm-suspend &
slock
in my handler for fn+f4.


no place like /home
github

Offline

#3 2010-05-12 06:36:56

count-corrupt
Member
From: Germany
Registered: 2009-02-01
Posts: 111

Re: [SOLVED] lock screen on when suspending/hibernating

demian wrote:

You don't need sudo in that script. Actually you don't need that seperate script at all.
I just use
pm-suspend &
slock
in my handler for fn+f4.

Actually I do need sudo to call xlock as my user. Otherwise it will need the root password to unlock.
I used your solution for a few days and didn't like it. When resuming the screen would show the WM for a few seconds before xlock takes over which is annoying to say the least. I really want the first thing to see when resuming to be the password prompt.


Desktop: Arch64/Gentoo | XMonad | E6600@2x3Ghz | 4G RAM | Geforce 9800 GTX+ | 2TB 4-Disk Raid 5
Laptop: Arch64 | XMonad | Lenovo X200s with AFFS display mod | L9400@2x1.86Ghz | 4G RAM | 945G

Offline

#4 2010-05-12 06:58:35

demian
Member
From: Frankfurt, Germany
Registered: 2009-05-06
Posts: 708

Re: [SOLVED] lock screen on when suspending/hibernating

You need sudo if you call xlock from terminal but aren't pm and acpid hooks run with root permissions anyway?

As for my solution: did you use the ampersand too? Because without it there is indeed a delay of a few seconds. I have that delay with xlock too though. Using the ampersand fixes that delay.

I have to correct myself though. I noticed that a simple "slock" didn't work anymore. So now I'm using su -c slock USER in my hooks now.

Regards,
demian

P.S.: On my X200s, both

        *1004) # FN+F4
            logger "acpid: Fn+F4 pressed, suspending"
        pm-suspend &
            su -c slock USER
        ;;

and

        *1004) # FN+F4
            logger "acpid: Fn+F4 pressed, suspending"
        pm-suspend &
            su -c xlock USER
        ;;

work.

Last edited by demian (2010-05-12 07:17:33)


no place like /home
github

Offline

#5 2010-05-12 08:49:16

count-corrupt
Member
From: Germany
Registered: 2009-02-01
Posts: 111

Re: [SOLVED] lock screen on when suspending/hibernating

Yeah, I did notice the ampersand. Thanks for trying to help btw.
I did a lot of testing there too but nothing works. Not even the

pm-suspend &
su -c xlock USER

solution.
I wonder if I might have a setup error somewhere if this works for you on the same laptop. Anyway this is extremely annoying. I'm more afraid to have the laptop lying somewhere suspended than shutdown or even running and locked (not counting cold-boot of course).
Do you remember tweaking your setup somewhere to get this running?


Desktop: Arch64/Gentoo | XMonad | E6600@2x3Ghz | 4G RAM | Geforce 9800 GTX+ | 2TB 4-Disk Raid 5
Laptop: Arch64 | XMonad | Lenovo X200s with AFFS display mod | L9400@2x1.86Ghz | 4G RAM | 945G

Offline

#6 2010-05-12 11:59:05

demian
Member
From: Frankfurt, Germany
Registered: 2009-05-06
Posts: 708

Re: [SOLVED] lock screen on when suspending/hibernating

No, my setup is pretty plain when it comes to acpi.

 > lr /etc/acpi
/etc/acpi:
actions/  events/  handler.sh*

/etc/acpi/actions:

/etc/acpi/events:
anything

Why don't you try my handler.sh and move all of your scripts to a different location while testing?
handler.sh

#!/bin/sh
# /etc/acpi/handler.sh

# fix acpid
PID=$(pgrep dbus-launch)
USER=$(ps -o user --no-headers $PID)
USERHOME=$(getent passwd $USER | cut -d: -f6)
export XAUTHORITY="$USERHOME/.Xauthority"
for x in /tmp/.X11-unix/*; do
    displaynum=`echo $x | sed s#/tmp/.X11-unix/X##`
    if [ x"$XAUTHORITY" != x"" ]; then
        export DISPLAY=":$displaynum"
    fi
done

# PATH
export PATH=$USERHOME/.bin:/bin:/usr/bin:/sbin:/usr/sbin

# VARIABLES
#MINSPEED=$(cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_min_freq)
#MAXSPEED=$(cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq)
#SETSPEED="/sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed"
DOCKED=$(cat /sys/devices/platform/dock.0/docked)
WLAN=$(ifconfig | grep wlan0 | wc -l)
PROFILE=$(echo $(ls /var/run/network/profiles))
BT=/sys/devices/platform/thinkpad_acpi/bluetooth_enable
BTCAT=$(cat $BT)
LVDS1=$(xrandr | grep LVDS1)
HDMI2=$(xrandr | grep HDMI2)
VGA1=$(xrandr | grep VGA1)

set $*

case "$1" in
    button/power)
        case "$2" in
            PWRF)  logger "acpid: power button pressed: $2"
           shutdown -h now;;
            *)     logger "acpid: action $2 undefined";;
        esac;;
    button/sleep)
        case "$2" in
        SLPB)  logger "acpid: sleep button pressed: $2";;
            *)     logger "acpid: action $2 undefined";;
        esac;;
    ac_adapter)
        case "$2" in
            AC)
                case "$4" in
                    00000000)   logger "acpid: running on bat"
                #echo -n $MINSPEED >$SETSPEED
                echo 4 > /sys/class/backlight/acpi_video0/brightness
                cpufreq-set -g ondemand;;
                    00000001)   logger "acpid: running on ac"
                #echo -n $MAXSPEED >$SETSPEED
                echo 8 > /sys/class/backlight/acpi_video0/brightness
                cpufreq-set -g performance;;
                esac;;
            *)  logger "acpid: action $2 undefined";;
        esac;;
    battery)
        case "$2" in
            BAT0)
                case "$4" in
                    00000000)   logger "acpid: battery offline";;
                    00000001)   logger "acpid: battery online"
                ethtool -s eth0 wol d
                echo 60 > /sys/devices/platform/smapi/BAT0/start_charge_thresh
                echo 90 > /sys/devices/platform/smapi/BAT0/stop_charge_thresh;;
                esac;;
            CPU0);;
            *)  logger "acpid: action $2 undefined";;
        esac;;
    button/lid)
    if [ $DOCKED = 0 ];then
            logger "acpid: lid closed, suspending"
            pm-suspend &
        su -c slock $USER
    fi;;
    ibm/hotkey)
    case "$4" in
        *1002) # FN+F2
          logger "acpid: Fn+F2 pressed, locking screen"
          su -c slock $USER;;
        *1003) # FN+F3
               logger "acpid: Fn+F3 pressed, turning off display"
               xset dpms force off;;
        *1004) # FN+F4
           logger "acpid: Fn+F4 pressed, suspending"
           pm-suspend &
               su -c slock $USER;;
        *1005) # FN+F5
           logger "acpid: Fn+F5 pressed, toggling wlan"
           case "$WLAN" in
            1)    ifconfig wlan0 down;;
            0)    ifconfig wlan0 up;;
           esac;;
        *1006) # FN+F6
           logger "acpid: Fn+F6 pressed, toggling bluetooth"
           case "$BTCAT" in
            1)    echo 0 > $BT;;
            0)    echo 1 > $BT;;
           esac;;
        *1007) # FN+F7
               logger "acpid: Fn+F7 pressed, toggling display"
           case "$LVDS1" in
               "LVDS1 connected"*)
                   case "$HDMI2" in
                   "HDMI2 connected 1"*) xrandr --output HDMI2 --off
                                xrandr --output LVDS1 --auto;;
                   "HDMI2 connected ("*) xrandr --output LVDS1 --off
                             xrandr --output HDMI2 --auto
                             if [ `echo $VGA1 | grep 'VGA1 connected' | wc -l` = 1 ];then
                                 xrandr --output VGA1 --right-of HDMI2
                             fi;;
               esac
               case "$VGA1" in
                   "VGA1 connected 1"*)  xrandr --output VGA1 --off
                             xrandr --output LVDS1 --auto;;
                   "VGA1 connected ("*)  xrandr --output LVDS1 --off
                             xrandr --output VGA1 --auto
                             if [ `echo $HDMI2 | grep 'HDMI2 connected' | wc -l` = 1 ];then
                                 xrandr --output HDMI2 --left-of VGA1
                             fi;;
               esac;;
               "LVDS1 disconnected"*);;
               *);;
           esac;;
        *1008) # FN+F8
           logger "acpid: Fn+F8 pressed, enabling both monitors (or returning to internal only)"
           case "$LVDS1" in
               "LVDS1 connected 1"*)
                   case "$HDMI2" in
                   "HDMI2 connected 1"*) xrandr --output HDMI2 --off
                                xrandr --output LVDS1 --auto;;
                   "HDMI2 connected ("*) xrandr --output HDMI2 --auto --left-of LVDS1;;
                   *);;
               esac
               case "$VGA1" in
                   "VGA1 connected 1"*)  xrandr --output VGA1 --off
                                xrandr --output LVDS1 --auto;;
                        "VGA1 connected ("*)  xrandr --output VGA1 --auto --left-of LVDS1;;
                   *);;
               esac;;
               "LVDS1 connected ("*)
                   case "$HDMI2" in
                   "HDMI2 connected 1"*) xrandr --output LVDS1 --auto --right-of HDMI2;;
                   *);;
               esac
               case "$VGA1" in
                   "VGA1 connected 1"*)  xrandr --output LVDS1 --auto --right-of VGA1;;
                   *);;
               esac;;
               "LVDS1 disconnected"*);;
               *);;
           esac;;
        *1009) # FN+F9
           logger "acpid: Fn+F9 pressed, reconnecting to $PROFILE";;
           #netcfg down $PROFILE
           #netcfg $PROFILE;;
        *100b) # FN+F11
           logger "acpid: Fn+F11 pressed, rebooting now";;
               #shutdown -r now;;
        *100c) # FN+F12
               logger "acpid: Fn+F12 pressed, initiating shutdown";;
               #reboot -h now;;
        *1018) # THINKPAD (ThinkVantage)
               logger "acpid: ThinkVantage pressed, toggling mute"
           amixer set Master toggle;;
        *7000) # wlan button switched
               logger "acpid: RFKILL switched";;
           #pm-utils already handles this but i could ititiate reconnection here
           #netcfg down $PROFILE
           #netcfg $PROFILE;;
           #/etc/rc.d/net-auto-wireless restart;;
        *1014) # FN+SPACE
               logger "acpid: Fn+Space pressed";;
        *1015) # VOLUME UP
           logger "acpid: volume up";;
               #amixer set Master 5+ unmute;;
        *1016) # VOLUME DOWN
               logger "acpid: volume down";;
               #amixer set Master 5- unmute;;
        *)       logger "IBM HOTKEY: $4";;
    esac;;
#    video)
#        case "$2" in
#            LCD0)
#                case "$3" in
#                    *86)  # Brightness up
#                logger "acpid: brightness up"
#                brightness +
#                #echo `cat /sys/class/backlight/acpi_video0/brightness` > $USERHOME/.brightness &;;
#                    *87)  # Brightness down
#                logger "acpid: brightness down"
#                brightness -
#                #echo `cat /sys/class/backlight/acpi_video0/brightness` > $USERHOME/.brightness &;;
#               esac;;
#        esac;;
    *)   logger "acpid: group/action undefined: $1 / $2";;
esac

events/anything

# Pass all events to our one handler script
event=.*
action=/etc/acpi/handler.sh %e

Last edited by demian (2010-05-14 16:05:55)


no place like /home
github

Offline

#7 2010-05-12 14:11:24

count-corrupt
Member
From: Germany
Registered: 2009-02-01
Posts: 111

Re: [SOLVED] lock screen on when suspending/hibernating

Unfortunately even that doesn't work. When I first saw your handler.sh I thought the DISPLAY settings might be the key but no. However I turn it, neither xlock nor alock or slock will start when invoked from handler.sh. And still no log output.


Desktop: Arch64/Gentoo | XMonad | E6600@2x3Ghz | 4G RAM | Geforce 9800 GTX+ | 2TB 4-Disk Raid 5
Laptop: Arch64 | XMonad | Lenovo X200s with AFFS display mod | L9400@2x1.86Ghz | 4G RAM | 945G

Offline

#8 2010-05-12 18:27:04

demian
Member
From: Frankfurt, Germany
Registered: 2009-05-06
Posts: 708

Re: [SOLVED] lock screen on when suspending/hibernating

You're using xmonad? What's your .xinitrc?

Try launching with ck-launch-session xmonad and use startx in your inittab:

x:5:once:/bin/su USER -l -c "/bin/zsh --login -c startx >/dev/null 2>&1"

That's all the possibly relevant differences i can think of really besides application versions. Are xorg, xlockmore etc up-to-date?
Are you using xorg.conf or input-evdev?

Last edited by demian (2010-05-12 19:39:58)


no place like /home
github

Offline

#9 2010-05-12 21:53:00

count-corrupt
Member
From: Germany
Registered: 2009-02-01
Posts: 111

Re: [SOLVED] lock screen on when suspending/hibernating

Yeah I'm using xmonad and Slim. But I'd hardly look for the problem there. I'm using ck-launch-session now but I'd like to stick to slim. No change whatsoever.

I'll be looking more into why the acpi handler script can't run xlock or any of its friends. Since suspending works there can't really be a problem with rights. The "fix acpid" part of your handler.sh should guarantee that the environment is setup correctly. There has to be something missing.


Desktop: Arch64/Gentoo | XMonad | E6600@2x3Ghz | 4G RAM | Geforce 9800 GTX+ | 2TB 4-Disk Raid 5
Laptop: Arch64 | XMonad | Lenovo X200s with AFFS display mod | L9400@2x1.86Ghz | 4G RAM | 945G

Offline

#10 2010-05-13 12:00:11

count-corrupt
Member
From: Germany
Registered: 2009-02-01
Posts: 111

Re: [SOLVED] lock screen on when suspending/hibernating

OK I got it. When I tried your config I copied it bit by bit and accidentally left out this line:

userhome=$(getent passwd $user | cut -d: -f6)

Hence $userhome wasn't set but XAUTHORITY overwritten with it. Ergo nothing that needed the display could be started from that script. I removed that whole part and now it works.

For the people interested, the relevant parts of my handler.sh now look like this:

pid=$(pgrep dbus-launch)
user=$(ps -o user --no-headers $pid)

set $*

case "$1" in

    ibm/hotkey)
    case "$4" in
        *1002)
            logger "Fn+F2 pressed"
            su -c xlock $user
        ;;  
        *1004)
            logger "Fn+F4 pressed"
            pm-suspend &
            su -c "xlock -mode matrix" $user
        ;;  
        esac
        ;;

Thank you very much demian.

Last edited by count-corrupt (2010-05-13 12:03:07)


Desktop: Arch64/Gentoo | XMonad | E6600@2x3Ghz | 4G RAM | Geforce 9800 GTX+ | 2TB 4-Disk Raid 5
Laptop: Arch64 | XMonad | Lenovo X200s with AFFS display mod | L9400@2x1.86Ghz | 4G RAM | 945G

Offline

#11 2010-05-13 13:07:06

demian
Member
From: Frankfurt, Germany
Registered: 2009-05-06
Posts: 708

Re: [SOLVED] lock screen on when suspending/hibernating

You're welcome. Just a note though: the fix-acpi part only works when you use dbus. I chose it at lack for a more universal process.
There's probably a better method to determine the user.

Last edited by demian (2010-05-13 13:18:54)


no place like /home
github

Offline

#12 2010-05-13 17:11:42

count-corrupt
Member
From: Germany
Registered: 2009-02-01
Posts: 111

Re: [SOLVED] lock screen on when suspending/hibernating

I do use dbus. I rely on kde sc for the gui software I use. Therefore I have kdeinit4 in my .xinitrc. It works like a charm actually. And if it breaks one day I can simply remove the lines and insert my username for $user. I only have one user anyway. But for now your solution is more elegant.

Last edited by count-corrupt (2010-05-13 17:12:17)


Desktop: Arch64/Gentoo | XMonad | E6600@2x3Ghz | 4G RAM | Geforce 9800 GTX+ | 2TB 4-Disk Raid 5
Laptop: Arch64 | XMonad | Lenovo X200s with AFFS display mod | L9400@2x1.86Ghz | 4G RAM | 945G

Offline

#13 2010-05-16 21:57:12

count-corrupt
Member
From: Germany
Registered: 2009-02-01
Posts: 111

Re: [SOLVED] lock screen on when suspending/hibernating

This doesn't work reliably. My laptop was just in state where it would correctly suspend when hitting Fn+F4 but again not start xlock. Restarting acpid fixed the issue but I don't know it didn't work until after I resume the machine. The acpid log is no help there (it doesn't seem to say anything interesting).

Any ideas?


Desktop: Arch64/Gentoo | XMonad | E6600@2x3Ghz | 4G RAM | Geforce 9800 GTX+ | 2TB 4-Disk Raid 5
Laptop: Arch64 | XMonad | Lenovo X200s with AFFS display mod | L9400@2x1.86Ghz | 4G RAM | 945G

Offline

#14 2010-07-16 16:50:52

Barghest
Member
From: Hanau/Germany
Registered: 2008-01-03
Posts: 561

Re: [SOLVED] lock screen on when suspending/hibernating

For me this doesn't work at all.

The problem is that slock segfaults

Jul 16 18:43:12 xerxes logger: acpid: Fn+F2 pressed, locking screen
Jul 16 18:43:12 xerxes kernel: slock[7877]: segfault at 8 ip 00000000004012f1 sp 00007fff399e8ec0 error 4 in slock[400000+2000]

I assume the problem is, that $ pgrep dbus-launch doesn't give a result, although dbus is started in my autostart.sh (openbox). I also tried dbus-launch in my .xinitrc line

\edit: a reboot solved it ;b

Last edited by Barghest (2010-07-17 08:39:05)

Offline

#15 2010-07-30 19:21:12

count-corrupt
Member
From: Germany
Registered: 2009-02-01
Posts: 111

Re: [SOLVED] lock screen on when suspending/hibernating

I solved my problem. I forgot to set DISPLAY in handler.sh. So, naturally, after restarting acpid from within X, it inherited the Shell's env. I exported DISPLAY in handler.sh and now it works reliably.


Desktop: Arch64/Gentoo | XMonad | E6600@2x3Ghz | 4G RAM | Geforce 9800 GTX+ | 2TB 4-Disk Raid 5
Laptop: Arch64 | XMonad | Lenovo X200s with AFFS display mod | L9400@2x1.86Ghz | 4G RAM | 945G

Offline

#16 2010-08-04 18:14:43

demian
Member
From: Frankfurt, Germany
Registered: 2009-05-06
Posts: 708

Re: [SOLVED] lock screen on when suspending/hibernating

Yeah, over the months I did a little work on my handler.sh too, to make it more reliable.
This is the current one that works fine for me:

#!/bin/bash
# /etc/acpi/handler.sh

DBUS=$(ps aux | grep 'dbus-launch' | grep -v root)
if [[ ! -z $DBUS ]];then
  USER=$(echo $DBUS | awk '{print $1}')
  USERHOME=$(getent passwd $USER | cut -d: -f6)
  export XAUTHORITY="$USERHOME/.Xauthority"
  for x in /tmp/.X11-unix/*; do
    DISPLAYNUM=$(echo $x | sed s#/tmp/.X11-unix/X##)
    if [[ -f "$XAUTHORITY" ]]; then
            export DISPLAY=":$DISPLAYNUM"
    fi
  done
else
  USER=demian
  USERHOME=/home/demian
  export XAUTHORITY="$USERHOME/.Xauthority"
  export DISPLAY=":0"
fi
PATH=$USERHOME/.bin:/bin:/usr/bin:/sbin:/usr/sbin
THEFT=$(pgrep theft)
THEFTMODULE=$(lsmod | grep hdaps)
DOCKED=$(cat /sys/devices/platform/dock.0/docked)
WLAN=$(find /sys/class/net | grep -o 'wlan[0-9]')
if [[ -z $WLAN ]] || [[ $(echo $WLAN | wc -l) -ge 2 ]];then
  export WLAN=wlan0
fi
WLANSTATE=$(ifconfig | grep -c $WLAN)
NETPROFILE=$(netcfg current)
BT=/sys/devices/platform/thinkpad_acpi/bluetooth_enable
BTCAT=$(cat $BT)
BTDAEMON=$(ls /var/run/daemons | grep -c bluetooth)
LVDS1=$(xrandr | grep LVDS1)
HDMI2=$(xrandr | grep HDMI2)
VGA1=$(xrandr | grep VGA1)
BAT=/sys/devices/platform/smapi/BAT0
START=$(cat $BAT/start_charge_thresh)
STOP=$(cat $BAT/stop_charge_thresh)
BRIGHT=/sys/class/backlight/acpi_video0/brightness
HARDBLOCKED=$(rfkill list | grep -c 'Hard blocked: yes')
AC=$(grep -c on-line /proc/acpi/ac_adapter/AC/state)
DISPON=$(xset q | grep -c 'Monitor is On')
EVENT=$1\ $2\ $3\ $4
#MINSPEED=$(cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_min_freq)
#MAXSPEED=$(cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq)
#SETSPEED="/sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed"

case "$EVENT" in
    butt*lid*)  if [[ $DOCKED = 0 ]];then
            pm-suspend &
            su -c slock $USER
            fi;;
    ac*0)    # no ac attached
        #echo -n $MINSPEED >$SETSPEED
        [[ $(cat $BRIGHT) != 4 ]] && echo 4 > $BRIGHT
        [[ $(cpufreq-info | grep -c ondemand) != 4 ]] && cpufreq-set -rg ondemand;;
    ac*1)    # ac attached
        #echo -n $MAXSPEED >$SETSPEED
        [[ $START != 60 ]] && echo 60 > $BAT/start_charge_thresh
        [[ $STOP != 90 ]] && echo 90 > $BAT/stop_charge_thresh
        [[ $(cat $BRIGHT) != 8 ]] && echo 8 > $BRIGHT
        [[ $(cpufreq-info | grep -c ondemand) != 4 ]] && cpufreq-set -rg ondemand;;
    bat*0);;    # no battery
    bat*1)    # battery
        [[ $(ethtool eth0 | grep -c ": d") = 0 ]] && ethtool -s eth0 wol d;;
    ibm*1001)    # FN+F1
        [[ $DISPON = 1 ]] && vbetool dpms on && xrandr --auto;;
    ibm*1002)    # FN+F2
        /etc/rc.d/acpid stop
        xset dpms force off
        [[ -z $THEFTMODULE ]] && modprobe hdaps && sleep 1
        theft &
        echo 7 blink >> /proc/acpi/ibm/led
        su -c slock $USER
        killall theft
        echo 7 off >> /proc/acpi/ibm/led
        /etc/rc.d/acpid start &;;
    ibm*1003)    # FN+F3
            xset dpms force off;;
    ibm*1004)    # FN+F4
        pm-suspend &
            su -c slock $USER;;
    ibm*1005)    # FN+F5
        case "$WLANSTATE" in
            1)    ifconfig $WLAN down;;
            0)    ifconfig $WLAN up;;
        esac;;
    ibm*1006)    # FN+F6
        case "$BTCAT" in
            1)  [[ $BTDAEMON = 1 ]] && /etc/rc.d/bluetooth stop
            echo 0 > $BT;;
            0)  [[ $BTDAEMON = 1 ]] && /etc/rc.d/bluetooth stop
            echo 1 > $BT;;
        esac;;
    ibm*1007)    # FN+F7
        case "$LVDS1" in
            "LVDS1 connected"*)
                case "$HDMI2" in
                "HDMI2 connected 1"*) xrandr --output HDMI2 --off --output LVDS1 --auto;;
                "HDMI2 connected ("*) xrandr --output LVDS1 --off --output HDMI2 --auto
                          [[ $(echo $VGA1 | grep -c 'VGA1 connected') = 1 ]] && xrandr --output VGA1 --right-of HDMI2
                          sh $USERHOME/.wallpaper;;
            esac
            case "$VGA1" in
                "VGA1 connected 1"*)  xrandr --output VGA1 --off --output LVDS1 --auto;;
                "VGA1 connected ("*)  xrandr --output LVDS1 --off --output VGA1 --auto
                          [[ $(echo $HDMI2 | grep -c 'HDMI2 connected') = 1 ]] && xrandr --output HDMI2 --left-of VGA1
                          sh $USERHOME/.wallpaper;;
            esac;;
            "LVDS1 disconnected"*);;
            *);;
        esac;;
    ibm*1008)    # FN+F8
        case "$LVDS1" in
            "LVDS1 connected 1"*)
                case "$HDMI2" in
                "HDMI2 connected 1"*) xrandr --output HDMI2 --off --output LVDS1 --auto;;
                "HDMI2 connected ("*) xrandr --output HDMI2 --auto --left-of LVDS1
                          sh $USERHOME/.wallpaper;;
                *);;
            esac
            case "$VGA1" in
                "VGA1 connected 1"*)  xrandr --output VGA1 --off --output LVDS1 --auto;;
                     "VGA1 connected ("*)  xrandr --output VGA1 --auto --left-of LVDS1
                          sh $USERHOME/.wallpaper;;
                *);;
            esac;;
            "LVDS1 connected ("*)
                case "$HDMI2" in
                "HDMI2 connected 1"*) xrandr --output LVDS1 --auto --right-of HDMI2;;
                *);;
            esac
            case "$VGA1" in
                    "VGA1 connected 1"*)  xrandr --output LVDS1 --auto --right-of VGA1;;
                *);;
            esac;;
            "LVDS1 disconnected"*);;
            *);;
        esac;;
    ibm*1009)    # FN+F9
        if [[ -z $THEFT ]];then
          [[ -z $THEFTMODULE ]] && modprobe hdaps && sleep 1
          theft &
          echo 7 blink >> /proc/acpi/ibm/led
        else
          kill $THEFT
          echo 7 off >> /proc/acpi/ibm/led
        fi;;
    ibm*100b)    # FN+F11
            shutdown -r now;;
    ibm*100c)    # FN+F12
            shutdown -h now;;
    ibm*1014)    # FN+SPACE
        if [[ $(cat $BRIGHT) != 9 ]];then
            echo 9 > $BRIGHT
        else
            echo 4 > $BRIGHT
        fi;;
    ibm*1015);; # VOLUME UP
    ibm*1016);; # VOLUME DOWN
    ibm*1018)    # ThinkVantage
        mute;;
    ibm*6030)    # DOCK EVENT
        if [[ $DOCKED = 1 ]];then
            dock -v
        fi;;
    ibm*7000)    # RFKILL
        if [[ $HARDBLOCKED = 0 ]];then
            rfkill block bluetooth
            case $NETPROFILE in
            home)    ;;
            '')    netcfg bett;;
            *)    netcfg all-resume;;
            esac
        else
            case $NETPROFILE in
            home)    ;;
            *)    netcfg all-suspend;;
            esac
        fi;;
    vid*86);;   # FN+POS1
    vid*87);;    # FN+END
    *)        logger "$EVENT undefined";;
esac

Basically I just added static exports as fallback if there's no dbus running as well as edited the dbus process detection part to not take the root user into account which it sometimes did for me. That last one might be the cause of your problem, Barghest.

Regards,
demian

Last edited by demian (2010-08-04 18:20:23)


no place like /home
github

Offline

#17 2010-11-25 13:29:03

akuschki
Member
Registered: 2009-10-17
Posts: 40

Re: [SOLVED] lock screen on when suspending/hibernating

Hi demian,

your handler.sh piqued my interest and I started adapting it for my needs (T42). But I wonder how you best use it, as I have never thought about this before. At the moment I use laptop-mode-tools and cpufreg but I imagine that your handler.sh might conflict with those daemons, no? Do you not use those and if not, why?

Offline

Board footer

Powered by FluxBB