parent
22d3634415
commit
3c6b8fd06c
5 changed files with 96 additions and 5 deletions
@ -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…
Reference in new issue