aboutsummaryrefslogtreecommitdiff
path: root/dmenu-memo
diff options
context:
space:
mode:
authorLukasz Kasprzak <lukasz.kasprzak@pm.me>2026-01-29 01:27:17 +0100
committerLukasz Kasprzak <lukasz.kasprzak@pm.me>2026-01-29 01:27:17 +0100
commit70e6d80c2d367480478eacf46363ee88a0e994ff (patch)
tree3585660271002a776a8756994c92f8e546f98044 /dmenu-memo
parent646bb0d8df0e720c966dc2992dcf7fe1154d17cf (diff)
downloadbin-70e6d80c2d367480478eacf46363ee88a0e994ff.tar.gz
bin-70e6d80c2d367480478eacf46363ee88a0e994ff.zip
added lots of new dmenu scripts
Diffstat (limited to 'dmenu-memo')
-rwxr-xr-xdmenu-memo46
1 files changed, 46 insertions, 0 deletions
diff --git a/dmenu-memo b/dmenu-memo
new file mode 100755
index 0000000..597f191
--- /dev/null
+++ b/dmenu-memo
@@ -0,0 +1,46 @@
+#!/usr/bin/env bash
+set -euo pipefail
+
+OUTFILE="${OUTFILE:-$HOME/.notes}"
+DMENU="${DMENU:-dmenu}"
+PROMPT="${PROMPT:-Memo: }"
+
+# Optional dmenu theming
+# shellcheck disable=SC1090
+[[ -r "${HOME}/.local/bin/dmenu-theming" ]] && . "${HOME}/.local/bin/dmenu-theming"
+
+notify() {
+ # $1: urgency (low|normal|critical), $2: message
+ if command -v notify-send >/dev/null 2>&1; then
+ notify-send -u "$1" "dmenu-memo" "$2"
+ fi
+}
+
+die() {
+ notify critical "$1"
+ exit 1
+}
+
+# dmenu returns non-zero on ESC; treat as cancel
+note="$(
+ printf "" \
+ | ${DMENU} -p "$PROMPT" ${lines:-} ${colors:-} ${font:-} \
+ || true
+)"
+
+# Cancel / empty input: notify low, then exit quietly
+if [[ -z "${note}" ]]; then
+ notify low "Cancelled (empty memo)"
+ exit 0
+fi
+
+ts="$(date '+%y:%m:%d %H:%M:%S')"
+
+{
+ printf -- "# %s\n" "$ts"
+ printf -- "%s\n" "$note"
+ printf -- "---\n"
+} >> "$OUTFILE" || die "Failed to write to $OUTFILE"
+
+notify normal "Saved to ~/.notes"
+