summaryrefslogtreecommitdiffstats
path: root/.local/bin/dmpass
diff options
context:
space:
mode:
authorJoe <bousset.rudy@gmail.com>2022-05-12 12:05:45 +0200
committerJoe <bousset.rudy@gmail.com>2022-05-12 12:05:45 +0200
commit5b3bf5a4fcaf460800a41b90609b5363b254a7a3 (patch)
treefdd5e5e32cb19c7213365b70f9c90ae57bbb8665 /.local/bin/dmpass
parentFix (diff)
downloaddotfiles-bsd-5b3bf5a4fcaf460800a41b90609b5363b254a7a3.tar.gz
dotfiles-bsd-5b3bf5a4fcaf460800a41b90609b5363b254a7a3.tar.bz2
dotfiles-bsd-5b3bf5a4fcaf460800a41b90609b5363b254a7a3.tar.xz
dotfiles-bsd-5b3bf5a4fcaf460800a41b90609b5363b254a7a3.tar.zst
dotfiles-bsd-5b3bf5a4fcaf460800a41b90609b5363b254a7a3.zip
Updates, new script!
Diffstat (limited to '')
-rwxr-xr-x.local/bin/dmpass31
1 files changed, 31 insertions, 0 deletions
diff --git a/.local/bin/dmpass b/.local/bin/dmpass
new file mode 100755
index 0000000..8fd3568
--- /dev/null
+++ b/.local/bin/dmpass
@@ -0,0 +1,31 @@
+#!/bin/sh
+
+typeit=0
+if [ "$1" = "--type" ]; then
+ typeit=1
+ shift
+fi
+
+if [ -n "$WAYLAND_DISPLAY" ]; then
+ dmenu=dmenu-wl
+ xdotool="ydotool type --file -"
+elif [ -n "$DISPLAY" ]; then
+ dmenu=dmenu
+ xdotool="xdotool type --delay 25 --clearmodifiers --file -"
+else
+ echo "Error: No Wayland or X11 display detected" >&2
+ exit 1
+fi
+
+prefix=${PASSWORD_STORE_DIR-~/.local/share/pass}
+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
+
+if [ $typeit -eq 0 ]; then
+ pass show -c "$password" >/dev/null 2>&1
+else
+ pass show "$password" | { IFS= read -r pass; printf %s "$pass"; } | $xdotool
+fi