X-Git-Url: https://git.friedersdorff.com/?a=blobdiff_plain;ds=sidebyside;f=states%2Fi3%2Ffiles%2Flock;fp=states%2Fi3%2Ffiles%2Flock;h=230369e613ccb98a329665b305372b820a0623f2;hb=790131a40e3748b9a8074fa778650fcda5ad3213;hp=0000000000000000000000000000000000000000;hpb=6bd4126d779dbc1782769a1a84c8222c3ca5a467;p=max%2Fsaltfiles.git diff --git a/states/i3/files/lock b/states/i3/files/lock new file mode 100644 index 0000000..230369e --- /dev/null +++ b/states/i3/files/lock @@ -0,0 +1,25 @@ +#!/bin/sh + +NAG_MSG="Smartcard is still plugged in, not locking! \ +Remove now to lock." +NOLOCK_MSG="Smartcard was not removed, did not lock!" + +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 +pkill -u ${UID} swayidle --signal USR1