From 6f76248af85a6efed79c000334ce0488d7fdec8e Mon Sep 17 00:00:00 2001 From: Jonathan Hodgson Date: Wed, 11 Mar 2020 11:45:16 +0000 Subject: [PATCH] Adds the option to type a passord in password manager --- bin/.bin/dmenu/password-manager | 17 +++++++++++++++-- bin/.bin/dmenu/rofi-background | 15 +++++++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) create mode 100755 bin/.bin/dmenu/rofi-background diff --git a/bin/.bin/dmenu/password-manager b/bin/.bin/dmenu/password-manager index 4fed9779..83d4bded 100755 --- a/bin/.bin/dmenu/password-manager +++ b/bin/.bin/dmenu/password-manager @@ -3,6 +3,15 @@ PASSWORDS="$HOME/.password-store" +function type_password(){ + local password="$1" + local pw=$(pass "$password" | head -n 1) + if [ -z "$pw" ]; then + exit 1 + fi + sleep 1 + echo "$pw" | xdotool type --clearmodifiers --file - +} function copy_password(){ local password="$1" local part="${2:-0}" @@ -40,7 +49,7 @@ if [ -d "$PASSWORDS" ]; then selection="$1" ret="${2:-0}" if [ -z "$selection" ]; then - selection=$((find . -type f -name '*.gpg' | sed 's/.gpg$//' | sed 's/^.\///') | rofi -dmenu -kb-custom-1 "Ctrl-o" -i -l 20) + selection=$((find . -type f -name '*.gpg' | sed 's/.gpg$//' | sed 's/^.\///') | rofi -dmenu -kb-custom-1 "Ctrl-o" -kb-custom-2 "Ctrl-i" -i -l 20) ret="$?" fi if [ -n "$selection" ]; then @@ -52,7 +61,11 @@ if [ -d "$PASSWORDS" ]; then name="$(rofi -dmenu -p Name -lines 0)" # Todo - create new passwords else - copy_password "$selection" "$ret" + if [ "$ret" -ne "11" ]; then + copy_password "$selection" "$ret" + else + type_password "$selection" "$ret" + fi fi fi else diff --git a/bin/.bin/dmenu/rofi-background b/bin/.bin/dmenu/rofi-background new file mode 100755 index 00000000..6cc33410 --- /dev/null +++ b/bin/.bin/dmenu/rofi-background @@ -0,0 +1,15 @@ +#!/usr/bin/env bash + +case "$(echo -e "default\nfilm\nearth" | rofi -dmenu)" in + default) + feh --bg-fill "$HOME/Pictures/background" + ;; + earth) + background --notify --earth + ;; + film) + dir="$HOME/Videos/wallpaper-candidates/" + background --film $( ls "$dir" | rofi -dmenu ) + ;; +esac +