summarylogtreecommitdiffstats
path: root/passmenu-extended.patch
blob: 6aaddf930e01ef7f26277997516c94ea34cb4af8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
diff --unified --recursive --text password-store-1.7.3/contrib/dmenu/passmenu password-store-1.7.3.new/contrib/dmenu/passmenu
--- password-store-1.7.3/contrib/dmenu/passmenu	2020-05-07 10:15:53.692356060 +1200
+++ password-store-1.7.3.new/contrib/dmenu/passmenu	2020-05-07 10:11:21.246208556 +1200
@@ -8,6 +8,30 @@
 	shift
 fi
 
+typeuser=0
+if [[ $1 == "--typeuser" ]]; then
+        typeuser=1
+        shift
+fi
+
+typeboth=0
+if [[ $1 == "--typeboth" ]]; then
+	typeboth=1
+	shift
+fi
+
+otp=0
+if [[ $1 == "--otp" ]]; then
+        otp=1
+        shift
+fi
+
+typeotp=0
+if [[ $1 == "--typeotp" ]]; then
+        typeotp=1
+        shift
+fi
+
 prefix=${PASSWORD_STORE_DIR-~/.password-store}
 password_files=( "$prefix"/**/*.gpg )
 password_files=( "${password_files[@]#"$prefix"/}" )
@@ -17,9 +41,24 @@
 
 [[ -n $password ]] || exit
 
-if [[ $typeit -eq 0 ]]; then
-	pass show -c "$password" 2>/dev/null
-else
+if [[ $typeit -eq 1 ]]; then	
+	pass show "$password" | { IFS= read -r pass; printf %s "$pass"; } |
+		xdotool type --clearmodifiers --file -
+elif [[ $typeuser -eq 1 ]]; then
+	pass show "$password" | awk 'BEGIN{ORS="\t"} NR==2 {print; exit}' |
+                sed 's/user\:\s//' | # Specify a custom filter if needed
+                xdotool type --clearmodifiers --file -
+elif [[ $typeboth -eq 1 ]]; then
+	pass show "$password" | awk 'BEGIN{ORS="\t"} NR==2 {print; exit}' |
+		sed 's/user\:\s//' | # Specify a custom filter if needed
+		xdotool type --clearmodifiers --file -
 	pass show "$password" | { IFS= read -r pass; printf %s "$pass"; } |
 		xdotool type --clearmodifiers --file -
+elif [[ $otp -eq 1 ]]; then
+	pass otp -c "$password" 2>/dev/null
+elif [[ $typeotp -eq 1 ]]; then
+	pass otp "$password" | { IFS= read -r pass; printf %s "$pass"; } |
+	        xdotool type --clearmodifiers --file -	
+else
+	pass show -c "$password" 2>/dev/null
 fi
diff --unified --recursive --text password-store-1.7.3/contrib/dmenu/README.md password-store-1.7.3.new/contrib/dmenu/README.md
--- password-store-1.7.3/contrib/dmenu/README.md	2020-05-07 10:15:27.296221593 +1200
+++ password-store-1.7.3.new/contrib/dmenu/README.md	2020-05-07 10:09:48.133462161 +1200
@@ -1,13 +1,24 @@
 `passmenu` is a [dmenu][]-based interface to [pass][], the standard Unix
 password manager. This design allows you to quickly copy a password to the
 clipboard without having to open up a terminal window if you don't already have
-one open. If `--type` is specified, the password is typed using [xdotool][]
-instead of copied to the clipboard.
+one open. 
+
+If `--type` is specified, the password is typed using [xdotool][]
+instead of copied to the clipboard. If `--typeuser` is specified, the
+second line is typed using [xdotool][] (ideally the username). If `--typeboth` 
+is specified, the second line is typed using [xdotool][] first (ideally the 
+username), then tab, then the first line.
+
+If [pass-otp][] is installed and `--typeotp` is specified, the otpauth URI
+is used to generate a token that is typed using [xdotool][]. If `--otp` is
+specified, the otpauth URI is used to generate a token that is copied to
+the clipboard.
 
 # Usage
 
-    passmenu [--type] [dmenu arguments...]
+    passmenu [--type | --typeuser | --typeboth | --typeotp | --otp] [dmenu arguments...]
 
-[dmenu]: http://tools.suckless.org/dmenu/
-[xdotool]: http://www.semicomplete.com/projects/xdotool/
-[pass]: http://www.zx2c4.com/projects/password-store/
+[dmenu]: https://tools.suckless.org/dmenu/
+[xdotool]: https://www.semicomplete.com/projects/xdotool/
+[pass]: https://www.zx2c4.com/projects/password-store/
+[pass-otp]: https://github.com/tadfisher/pass-otp