You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
1.3 KiB
44 lines
1.3 KiB
5 years ago
|
#!/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
|