From bd7d18fd272df53d096586365ea7482531e7fcb3 Mon Sep 17 00:00:00 2001 From: Sebastian Schulze Date: Fri, 22 Jan 2021 12:28:14 +0100 Subject: [PATCH] [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. --- bin/executable_yubikey-plug-in | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 bin/executable_yubikey-plug-in diff --git a/bin/executable_yubikey-plug-in b/bin/executable_yubikey-plug-in new file mode 100644 index 0000000..47ae830 --- /dev/null +++ b/bin/executable_yubikey-plug-in @@ -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}\""