summary refs log tree commit diff
path: root/bin/notifmenu
diff options
context:
space:
mode:
authorRobert Günzler <r@gnzler.io>2026-02-10 12:32:48 +0100
committerRobert Günzler <r@gnzler.io>2026-02-10 12:41:25 +0100
commit63feeb9f369fc6176e85c1c2d8fcc863caad1946 (patch)
tree41cd5d2d1ec36e74e464caab722cc9b460153f04 /bin/notifmenu
parent5bd0a4aca65ecb9818ef1285982d160b6b6ff665 (diff)
start new
Signed-off-by: Robert Günzler <r@gnzler.io>
Diffstat (limited to 'bin/notifmenu')
-rwxr-xr-xbin/notifmenu117
1 files changed, 0 insertions, 117 deletions
diff --git a/bin/notifmenu b/bin/notifmenu
deleted file mode 100755
index 6b993a6..0000000
--- a/bin/notifmenu
+++ /dev/null
@@ -1,117 +0,0 @@
-#!/bin/sh
-
-set -e
-[ -n "$DEBUG" ] && set -x
-
-manual_actions_handling=
-act_on_history=
-while getopts mHh opt; do
-	case "$opt" in
-	# don't use makoctl menu ...
-	m) manual_actions_handling=1 ;;
-	H) act_on_history=1 ;;
-	h | ?)
-		printf 'usage: %s [-h]\n' "$(basename "$0")"
-		printf '\n'
-		printf '  -m    handle actions using bemenu instead of "makectl menu"\n'
-		printf '  -H    act on the history buffer, instead of active notifications\n'
-		printf "\n"
-		exit 2
-		;;
-	esac
-done
-shift $((OPTIND - 1))
-
-# check requirements
-for tool in makoctl jq bemenu; do
-	if ! command -v "$tool" >/dev/null; then
-		printf '%s: %s not installed but required\n' "$(basename "$0")" "$tool" >&2
-		exit 1
-	fi
-done
-
-export MENU_PROMPT="󰡟 notif"
-
-_menu() {
-	menu -l10 --ifne --accept-single "$@"
-}
-
-list_notifications() {
-	if [ -n "${act_on_history}" ]; then
-		makoctl history
-	else
-		makoctl list
-	fi
-}
-
-select_notification() {
-	while read -r line; do # actually only supports 1
-		id=$(printf '%s' "${line}" | awk -F'\t' '{print $1}')
-		list_notifications | jq -r ".. | select(.id?.data?==${id}) | @text"
-	done
-}
-
-handle() {
-	options="
-		dismiss
-		actions
-		$(if [ -n "${act_on_history}" ]; then printf restore; fi)
-	"
-	while read -r json; do
-		if [ -n "$DEBUG" ]; then printf '%s' "${json}" | jq; fi
-		for o in $options; do printf '%s\n' "$o"; done |
-			MENU_PROMPT="${MENU_PROMPT}: $(printf '%s' "${json}" | jq -r '.summary.data')" _menu |
-			{
-				read -r line
-				case ${line} in
-				dismiss) handle_dismiss "${json}" ;;
-				actions) handle_actions "${json}" ;;
-				restore) handle_restore "${json}" ;;
-				esac
-			}
-	done
-}
-
-handle_dismiss() {
-	id=$(printf '%s' "${1}" | jq -r '.id.data')
-	makoctl dismiss -n "${id}"
-}
-
-handle_restore() {
-	id=$(printf '%s' "${1}" | jq -r '.id.data')
-	makoctl restore -n "${id}"
-}
-
-handle_actions() {
-	id=$(printf '%s' "${1}" | jq -r '.id.data')
-
-	if [ -n "${manual_actions_handling}" ]; then
-		printf '%s' "${1}" | jq -r '.actions.data | to_entries | .[] | @text' |
-			_menu |
-			jq -r '.key' |
-			handle_action_manually "${id}"
-	else
-		exec makoctl menu -n "${id}" menu -l10
-	fi
-}
-
-handle_action_manually() {
-	id="$1"
-	while read -r action; do
-		printf 'print\ninvoke (using makoctl)\n' |
-			_menu --prefix "${action} >" |
-			{
-				read -r line
-				case ${line} in
-				print) printf '%s\n' "${action}" ;;
-				invoke*) exec makoctl invoke -n "${id}" "${action}" ;;
-				esac
-			}
-	done
-}
-
-list_notifications |
-	jq --arg id "${1}" -r '(..|select(.id?.data?==$id)) // .data[][] | [.id.data, ."app-name".data, .summary.data, .body.data] | @tsv' |
-	if [ -n "${1}" ]; then tac | tac; else _menu; fi |
-	select_notification |
-	handle