Commit ac70c882f148

Vincent Demeester <vincent@sbr.pm>
2026-06-17 09:38:10
feat: notify when yubikey is missing for authkey
Added early detection and desktop notification when authkey needs yubikey OATH but no yubikey is connected, preventing redhat-vpn from hanging silently.
1 parent 54faeab
Changed files (1)
pkgs
my
scripts
pkgs/my/scripts/bin/authkey
@@ -6,5 +6,10 @@ if [ -f ~/.oath/key ]; then
 	oathtool --hotp "$(cat ~/.oath/key)" -c "$([ ! -f ~/.oath/counter ] && echo -n 0 > ~/.oath/counter || echo -n $(($(cat ~/.oath/counter)+1)) > ~/.oath/counter; cat ~/.oath/counter)"
 else
 	# Fallback: YubiKey OATH
+	if ! ykman info &>/dev/null; then
+		notify-send --urgency=critical "authkey" "YubiKey not connected. Please plug in your YubiKey."
+		echo "Error: YubiKey not connected" >&2
+		exit 1
+	fi
 	ykman oath accounts code --single "Red Hat:redhat" 2>/dev/null | grep -oE '[0-9]{6,8}'
 fi
\ No newline at end of file