
I recently installed kde5 on debian stretch. I have a yubikey which I use to log in with. I'd like to lock the screen when I remove the yubikey. I have it working with cinnamon and lxde but I can't quite get it with kde. I can lock the screen if I run the shell script from a terminal as root but when I remove the yubikey the shell script returns error code 1. Here's my shell scripts: ykgone.sh Konsole output #! /bin/sh if [ -z "$(lsusb | grep Yubikey)" ] ; then if [ ! -z "$(ps aux | grep cinnamon-session | grep -v grep)" ] ; then /bin/su rjonasz -c "DISPLAY=:0 cinnamon-screensaver-command -l" elif [ ! -z "$(ps aux | grep startkde | grep -v grep)" ] ; then /usr/bin/sudo -u rjonasz -H -i /usr/local/bin/lockkde.sh else /bin/su rjonasz -c "DISPLAY=:0 xscreensaver-command --lock" fi fi lockkde.sh Konsole output #! /bin/sh kde_pid=`pidof kdeinit5` export `cat /proc/$kde_pid/environ|grep -ao 'DBUS_SESSION_BUS_ADDRESS=[[:graph:]]*'` /usr/bin/qdbus org.freedesktop.ScreenSaver /ScreenSaver Lock I can't seem to figure this one out. Thanks for any help! Randy -- Even philosophers will praise war as ennobling mankind, forgetting the Greek who said: 'War is bad in that it begets more evil than it kills.' Immanuel Kant