summaryrefslogtreecommitdiff
path: root/dmenu_keepass
diff options
context:
space:
mode:
authorzachir <zachir@librem.one>2022-08-12 04:30:51 -0500
committerzachir <zachir@librem.one>2022-08-12 04:30:51 -0500
commitc4d96716c05c41a3b18f2326cb588cd19246da5f (patch)
treeaa6b16c2e89ee63d37eb05e38577ec0b0bddea59 /dmenu_keepass
initial commit
Diffstat (limited to 'dmenu_keepass')
-rwxr-xr-xdmenu_keepass30
1 files changed, 30 insertions, 0 deletions
diff --git a/dmenu_keepass b/dmenu_keepass
new file mode 100755
index 0000000..d87a4c8
--- /dev/null
+++ b/dmenu_keepass
@@ -0,0 +1,30 @@
+#!/sbin/sh
+
+HAS_KEYFILE="y"
+
+PASS_DIR="$HOME/Pass"
+[ -n "$HAS_KEYFILE" ] && \
+ KEYFILE=`ls $PASS_DIR | barmenu $@ -p 'keyfile:'` && \
+ [ -n "$KEYFILE" ] && \
+ KEYFILE_FLAG="-k" && \
+ echo "$KEYFILE" || \
+ exit 2
+
+PASS_DB=`ls $PASS_DIR | barmenu $@ -p 'database:'` && \
+ [ -f "$PASS_DIR/$PASS_DB" ] &&
+ echo "$PASS_DB" || \
+ exit 1
+
+
+PASS_WD=`barmenu -P $@ -p 'password:'`
+
+PASS_LS=`echo "$PASS_WD" | keepassxc-cli ls -Rf "$KEYFILE_FLAG" "$PASS_DIR/$KEYFILE" "$PASS_DIR/$PASS_DB"`
+
+PASSWORD_SEL=`echo "$PASS_LS" | barmenu $@ -p password`
+
+PASS_ATTR=`echo "username\npassword" | barmenu $@ -p "which attribute to copy?"` && \
+ [ -z "$PASS_ATTR" ] && \
+ PASS_ATTR="password"
+
+echo "$PASS_WD" | keepassxc-cli clip -a "$PASS_ATTR" "$KEYFILE_FLAG" "$PASS_DIR/$KEYFILE" "$PASS_DIR/$PASS_DB" "$PASSWORD_SEL" 15
+