From ba6ee9bd994c7342429256fdf5c662bc95125288 Mon Sep 17 00:00:00 2001 From: tavo-wasd Date: Fri, 5 Jan 2024 19:32:08 -0600 Subject: [PATCH] modular password management --- .gitignore | 1 + scripts/menu/menu | 16 ++++++++++++++-- scripts/menu/menu-pass | 14 +++----------- shell/aliasrc | 3 +-- wrappers/passc | 4 ++++ wrappers/passw | 4 ++++ wrappers/passx | 4 ++++ 7 files changed, 31 insertions(+), 15 deletions(-) create mode 100755 wrappers/passc create mode 100755 wrappers/passw create mode 100755 wrappers/passx diff --git a/.gitignore b/.gitignore index 7aeaf04..0dba011 100644 --- a/.gitignore +++ b/.gitignore @@ -200,3 +200,4 @@ ksslcertificatemanager kwalletmanager5rc soffice.binrc systemmonitorrc +menu-config diff --git a/scripts/menu/menu b/scripts/menu/menu index 7a40e1c..61d8127 100755 --- a/scripts/menu/menu +++ b/scripts/menu/menu @@ -4,7 +4,7 @@ PROMPT="$1" ; MODE="$2" # Configuration -MENU="dmenu" +MENU="fzf" # Default to fzf col_nb="#121212" # Normal background col_nf="#665c54" # Normal foreground col_sb="#d3869b" # Selected background @@ -12,6 +12,8 @@ col_sf="#121212" # Selected foreground font="JetbrainsMono" font_size="10" +[ -e "$HOME/.config/menu-config" ] && MENU="$(cat "$HOME/.config/menu-config")" + # Print help if [ "$PROMPT" = "" -o "$PROMPT" = "-h" ] ; then printf "Usage: menu [prompt] [run/pass/empty]" @@ -51,7 +53,6 @@ BEMENU_OPTS=" \ # dmenu opts DMENU_OPTS=" \ - -c \ -i \ -l 10 \ -nb $col_nb \ @@ -63,6 +64,12 @@ DMENU_OPTS=" \ $DPASS \ " +# dmenu opts +FZF_OPTS=" \ + --cycle \ + --reverse \ +" + # If chosen bemenu, use this args [ "$MENU" = "bemenu" ] && OPTS="$BEMENU_OPTS" && @@ -73,6 +80,11 @@ DMENU_OPTS=" \ OPTS="$DMENU_OPTS" && RUN="_run" +# If chosen fzf, use this args +[ "$MENU" = "fzf" ] && + OPTS="$FZF_OPTS" && + RUN="" + [ "$MODE" = "run" ] && $MENU$RUN $OPTS [ "$MODE" = "pass" ] && < /dev/null | $MENU $OPTS [ "$MODE" = "empty" ] && < /dev/null | $MENU $OPTS diff --git a/scripts/menu/menu-pass b/scripts/menu/menu-pass index c9fb637..0779718 100755 --- a/scripts/menu/menu-pass +++ b/scripts/menu/menu-pass @@ -1,15 +1,7 @@ #!/bin/sh -# Script for 'pass' - +# menu for 'pass' PASSWORD_STORE_DIR="$XDG_DATA_HOME/password-store" -# Ask for password name in vault -password="$(find "$PASSWORD_STORE_DIR" -type f -name '*.gpg' | - sed "s@$PASSWORD_STORE_DIR/@@g ; s@.gpg@@g" | menu "Password:")" +password="$(find "$PASSWORD_STORE_DIR" -type f -name '*.gpg' | sed "s@$PASSWORD_STORE_DIR/@@g ; s@.gpg@@g" | menu "Password:")" -# Exit if none chosen -[ -z "$password" ] && exit - -# If chosen, use xdotool to type it -xdotool type "$(pass $password | head -1)" && - [ -e /usr/bin/notify-send ] && notify-send " $password" "Successfully decrypted" +! [ -z "$password" ] && printf '%s' "$password" diff --git a/shell/aliasrc b/shell/aliasrc index 2eaf71e..2baaf18 100644 --- a/shell/aliasrc +++ b/shell/aliasrc @@ -16,10 +16,9 @@ alias \ vid="cd $HOME/Videos/ && ls" \ # Common - alias \ ll="exa -al --group-directories-first" \ - ls="ls -Alh --color=auto" \ + ls="ls -A --color=auto" \ fzf="fzf --cycle --reverse" \ diff="diff --color=auto" \ grep="grep --color=auto" \ diff --git a/wrappers/passc b/wrappers/passc new file mode 100755 index 0000000..a8345de --- /dev/null +++ b/wrappers/passc @@ -0,0 +1,4 @@ +#!/bin/sh + +PASS="$(menu-pass)" +pass -c "$PASS" diff --git a/wrappers/passw b/wrappers/passw new file mode 100755 index 0000000..4f26807 --- /dev/null +++ b/wrappers/passw @@ -0,0 +1,4 @@ +#!/bin/sh + +PASS="$(menu-pass)" +pass "$PASS" | head -n 1 | wtype - diff --git a/wrappers/passx b/wrappers/passx new file mode 100755 index 0000000..ff6953e --- /dev/null +++ b/wrappers/passx @@ -0,0 +1,4 @@ +#!/bin/sh + +PASS="$(menu-pass)" +xdotool type "$(pass "$PASS" | head -n 1)"