-if [ $(pgrep -c lock.{{ grains['host'] }}) -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
+ 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"