aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/desktop/password-store.sh
diff options
context:
space:
mode:
Diffstat (limited to 'tools/desktop/password-store.sh')
-rwxr-xr-xtools/desktop/password-store.sh25
1 files changed, 19 insertions, 6 deletions
diff --git a/tools/desktop/password-store.sh b/tools/desktop/password-store.sh
index e83529b..4d3759e 100755
--- a/tools/desktop/password-store.sh
+++ b/tools/desktop/password-store.sh
@@ -1,19 +1,32 @@
1#! /bin/bash 1#! /bin/bash
2 2
3# Use rofi to quickly access password by command 'pass'
4# xsel needed !!
5
6ROFI_ARGS=( "-font" "Hack 22" )
7
3find ~/.password-store -name '*gpg' -printf %P\\n | \ 8find ~/.password-store -name '*gpg' -printf %P\\n | \
4sed 's/.gpg$//' | \ 9sed 's/.gpg$//' | \
5rofi -dmenu -font 'Hack 22' | { 10rofi -dmenu "${ROFI_ARGS[@]}" | {
11 # Get arguments for command 'pass'
6 read ARG1 ARG2 12 read ARG1 ARG2
7 if [[ $ARG1 =~ gen ]]; then 13
14 if [[ -z $ARG1 ]]; then
15 exit 1
16 elif [[ $ARG1 =~ gen ]]; then
8 # Generate a new password by ARG2 17 # Generate a new password by ARG2
9 alacritty --hold -e pass generate $ARG2 18 alacritty --hold -e pass --clip generate $ARG2
10 else 19 else
11 pass $ARG1 | { 20 pass $ARG1 | {
12 read PASSWORD 21 # If command fails, just fail directly
22 read PASSWORD; [[ -z $PASSWORD ]] && exit 1
23
24 # Simply copy password into system clipboard
13 echo $PASSWORD | xsel -ib 25 echo $PASSWORD | xsel -ib
14 26
15 rofi -e "Password Copied: $ARG1 $(echo; echo; cat | sed '1{/^$/d}')" \ 27 # Show success message, and display extra contents
16 -font 'Hack 22' 28 rofi -e "Copied: $ARG1 $(echo; echo; cat | sed '1{/^$/d}')" \
29 "${ROFI_ARGS[@]}"
17 } 30 }
18 fi 31 fi
19} 32}