aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorHsieh Chin Fan <pham@topo.tw>2022-09-27 23:34:21 +0800
committerHsieh Chin Fan <pham@topo.tw>2022-09-27 23:45:00 +0800
commit3556eb2403cb89a9c164e4eabe323507a1b9ac2b (patch)
tree7eec71c6a2fbe06b6c783410d49221583162402c
parentdd97e761a8b354e09c27ef604d27a3bbaa27b2e2 (diff)
Improve script for password
-rw-r--r--misc/openbox/rc.xml2
-rwxr-xr-xtools/desktop/password-store.sh25
2 files changed, 20 insertions, 7 deletions
diff --git a/misc/openbox/rc.xml b/misc/openbox/rc.xml
index bd1baa6..2d0c994 100644
--- a/misc/openbox/rc.xml
+++ b/misc/openbox/rc.xml
@@ -583,7 +583,7 @@
583 </keybind> 583 </keybind>
584 <keybind key="W-p"> 584 <keybind key="W-p">
585 <action name="Execute"> 585 <action name="Execute">
586 <command>~/helper/tools/desktop/password-store.sh</command> 586 <command>~/bin/password-store.sh</command>
587 </action> 587 </action>
588 </keybind> 588 </keybind>
589 <!-- CLI Apps --> 589 <!-- CLI Apps -->
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}