diff options
| author | Danilo M. <danix@danix.xyz> | 2026-09-15 14:34:46 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-09-15 14:34:46 +0200 |
| commit | fe1c0524c87118b1171c6549c68d7fbb701c61ab (patch) | |
| tree | f59ab34478ac11c634748646aca1145bf2bb41ae | |
| parent | 2c15d79296380a3c46da560484daaf5ac7b2a869 (diff) | |
| download | quickshell-fe1c0524c87118b1171c6549c68d7fbb701c61ab.tar.gz quickshell-fe1c0524c87118b1171c6549c68d7fbb701c61ab.zip | |
feat(notifications): add the rofi action picker
The renderer passes the action labels and keys as arguments, so the picker
parses no JSON; a chosen label maps to its key and runs notifyctl action.
| -rwxr-xr-x | notifications/notify-actions.sh | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/notifications/notify-actions.sh b/notifications/notify-actions.sh new file mode 100755 index 0000000..651275c --- /dev/null +++ b/notifications/notify-actions.sh @@ -0,0 +1,40 @@ +#!/bin/bash +# +# Copyright (C) 2026 Danilo M. <danix@danix.xyz> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# Pick one of a notification's actions with rofi and invoke it. The renderer +# passes the labels and keys as arguments, so nothing here parses JSON. +# +# notify-actions.sh <id> <label> <key> [label key ...] + +set -u + +[[ $# -ge 3 ]] || { echo "usage: ${0##*/} <id> <label> <key> ..." >&2; exit 2; } + +id="$1"; shift +labels=() +keys=() +while [[ $# -ge 2 ]]; do + labels+=("$1") + keys+=("$2") + shift 2 +done + +choice="$(printf '%s\n' "${labels[@]}" | rofi -dmenu -i -p "Notification")" +[[ -n "$choice" ]] || exit 0 + +for i in "${!labels[@]}"; do + if [[ "${labels[$i]}" == "$choice" ]]; then + notifyctl action "$id" "${keys[$i]}" + exit $? + fi +done |
