diff options
author | Yaroslav <contact@yaroslavps.com> | 2020-07-05 09:25:36 +0300 |
---|---|---|
committer | Yaroslav <contact@yaroslavps.com> | 2020-07-05 09:25:36 +0300 |
commit | c56d9b728981f89bfe1c49eba33480dc3dcb0f9c (patch) | |
tree | 1a95ee10fb2912f856878cc24abebce52522886b /dotfiles | |
parent | 0f22fcc301420ebec1d1313d1ff803311206afed (diff) | |
download | swayrice-c56d9b728981f89bfe1c49eba33480dc3dcb0f9c.tar.gz swayrice-c56d9b728981f89bfe1c49eba33480dc3dcb0f9c.zip |
bemenu script for pass password manager
Diffstat (limited to 'dotfiles')
-rw-r--r-- | dotfiles/.config/sway/config | 2 | ||||
-rwxr-xr-x | dotfiles/.local/bin/menupass | 40 |
2 files changed, 42 insertions, 0 deletions
diff --git a/dotfiles/.config/sway/config b/dotfiles/.config/sway/config index e57fcc5..30df794 100644 --- a/dotfiles/.config/sway/config +++ b/dotfiles/.config/sway/config @@ -184,6 +184,8 @@ bindsym --to-code { $mod+grave exec --no-startup-id menuemoji $mod+Ctrl+grave exec --no-startup-id menuwebsurf $mod+Shift+grave exec --no-startup-id menuwebsurf paste + $mod+apostrophe exec --no-startup-id menupass + $mod+Shift+apostrophe exec --no-startup-id "menupass --type" # Network management $mod+Shift+c exec togglevpn diff --git a/dotfiles/.local/bin/menupass b/dotfiles/.local/bin/menupass new file mode 100755 index 0000000..dad8023 --- /dev/null +++ b/dotfiles/.local/bin/menupass @@ -0,0 +1,40 @@ +#!/usr/bin/sh + +# Taken from https://git.zx2c4.com/password-store/tree/contrib/dmenu/passmenu +# and modified + +# Source settings from .bemenurc +. ~/.config/bemenurc + +shopt -s nullglob globstar + +title="Copy password to clipboard" +typeit=0 +if [[ $1 == "--type" ]]; then +title="Show and copy password to clipboard" + typeit=1 + shift +fi + +prefix=${PASSWORD_STORE_DIR-~/.password-store} +password_files=( "$prefix"/**/*.gpg ) +password_files=( "${password_files[@]#"$prefix"/}" ) +password_files=( "${password_files[@]%.gpg}" ) + +password=$(printf '%s\n' "${password_files[@]}" | bemenu -p "$title:" --tf="$BEMENU_TF" --tb="$BEMENU_NB" --fb="$BEMENU_NB" --fn="$BEMENU_FN" --nb="$BEMENU_NB" --nf="$BEMENU_NF" --hf="$BEMENU_HF" --hb="$BEMENU_HB") + +[[ -n $password ]] || exit + +oldclip=$(wl-paste) +thepassword=$(pass show "$password") +wl-copy "$thepassword" + +if [[ $typeit -eq 0 ]]; then + notify-send "🔑 Password store" "The password for $password has been copied to the clipboard and will be cleared in 30 seconds" +else + notify-send "🔑 Password store" "Password for $password: $thepassword" +fi + +sleep 30 +wl-copy $oldclip +notify-send "🔑 Password store" "Password cleared from clipboard" |