summaryrefslogtreecommitdiff
path: root/.local/bin/dmenupass
diff options
context:
space:
mode:
author0scar <qgt268@alumni.ku.dk>2025-02-13 16:50:30 +0000
committer0scar <qgt268@alumni.ku.dk>2025-02-13 16:50:30 +0000
commit671c1608210ab47858da8ee7729ea81ce29a79e7 (patch)
treee11a36ce07357a467c56353739cc17e3f52c9f35 /.local/bin/dmenupass
parente8d5c7f03b2fabd63cb87e26c303e73e0782ef17 (diff)
Add some scripts
Diffstat (limited to '.local/bin/dmenupass')
-rwxr-xr-x.local/bin/dmenupass42
1 files changed, 42 insertions, 0 deletions
diff --git a/.local/bin/dmenupass b/.local/bin/dmenupass
new file mode 100755
index 0000000..11b1822
--- /dev/null
+++ b/.local/bin/dmenupass
@@ -0,0 +1,42 @@
+#!/usr/bin/sh
+
+getpswds() {
+ RET=$(pass ls | sed -E '/^[A-Z]/d;s/[└├](─)* //g;s/(\[0+m)//g' | fzf)
+ [ -z "${RET}" ] && exit 0
+ echo -en "${RET}"
+}
+
+show() {
+ PSWD=$1
+ [ -z "$PSWD" ] && PSWD=$(getpswds)
+ # Necessary in order to allow pasting and not immediately closing the thing
+ pass show -c "$PSWD"
+ notify-send -t 5000 "Pass" "Copied $PSWD to clipboard"
+ sleep 30
+}
+
+add() {
+ clear
+ echo -n "Name for new password: "
+ read PSWDNAME
+ [ -z "${PSWDNAME}" ] && exit 0
+ pass insert "${PSWDNAME}"
+}
+
+options() {
+ RET=$(echo -e "ls\nshow\ninsert\nadd" | sort | fzf)
+ [ -z "${RET}" ] && exit 0
+ echo -en "${RET}"
+}
+
+CMD="${1}"
+
+[ -z "${CMD}" ] && CMD=$(options)
+
+
+case "${CMD}" in
+ ls) getpswds >/dev/null;;
+ show) show;;
+ insert) add;;
+ add) add;;
+esac