Created
April 29, 2019 10:33
-
-
Save ju916/e85629890d50b4e31f64f3620e930b45 to your computer and use it in GitHub Desktop.
Script to lock XScreensaver
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# echo "USB device removed `date` $@" >>/tmp/xscreenlock.log | |
#user=ju | |
user=`who | grep ':0' | awk '{print $1}'| head -1` | |
if [ ! -z "$user" ] ; then | |
DISPLAY=:0 sudo -n -H -u "$user" /usr/bin/xscreensaver-command -lock >> /tmp/xscreenlock.log 2>>/tmp/xscreenlock.log | |
fi | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In Zeile 6 ist noch ein Fehler enthalten.
Das Kommando
who
gibt bei mir z.B. folgenden Ausgabe:grep ':0'
matcht auf beide Zeilen. Undhead -1
wählt dann den NutzertollerAdmin
, obwohl dieser auf Display:1
arbeitet.Daher einfach Zeile wie folgt ändern:
user=`who | grep '(:0)' | awk '{print $1}'| head -1`
Viele Grüße :-)