diff options
-rw-r--r-- | misc/openbox/rc.xml | 2 | ||||
-rwxr-xr-x | tools/desktop/password-store.sh | 25 |
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 | |||
6 | ROFI_ARGS=( "-font" "Hack 22" ) | ||
7 | |||
3 | find ~/.password-store -name '*gpg' -printf %P\\n | \ | 8 | find ~/.password-store -name '*gpg' -printf %P\\n | \ |
4 | sed 's/.gpg$//' | \ | 9 | sed 's/.gpg$//' | \ |
5 | rofi -dmenu -font 'Hack 22' | { | 10 | rofi -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 | } |