Recently Written · git

dmenu-scripts

Ask for things

git clone https://github.com/equwal/dmenu-scripts

Log | Files | Refs


commit 7daa9c918587fca4ef8b46d6f2d2522862d667e4
Spenser Truex <truex@equwal.com>
2025-09-02 14:05:21 -0700

Add passmenu-otp

 README.md    |  5 ++++-
 passmenu-otp | 25 +++++++++++++++++++++++++
 2 files changed, 29 insertions(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 5e856a3..5d8dac8 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,7 @@
 # My dmenu scripts
 
+[website](https://therealtruex.com/posts/dmenu-scripts-repo-released)
+
 [dmenu](https://tools.suckless.org/dmenu/) is a simple program with a
 pretty selection window for X. These are my scripts for doing things
 with that.
@@ -17,7 +19,8 @@ with that.
 - `dsysact`: reboot/shutdown/etc.
 - `dtimer`: a coffee timer. Check out [uniformativ.de](https://www.uninformativ.de/git/countty/file/README.html)'s countty for a non-dmenu one.
 - `dtmpl`: copy template files from a directory into the clipboard
-- `passmenu`: unix [`pass`](https://www.passwordstore.org/) interface
+- `passmenu`: unix [`pass`](https://www.passwordstore.org/) interface, copies to clipboard.
+- `passmenu-otp`: like passmenu but copies the OTP code to clipboard.
 - `y-or-n`: ask if yes or no
 
 ## Submodules with even more scripts
diff --git a/passmenu-otp b/passmenu-otp
new file mode 100755
index 0000000..8470fbb
--- /dev/null
+++ b/passmenu-otp
@@ -0,0 +1,25 @@
+#!/usr/bin/env bash
+
+shopt -s nullglob globstar
+
+typeit=0
+if [[ $1 == "--type" ]]; then
+	typeit=1
+	shift
+fi
+
+prefix=${PASSWORD_STORE_DIR-~/.password-store}
+password_files=( "$prefix"/**/*.gpg )
+password_files=( "${password_files[@]#"$prefix"/}" )
+password_files=( "${password_files[@]%.gpg}" )
+
+password=$(printf '%s\n' "${password_files[@]}" | dmenu "$@")
+
+[[ -n $password ]] || exit
+
+if [[ $typeit -eq 0 ]]; then
+	pass otp -c "$password" 2>/dev/null
+else
+	pass otp show "$password" | { IFS= read -r pass; printf %s "$pass"; } |
+		xdotool type --clearmodifiers --file -
+fi