Skip to content

Instantly share code, notes, and snippets.

@cfra
Created July 22, 2021 09:28
Show Gist options
  • Save cfra/72af00710e55c4331ac7947379f1118f to your computer and use it in GitHub Desktop.
Save cfra/72af00710e55c4331ac7947379f1118f to your computer and use it in GitHub Desktop.
Use totp python package to generate totp tokens from pass menu
--- /usr/bin/passmenu 2021-06-12 18:06:38.000000000 +0200
+++ /usr/local/bin/mypassmenu 2021-07-22 11:19:24.138521764 +0200
@@ -28,6 +28,20 @@
[[ -n $password ]] || exit
+if [[ ${password%-otp} != ${password} ]]; then
+ code_file="$prefix/2fa/$password/code.gpg"
+ [[ -e "$code_file" ]] || {
+ mkdir -p "$prefix/2fa/$password"
+ ln -s "$prefix/${password}.gpg" "$code_file"
+ }
+ if [[ $typeit -eq 0 ]]; then
+ totp show "$password" > /dev/null
+ else
+ totp show -n "$password" | { IFS= read -r pass; printf %s "$pass"; } | $xdotool
+ fi
+ exit 0
+fi
+
if [[ $typeit -eq 0 ]]; then
pass show -c "$password" 2>/dev/null
else
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment