Change some scripts a bit
This commit is contained in:
parent
297cb39020
commit
fdb2ed3606
5 changed files with 96 additions and 5 deletions
43
bin/.bin/dmenu/password-manager
Executable file
43
bin/.bin/dmenu/password-manager
Executable file
|
@ -0,0 +1,43 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
PASSWORDS="$HOME/.password-store"
|
||||
|
||||
|
||||
function copy_password(){
|
||||
local password="$1"
|
||||
local sleep_argv0="jh password store sleep on display $DISPLAY"
|
||||
local before="$(xclip -o -selection clipboard 2>/dev/null | base64)"
|
||||
pkill -f "^$sleep_argv0" 2>/dev/null && sleep 0.5
|
||||
local pw=$(pass "$selection" | head -n 1)
|
||||
echo "$pw" | xclip -selection "primary"
|
||||
echo "$pw" | xclip -selection "clipboard"
|
||||
notify-send "Password put on clipboard" "Will be removed in 10 seconds"
|
||||
(
|
||||
( exec -a "$sleep_argv0" bash <<<"trap 'kill %1' TERM; sleep '10' & wait" )
|
||||
|
||||
echo "$before" | base64 -d | xclip -selection "primary"
|
||||
echo "$before" | base64 -d | xclip -selection "clipboard"
|
||||
|
||||
notify-send "Password Clearerd"
|
||||
|
||||
) >/dev/null 2>&1 & disown
|
||||
}
|
||||
|
||||
if [ -d "$PASSWORDS" ]; then
|
||||
cd "$PASSWORDS"
|
||||
selection=$((echo "NEW";find . -type f -name '*.gpg' | sed 's/.gpg$//' | sed 's/^.\///') | rofi -dmenu -i -l 20)
|
||||
if [ -n "$selection" ]; then
|
||||
if [[ "$selection" == "NEW" ]]; then
|
||||
dir="$(find . -type d -not -path \*.git\* |rofi -dmenu -p Directory | sed 's/^.\/?//')"
|
||||
if [ ! -d "$dir" ]; then
|
||||
mkdir -p "$dir"
|
||||
fi
|
||||
name="$(rofi -dmenu -p Name -lines 0)"
|
||||
# Todo - create new passwords
|
||||
else
|
||||
copy_password "$selection"
|
||||
fi
|
||||
fi
|
||||
else
|
||||
notify-send "$BOOKMARKS doesn't exist"
|
||||
fi
|
Loading…
Add table
Add a link
Reference in a new issue