--- /dev/null
+#!/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