X-Git-Url: https://git.friedersdorff.com/?a=blobdiff_plain;f=sway%2F.local%2Fbin%2Flock.magnesium;h=b7cbe89dd178be35fd30ec1cee1b522785347f61;hb=HEAD;hp=d1db92375ff532fbaadfbf168913ae58df151fe5;hpb=9cf8dae6aec2c66cb0d50250be388ae5e15f3a34;p=max%2Fdotfiles.git diff --git a/sway/.local/bin/lock.magnesium b/sway/.local/bin/lock.magnesium index d1db923..b7cbe89 100755 --- a/sway/.local/bin/lock.magnesium +++ b/sway/.local/bin/lock.magnesium @@ -1,5 +1,22 @@ #!/bin/sh -swaylock \ - -i HDMI-A-2:~/Pictures/lockscreen_1080_1.png \ - -i HDMI-A-3:~/Pictures/lockscreen_1080_2.png +NAG_MSG="Smartcard is still plugged in, not locking! \ +Lock again to force locking." + +LOCK_CMD="swaylock " +LOCK_CMD+=" -i HDMI-A-2:~/Pictures/lockscreen_1080_1.png" +LOCK_CMD+=" -i HDMI-A-3:~/Pictures/lockscreen_1080_2.png" + +if [ $(pgrep -c lock.${HOSTNAME}) -gt 1 ]; then + pkill -f "$NAG_MSG" + $LOCK_CMD +else + gpg --card-status > /dev/null + if [ $? -ne 2 ]; then + gpg --card-status + echo $? + swaynag -m "$NAG_MSG" --type warning + else + $LOCK_CMD + fi +fi