[bin] Add helper script to restart pcscd upon plugging in a Yubikey

This seems to be some sort of weird issue with pcscd and I've got shit to do.
This commit is contained in:
Sebastian Schulze 2021-01-22 12:28:14 +01:00
parent 8916d23409
commit bd7d18fd27
Signed by: bascht
GPG Key ID: 5BCB1D3B4D38A35A
1 changed files with 17 additions and 0 deletions

View File

@ -0,0 +1,17 @@
#!/bin/bash
SWAYSOCK=$(ls /run/user/1000/sway-ipc.1000.*.sock)
export SWAYSOCK
swaymsg exec -- 'notify-send -t 2000 -u low "Yubikey plugged in, reloading pcsd. User: ${USER}"'
RETRIES=0
while ! HOLDER=$(gpg --card-status|grep Login | cut -d ":" -f 2 | tr -d " "); do
sudo /bin/systemctl restart pcscd.service
sleep 3
if (( RETRIES > 3 )); then
exit 1;
fi;
$RETRIES++;
done
swaymsg exec -- "notify-send -t 2000 -u low \"Successfully poked pcscd, found Yubikey for ${HOLDER}\""