]> git.friedersdorff.com Git - max/saltfiles.git/commitdiff
Simplify lock script
authorMaximilian Friedersdorff <max@friedersdorff.com>
Thu, 9 Jan 2020 10:34:59 +0000 (10:34 +0000)
committerMaximilian Friedersdorff <max@friedersdorff.com>
Thu, 9 Jan 2020 10:34:59 +0000 (10:34 +0000)
states/sway/files/lock

index 936b955c261c5eaa930b13763ebf0979433f984d..230369e613ccb98a329665b305372b820a0623f2 100644 (file)
@@ -4,28 +4,22 @@ NAG_MSG="Smartcard is still plugged in, not locking! \
 Remove now to lock."
 NOLOCK_MSG="Smartcard was not removed, did not lock!"
 
-LOCK_CMD="systemctl suspend"
+gpg --card-status > /dev/null
+if [ $? -ne 2 ]; then
+       swaynag -m "$NAG_MSG" --type warning&
 
-if [ $(pgrep -c lock.magnesium) -gt 1 ]; then
-       exit
-else
-       gpg --card-status > /dev/null
-       if [ $? -ne 2 ]; then
-               swaynag -m "$NAG_MSG" --type warning&
+       counter=0
+       while [ $? -ne 2 ]; do
+               if [ $counter -gt 20 ]; then
+                       pkill -f "$NAG_MSG"
+                       swaynag -m "$NOLOCK_MSG" --type error&
+                       exit
+               fi
 
-               counter=0
-               while [ $? -ne 2 ]; do
-                       if [ $counter -gt 20 ]; then
-                               pkill -f "$NAG_MSG"
-                               swaynag -m "$NOLOCK_MSG" --type error&
-                               exit
-                       fi
-
-                       sleep 1
-                       counter=$(bc <<<"${counter}+1")
-                       gpg --card-status > /dev/null
-               done
-               pkill -f "$NAG_MSG"
-       fi
-       $LOCK_CMD
+               sleep 1
+               counter=$(bc <<<"${counter}+1")
+               gpg --card-status > /dev/null
+       done
+       pkill -f "$NAG_MSG"
 fi
+pkill -u ${UID} swayidle --signal USR1