You are not logged in.
Pages: 1
Hi, I just wanted to post here instructions how to make Fn+F2 key shortcut to lock screen properly on Lenovo ThinkPad (tested on x200s), because it took me quite a lot of time finding out how to do it. I wanted it to lock all sessions on all virtual displays, which makes it a little more complicated.
1) make sure your acpid and dbus work
2) Create a file named /etc/acpi/events/fn-f2.sh with the following content:
event=ibm/hotkey HKEY 00000080 00001002
action=/etc/acpi/dbus-lock-screen.sh %e
3) Create a file named /etc/acpi/dbus-lock-screen.sh with the following content:
#!/bin/bash
users=$(who|grep '^\w\w* *:'|awk '{print $1}'|sort|uniq)
for user in $users; do
userhome=$(grep "^$user:" /etc/passwd|awk -F : '{print $6}')
cd "$userhome/.dbus/session-bus/"
for sf in $(ls); do
source $sf
export DBUS_SESSION_BUS_ADDRESS
export DBUS_SESSION_BUS_PID
export DBUS_SESSION_BUS_WINDOWID
su $user -c 'qdbus org.freedesktop.ScreenSaver /ScreenSaver Lock'
done
done
4) chmod +x /etc/acpi/dbus-lock-screen.sh
5) /etc/rc.d/acpid restart
Thats it, now pressing Fn+F2 will lock all X sessions,
Offline
Thanks for sharing.
Doesn't work for me on X200s though.
Sadly, I don't really have the time to dive into the topic to find out what's wrong.
Regards,
demian
Last edited by demian (2011-04-30 15:00:45)
no place like /home
github
Offline
Problem is in regex for grep in $users - it returns nothing for me. Simple grep '(:'
should work.
Because I'm the only user on my laptop, this works for me
su -c ". ~/.dbus/session-bus/$(cat /var/lib/dbus/machine-id)-0 ;
export DBUS_SESSION_BUS_ADDRESS ;
/usr/bin/qdbus org.freedesktop.ScreenSaver /ScreenSaver Lock" \
- $user
Note that probably you need to change $(cat /var/lib/dbus/machine-id)-0 if your $DISPLAY is not :0.0
Offline
Pages: 1