Another copy of my dotfiles. Because I don't completely trust GitHub.
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.
 
 
 
 
 
 

55 lines
1.9 KiB

#!/usr/bin/env bash
shopt -s nullglob globstar
typeit=1
if [[ $1 == "--type" ]]; then
typeit=1
shift
fi
prefix=${PASSWORD_STORE_DIR-~/.password-store}
password_files=( "$prefix"/**/*.gpg )
password_files=( "${password_files[@]#"$prefix"/}" )
password_files=( "${password_files[@]%.gpg}" )
# Show urls open in firefox on top
open_urls="$($HOME/.local/bin/exfirefoxtabs.py | awk -F/ '{print $3}' | sort | uniq | sed 's/$//g' | sed ':a;N;$!ba;s/\n/|/g')"
pfiles="$(printf "%s\n" ${password_files[@]})"
list="$(echo "$pfiles" | grep -E "$open_urls")\n$(echo "$pfiles" | grep -Ev "$open_urls")"
entry=$(echo -e "$list" | dmenu -l 7 -p "Pass" -i "$@")
[[ -n $entry ]] || exit
action=$(echo -e "Login\nUsername\nPassword\nTOTP" | dmenu -p "Entry" -i )
case "$action" in
Login)
username=$(echo "$entry" | rev | cut -d"/" -f 1 | rev)
password=$(pass show "$entry")
printf %s "$username" | xargs | xdotool type --clearmodifiers --file -
xdotool key Tab
printf %s "$password" | { IFS= read -r pass; printf %s "$pass"; } | xargs |
xdotool type --clearmodifiers --file -
xdotool key Return
;;
Username)
username=$(echo "$entry" | rev | cut -d"/" -f 1 | rev)
printf %s "$username" | xclip -selection clipboard
printf %s "$username" | xargs | xdotool type --clearmodifiers --file -
notify-send -a " Password Manager" "Username copied to clipboard";;
Password)
password=$(pass show "$entry")
printf %s "$password" | xclip -selection clipboard
printf %s "$password" | { IFS= read -r pass; printf %s "$pass"; } | xargs |
xdotool type --clearmodifiers --file -
notify-send -a " Password Manager" "Password copied to clipboard";;
TOTP)
otp=$(pass otp "$entry")
printf %s "$otp" | xclip -selection clipboard
printf %s "$otp" | { IFS= read -r pass; printf %s "$pass"; } |
xdotool type --clearmodifiers --file -
notify-send -a " Password Manager" "TOTP copied to clipboard"
xdotool key Return
;;
esac