X-Git-Url: https://git.friedersdorff.com/?a=blobdiff_plain;f=states%2Fsway%2Ffiles%2Flock;h=230369e613ccb98a329665b305372b820a0623f2;hb=d4f86cc0a4469d5c31f92f2ab0e005ef39b14abc;hp=f78f68545e1a2e21cadf40ce89643716561abc87;hpb=9280ed5db9e0c8da54151a747235d6a450d4a7e2;p=max%2Fsaltfiles.git diff --git a/states/sway/files/lock b/states/sway/files/lock index f78f685..230369e 100644 --- a/states/sway/files/lock +++ b/states/sway/files/lock @@ -4,40 +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="swaylock " -SLEEP_CMD=":" -{% 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" -SLEEP_CMD="systemctl suspend" -{% endif %} +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 -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 - - sleep 1 - counter=$(bc <<<"${counter}+1") - gpg --card-status > /dev/null - done - pkill -f "$NAG_MSG" - fi - $LOCK_CMD & - sleep 10 - $SLEEP_CMD + sleep 1 + counter=$(bc <<<"${counter}+1") + gpg --card-status > /dev/null + done + pkill -f "$NAG_MSG" fi +pkill -u ${UID} swayidle --signal USR1