diff options
author | Toby Vincent <tobyv13@gmail.com> | 2023-02-03 15:16:17 -0600 |
---|---|---|
committer | Toby Vincent <tobyv13@gmail.com> | 2023-02-03 15:16:17 -0600 |
commit | 97de3720df47085413640d06c8fe059763c974c4 (patch) | |
tree | ff53e37a3d2c492a04af8467398cea3ea3a47954 /rofi/.local | |
parent | ade5eea45d95b1085c46dc58c9c8ff1890d6f387 (diff) |
feat(rofi): add rofi-ykman for Yubikey TOTP
Diffstat (limited to 'rofi/.local')
-rwxr-xr-x | rofi/.local/bin/rofi-ykman | 33 |
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 |