aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/rofi
diff options
context:
space:
mode:
authorToby Vincent <tobyv13@gmail.com>2023-02-03 15:16:17 -0600
committerToby Vincent <tobyv13@gmail.com>2023-02-03 15:16:17 -0600
commit97de3720df47085413640d06c8fe059763c974c4 (patch)
treeff53e37a3d2c492a04af8467398cea3ea3a47954 /rofi
parentade5eea45d95b1085c46dc58c9c8ff1890d6f387 (diff)
feat(rofi): add rofi-ykman for Yubikey TOTP
Diffstat (limited to 'rofi')
-rwxr-xr-xrofi/.local/bin/rofi-ykman33
1 files changed, 33 insertions, 0 deletions
diff --git a/rofi/.local/bin/rofi-ykman b/rofi/.local/bin/rofi-ykman
new file mode 100755
index 0000000..3d4ca99
--- /dev/null
+++ b/rofi/.local/bin/rofi-ykman
@@ -0,0 +1,33 @@
+#!/usr/bin/env bash
+
+# rofi-ykman
+# Yubikey oath utility
+
+#2019 nukeop
+
+if [ ! "$(ykman info)" ]; then
+ notify-send "rofi-ykman" "Yubikey not detected." -a "rofi-ykman"
+ exit 1
+fi
+
+OPTIONS=$(ykman oath accounts list)
+LAUNCHER="rofi -dmenu -i -p YubikeyOATH"
+
+option=$(echo "${OPTIONS/, TOTP/\n}" | $LAUNCHER)
+code=$(ykman oath accounts code "$option")
+IFS=', ' read -r -a code <<<"$code"
+if [ "$XDG_SESSION_TYPE" == "wayland" ]; then
+ cliptool=wl-copy
+ typer="wtype -"
+else
+ cliptool="xclip -selection clipboard"
+ typer="xargs xdotool type"
+fi
+if [ "$1" == "type" ]; then
+ action=$typer
+else
+ action=$cliptool
+fi
+
+notify-send "rofi-ykman" "Touch Yubikey..." -a "rofi-ykman"
+echo "${code[-1]}" | $action