aboutsummaryrefslogtreecommitdiffhomepage
path: root/X11/rofi/pass.get
diff options
context:
space:
mode:
Diffstat (limited to 'X11/rofi/pass.get')
-rwxr-xr-xX11/rofi/pass.get54
1 files changed, 54 insertions, 0 deletions
diff --git a/X11/rofi/pass.get b/X11/rofi/pass.get
new file mode 100755
index 0000000..df70652
--- /dev/null
+++ b/X11/rofi/pass.get
@@ -0,0 +1,54 @@
1#! /bin/sh
2
3ROFI_ARGS=( '-font' 'Hack 22' )
4OPTIONS_NEW=( 'NO' 'YES' 'YES, and edit it' )
5
6# Generate a new password
7if [ -n "${ROFI_DATA}" ]; then
8 [ "$1" == "${OPTIONS_NEW[1]}" ] && \
9 coproc (
10 export POST=false
11 pass generate ${ROFI_DATA} --clip
12 rofi "${ROFI_ARGS[@]}" -e "Generate and Copied: ${ROFI_DATA}"
13 )
14
15 [ "$1" == "${OPTIONS_NEW[2]}" ] && \
16 coproc (
17 export POST=false
18 pass generate ${ROFI_DATA} --clip
19 alacritty -e pass edit ${ROFI_DATA}; \
20 )
21
22 exit 0
23fi
24
25# Give rofi available passwords and exit
26if [ $# -eq 0 ]; then
27 # Specify rofi prompt as 'Get'
28 echo -e "\0prompt\x1fGet"
29
30 find ~/.password-store -name '*gpg' -printf %P\\n | \
31 sed 's/.gpg$//'
32
33 exit 0
34fi
35
36# Test password exists or not
37RESULT="$(pass $1)"
38if [ -n "$RESULT" ]; then
39 # Copy the given password into clipboard
40 echo "$RESULT" | head -1 | xsel -ib
41
42 # And show extra message
43 EXTRA="$(echo; echo; echo "$RESULT" | sed '1d; 1{/^$/d}')"
44 coproc ( rofi "${ROFI_ARGS[@]}" -e "Copied: $1$EXTRA" )
45# Password doesn't exist yet
46# Go to next rofi execution
47else
48 echo -e "\0prompt\x1f$1 doesn't exist, generate it?"
49 echo -e "\0data\x1f$1"
50
51 for i in "${OPTIONS_NEW[@]}"; do
52 echo $i
53 done
54fi