From a09005fd585a752ca7f0f6c04c7f650d9b97648f Mon Sep 17 00:00:00 2001 From: Alex Date: Thu, 22 Dec 2022 21:43:57 -0600 Subject: [PATCH] create program get-pass.sh that will save a password encrypted allow the user to access it by calling the script. --- get-pass.sh | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100755 get-pass.sh diff --git a/get-pass.sh b/get-pass.sh new file mode 100755 index 0000000..8132d17 --- /dev/null +++ b/get-pass.sh @@ -0,0 +1,38 @@ +#!/bin/sh + +[ -z "$PFILE" ] && PFILE="$HOME/.local/share/pass.gpg" + + +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