[GTALUG] Locking KDE 5 screen from shell script
Randy Jonasz
rjonasz at rjonasz.org
Thu Aug 13 23:58:15 UTC 2015
Thanks for the tip Mauro, Lennart! It turns out the problem was with not
having the DISPLAY variable set properly. So in lockkde.sh I invoke
qdbus this way
Konsole output
DISPLAY=:0 /usr/bin/qdbus org.freedesktop.ScreenSaver /ScreenSaver Lock
And now it works!
Thanks again,
Randy
On 12/08/15 07:35 AM, Mauro Souza wrote:
>
> You could change this line
> ps aux | grep cinnamon-session | grep -v grep
>
> to this
> pgrep cinnamon-session
>
> It's cleaner and works well.
>
> To answer the main question, try to install bashdb and run the script
> thru it. It's the bash debugger, it's far more powerful than bash -vx.
>
> On Aug 12, 2015 04:22, "Randy Jonasz" <rjonasz at rjonasz.org
> <mailto:rjonasz at rjonasz.org>> wrote:
>
> 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
>
> #! /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
>
> #! /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
>
>
> ---
> Talk Mailing List
> talk at gtalug.org <mailto:talk at gtalug.org>
> http://gtalug.org/mailman/listinfo/talk
>
>
>
> ---
> Talk Mailing List
> talk at gtalug.org
> http://gtalug.org/mailman/listinfo/talk
--
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://gtalug.org/pipermail/talk/attachments/20150813/16aa413b/attachment.html>
More information about the talk
mailing list