aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rwxr-xr-xX11/rofi/pass.get70
1 files changed, 36 insertions, 34 deletions
diff --git a/X11/rofi/pass.get b/X11/rofi/pass.get
index ffe7988..7bec799 100755
--- a/X11/rofi/pass.get
+++ b/X11/rofi/pass.get
@@ -1,54 +1,56 @@
1#! /bin/sh 1#! /bin/sh
2 2
3OPTIONS_NEW=( 'NO' 'YES' 'YES, and edit it' ) 3GENERATION_HINT="Generate with default config"
4 4
5# Generate a new password 5# Generate a new password if ROFI_DATA is given by last execution
6if [ -n "${ROFI_DATA}" ]; then 6if [ -n "${ROFI_DATA}" ]; then
7 [ "$1" == "${OPTIONS_NEW[1]}" ] && \ 7 PASSWORD="${ROFI_DATA}"
8 coproc ( 8 export ROFI_DATA=
9 export POST=false 9
10 pass generate ${ROFI_DATA} --clip 10 # If custom arguments for password generation is given
11 rofi -e "Generate and Copied: ${ROFI_DATA}" 11 # Set environment variable
12 ) 12 if [ ${ROFI_RETV} -eq 2 ]; then
13 13 extra_arguments="${1}"
14 [ "$1" == "${OPTIONS_NEW[2]}" ] && \ 14 fi
15 coproc ( 15
16 export POST=false 16 # Generate password in a new process
17 pass generate ${ROFI_DATA} --clip 17 # And Use current script to copy the values info X11 selections
18 rofi-sensible-terminal -e pass edit ${ROFI_DATA}; \ 18 coproc (
19 ) 19 pass generate ${PASSWORD} ${extra_arguments}
20 20 $0 ${PASSWORD}
21 exit 0 21 )
22
23 exit 0
22fi 24fi
23 25
24# Give rofi available passwords and exit 26# Give rofi available passwords and exit
25if [ $# -eq 0 ]; then 27if [ $# -eq 0 ]; then
26 # Specify rofi prompt as 'Get' 28 # Specify rofi prompt as 'Get'
27 echo -e "\0prompt\x1fGet" 29 echo -e "\0prompt\x1fGet"
28 30
29 find ~/.password-store -name '*gpg' -printf %P\\n | \ 31 find ~/.password-store -name '*gpg' -printf %P\\n | \
30 sed 's/.gpg$//' 32 sed 's/.gpg$//'
31 33
32 exit 0 34 exit 0
33fi 35fi
34 36
35# Test password exists or not 37# Test password exists or not
36RESULT="$(pass $1)" 38RESULT="$(pass $1)"
37if [ -n "$RESULT" ]; then 39if [ -n "$RESULT" ]; then
38 # Copy the given password into clipboard 40 # Copy the given password into PRIMARY selection and kill it in 30s
39 echo "$RESULT" | sed -n 1p | tr -d '\n' | xsel -i -t 30000 41 echo "$RESULT" | sed -n 1p | tr -d '\n' | xsel -i -t 30000
40 echo "$RESULT" | sed -n 2p | tr -d '\n' | xsel -ib 42 # Copy the second line (most of the time, account name) into CLIPBOARD selection
43 echo "$RESULT" | sed -n 2p | tr -d '\n' | xsel -ib
44
45 # And show extra message
46 EXTRA="$(echo; echo; echo "$RESULT" | sed '1d' | sed '1{/^$/d}')"
47 coproc ( rofi -e "Copied: $1$EXTRA" )
41 48
42 # And show extra message
43 EXTRA="$(echo; echo; echo "$RESULT" | sed '1d' | sed '1{/^$/d}')"
44 coproc ( rofi -e "Copied: $1$EXTRA" )
45# Password doesn't exist yet 49# Password doesn't exist yet
46# Go to next rofi execution 50# Go to next rofi execution
47else 51else
48 echo -e "\0prompt\x1f$1 doesn't exist, generate it?" 52 echo -e "\0prompt\x1f$1"
49 echo -e "\0data\x1f$1" 53 echo -e "\0message\x1fThis password doesn't exist, generate with custom arguments?"
50 54 echo -e "\0data\x1f$1"
51 for i in "${OPTIONS_NEW[@]}"; do 55 echo ${GENERATION_HINT}
52 echo $i
53 done
54fi 56fi