diff options
author | Joe <bousset.rudy@gmail.com> | 2022-05-19 10:33:57 +0200 |
---|---|---|
committer | Joe <bousset.rudy@gmail.com> | 2022-05-19 10:33:57 +0200 |
commit | 9befc770be885de782803167e7b3fca27d2f2d73 (patch) | |
tree | b2e801b2996e236e3a951b1b41838b42f07535b6 /.local | |
parent | update (diff) | |
download | dotfiles-bsd-9befc770be885de782803167e7b3fca27d2f2d73.tar.gz dotfiles-bsd-9befc770be885de782803167e7b3fca27d2f2d73.tar.bz2 dotfiles-bsd-9befc770be885de782803167e7b3fca27d2f2d73.tar.xz dotfiles-bsd-9befc770be885de782803167e7b3fca27d2f2d73.tar.zst dotfiles-bsd-9befc770be885de782803167e7b3fca27d2f2d73.zip |
update
Diffstat (limited to '.local')
-rwxr-xr-x | .local/bin/dmotp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/.local/bin/dmotp b/.local/bin/dmotp new file mode 100755 index 0000000..9744bc7 --- /dev/null +++ b/.local/bin/dmotp @@ -0,0 +1,21 @@ +#!/bin/sh + +if [ -n "$WAYLAND_DISPLAY" ]; then + dmenu=dmenu-wl + xdotool="ydotool type --file -" +elif [ -n "$DISPLAY" ]; then + dmenu=dmenu + xdotool="xdotool type --delay 15 --clearmodifiers --file -" +else + echo "Error: No Wayland or X11 display detected" >&2 + exit 1 +fi + +prefix=${PASSWORD_STORE_DIR-~/.local/share/pass}/otp +rprefix=$(printf "%s" $prefix | sed 's/\//\\\//g') +password_files=$(ls "$prefix"/*.gpg | sed 's/^'${rprefix}'\///g' | sed 's/\.gpg//g') +password=$(printf "%s\n" "${password_files}" | "$dmenu" -i -l 15 -m 0) + +[ -n "$password" ] || exit + +pass otp show otp/"$password" | { IFS= read -r pass; printf %s "$pass"; } | $xdotool |