2022-12-23 03:43:57 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
2023-03-12 02:40:37 +00:00
|
|
|
[ -z "$PFILE" ] && PFILE="$HOME/.files/pass.gpg"
|
2022-12-23 03:43:57 +00:00
|
|
|
|
|
|
|
|
|
|
|
mkpass() {
|
|
|
|
echo "enter password to store encrypted: "
|
|
|
|
read input
|
|
|
|
|
|
|
|
echo "$input" | gpg -c > "$PFILE"
|
|
|
|
|
|
|
|
echo "password file: $PFILE created. call script without args to get the password. Run -i again on the same file to change password."
|
|
|
|
}
|
|
|
|
|
|
|
|
getpass() {
|
|
|
|
gpg -d "$PFILE" 2>/dev/null
|
|
|
|
}
|
|
|
|
|
|
|
|
getpass_clipboard() {
|
|
|
|
wl-copy "$(getpass)"
|
|
|
|
notify-send "get-pass.sh" "Password copied to clipboard. Clearing clipboard in 10 seconds"
|
|
|
|
sleep 10
|
|
|
|
wl-copy --clear
|
|
|
|
notify-send "get-pass.sh" "Clipboard cleared"
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if [ "$1" = "-i" ]; then
|
|
|
|
mkpass
|
|
|
|
elif [ "$1" = "-c" ]; then
|
|
|
|
getpass_clipboard
|
|
|
|
else
|
|
|
|
if [ -f "$PFILE" ]; then
|
|
|
|
getpass
|
|
|
|
else
|
|
|
|
echo "password file: $PFILE not found. create with get-pass.sh -i"
|
|
|
|
fi
|
|
|
|
fi
|