summaryrefslogtreecommitdiff
path: root/dgenpass
diff options
context:
space:
mode:
Diffstat (limited to 'dgenpass')
-rwxr-xr-xdgenpass29
1 files changed, 29 insertions, 0 deletions
diff --git a/dgenpass b/dgenpass
new file mode 100755
index 0000000..4f802ce
--- /dev/null
+++ b/dgenpass
@@ -0,0 +1,29 @@
+#!/bin/sh
+
+PASSWORD_LENGTH=24
+DMENU_PROMPT="Enter password name:"
+NOTIFY_TITLE="dgenpass"
+
+# Ask for a password name
+name=$(echo "" | dmenu -i -p "$DMENU_PROMPT")
+
+# Exit if user cancels
+[ -z "$name" ] && exit 1
+
+# Generate random password
+password=$(tr -dc 'A-Za-z0-9!@#$%^&*()_+-=' </dev/urandom | head -c "$PASSWORD_LENGTH")
+
+# Save to pass
+echo "$password" | pass insert -f -m "$name"
+
+# Copy to clipboard
+if command -v xclip >/dev/null 2>&1; then
+ echo -n "$password" | xclip -selection clipboard
+elif command -v wl-copy >/dev/null 2>&1; then
+ echo -n "$password" | wl-copy
+fi
+
+# Notify user
+if command -v notify-send >/dev/null 2>&1; then
+ notify-send "$NOTIFY_TITLE" "Password for '$name' saved and copied to clipboard"
+fi