X-Git-Url: https://git.friedersdorff.com/?a=blobdiff_plain;f=states%2Fsway%2Ffiles%2Flock;h=3b01fe16b083a77a64f9423c1a02b3acc1e8ce40;hb=fe6bf662d134c8c86543858b19406f447f7cb57f;hp=75498371adad556c7610e686b82b84d51c1508de;hpb=31e13a4bca72c4cf40590ebd1331e635a6192e40;p=max%2Fsaltfiles.git diff --git a/states/sway/files/lock b/states/sway/files/lock index 7549837..3b01fe1 100644 --- a/states/sway/files/lock +++ b/states/sway/files/lock @@ -1,22 +1,39 @@ #!/bin/sh NAG_MSG="Smartcard is still plugged in, not locking! \ -Lock again to force locking." +Remove now to lock." +NOLOCK_MSG="Smartcard was not removed, did not lock!" LOCK_CMD="swaylock " +{% if grains['host'] == 'magnesium' %} LOCK_CMD+=" -i HDMI-A-2:~/Pictures/lockscreen_1080_1.png" LOCK_CMD+=" -i HDMI-A-3:~/Pictures/lockscreen_1080_2.png" +{% elif grains['host'] == 'barium' %} +LOCK_CMD+=" -i eDP-1:~/Pictures/lockscreen_1080_1.png" +LOCK_CMD+=" -i HDMI-A-1:~/Pictures/lockscreen_1080_1.png" +{% endif %} -if [ $(pgrep -c lock.{{ grains['host'] }}) -gt 1 ]; then - pkill -f "$NAG_MSG" - $LOCK_CMD + +if [ $(pgrep -c lock.magnesium) -gt 1 ]; then + exit else gpg --card-status > /dev/null if [ $? -ne 2 ]; then - gpg --card-status - echo $? - swaynag -m "$NAG_MSG" --type warning - else - $LOCK_CMD + 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 + + sleep 1 + counter=$(bc <<<"${counter}+1") + gpg --card-status > /dev/null + done + pkill -f "$NAG_MSG" fi + $LOCK_CMD fi