aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFederico Angelilli <code@fedang.net>2024-01-19 10:54:30 +0100
committerFederico Angelilli <code@fedang.net>2024-01-19 10:58:38 +0100
commit5942f372315cfdf39aae8a6b74188503b6f11b0e (patch)
tree775f1256e6f19b5d3ce5e6762895bbd19f3518e9
parentdc3d7f95d9fdc2bf58ef9f9552ff26a2a73d1d47 (diff)
Add cryptmenu script (dmenu integration)
-rw-r--r--README2
-rwxr-xr-xcrypt.sh4
-rwxr-xr-xcryptmenu.sh23
3 files changed, 26 insertions, 3 deletions
diff --git a/README b/README
index 5e83114..8c067b9 100644
--- a/README
+++ b/README
@@ -3,4 +3,4 @@ Every file can be associated with actions (insert, edit, show, etc).
For example, you can have password entries and otp entries, the former being
copied to your clipboard when selected and the latter generating their code.
Or you could simply use it as a safe to keep your annotations.
-It is really up to you how you want to configure your crypt's configuration.
+It is really up to you how you want to configure your crypt.
diff --git a/crypt.sh b/crypt.sh
index 9d9c250..14c651c 100755
--- a/crypt.sh
+++ b/crypt.sh
@@ -714,7 +714,7 @@ cmd_list() {
if [ $plain -eq 0 ]; then
local header="Crypt ($PRETTY_PATH)"
- [[ $CLOSED -eq 1 ]] && printf "%s\n%s\n" "$header" "$(_color gray,bold)Closed 🔒$(_color reset)" && return
+ [[ $CLOSED -eq 1 ]] && printf "%s\n%s\n" "$header" "$(_color gray,bold)Closed 🔒$(_color reset)" && exit 1
if [[ -n "$1" && "$1" != $CRYPT_PATH ]]; then
local color="" reset=""
@@ -727,7 +727,7 @@ cmd_list() {
tree -f --noreport -l "$path" "${args[@]}" -I '*.sig' | tail -n +2 | while IFS='' read -r line; do _cmd_list_fmt "$line"; done | \
column -t -s$'\t' | sed 's/\v/\t\t/' # Make pretty columns
else
- [[ $CLOSED -eq 1 ]] && return
+ [[ $CLOSED -eq 1 ]] && exit 1
local tmp=$(find "$path" -path '*/.git' -prune -o -path '*/.extensions' -prune -o -iname '*.gpg' -print | \
sed -e "s~^$path\/*~~" | sort | while IFS='' read -r line; do \
diff --git a/cryptmenu.sh b/cryptmenu.sh
new file mode 100755
index 0000000..c99a155
--- /dev/null
+++ b/cryptmenu.sh
@@ -0,0 +1,23 @@
+#!/bin/sh
+#
+# Script with a dmenu integration for crypt
+
+set -o pipefail
+
+typeit=0
+if [[ $1 == "--type" ]]; then
+ typeit=1
+ shift
+fi
+
+list=$(crypt list --plain | awk '{print $1"["$2"]"}')
+[[ -n "$list" ]] || exit 1
+name=$(echo "$list" | dmenu "$@" | sed 's/\(\.*\)\[.*\]/\1/')
+[[ -n "$name" ]] || exit
+
+if [[ $typeit -eq 0 ]]; then
+ # FIXME: clear the clipboard
+ crypt show $name | xclip -selection clipboard
+else
+ crypt show $name | { IFS= read -r line; printf %s "$line"; } | xdotool type --clearmodifiers --file -
+fi