1
0
mirror of https://github.com/frebib/dotfiles.git synced 2024-06-14 12:57:23 +00:00

i3: Add $mod+z otp selector

Signed-off-by: Joe Groocock <me@frebib.net>
This commit is contained in:
Joe Groocock 2021-11-23 11:05:34 +00:00
parent 49554ca359
commit a7778c30a7
Signed by: frebib
GPG Key ID: E0B16BEACFBB6A86
2 changed files with 43 additions and 0 deletions

View File

@ -152,6 +152,7 @@ bindsym $mod+numbersign exec systemd-run-i3 -n i3-sensible-terminal --ho
bindsym $mod+r exec bash -c 'pwgen -snc 32 1 | tee >(xargs notify-send Generated\ password\:) | xclip -i -r'
bindsym $mod+g exec systemd-run-i3 -n notify-send -c transfer "$(gist -PRpc)"
bindsym --release $mod+i exec systemd-run-i3 -s background -n sh -c 'sleep 0.5 && xdotool getactivewindow type --delay 10 -- "$(xclip -o -selection clipboard)"'
bindsym $mod+z exec otp | rofi -dmenu -p otp | xargs otp
# Media player controls
bindsym XF86AudioPlay exec --no-startup-id playerctl -a play-pause

42
scripts/otp Executable file
View File

@ -0,0 +1,42 @@
#!/usr/bin/env bash
while getopts "on:" o; do
case "${o}" in
o)
stdout=1;;
n)
caller="${OPTARG}"
;;
*)
exec ykman oath accounts list
;;
esac
done
shift $((OPTIND-1))
if [ $# -lt 1 ]; then
exec ykman oath accounts list
fi
if [ -n "$caller" ]; then
notif="$(notify-send -p "Touch your Yubikey" "$caller is requesting otp for $1")"
fi
ykman oath accounts code -s "$1" 2>&1 |
while read -r x; do
if grep -Pqw '[0-9]{6}' <<< "$x"; then
if [ -z "$stdout" ]; then
echo "$x" | tee >(xclip -i)
xdotool type "$x"
else
echo "$x"
fi
fi
if [ -z "$stdout" ]; then
notify-send "$x";
fi
done
if [ -n "$notif" ]; then
notify-send -r "$notif" -t 1000 "Touch your Yubikey" "otp generated for $caller"
fi