diff options
| author | Danilo M. <danix@danix.xyz> | 2026-10-18 11:42:52 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-10-18 11:42:52 +0200 |
| commit | 1d527c4e47514540541abf57aa1adb6a14ae5b54 (patch) | |
| tree | dde8c34cd5e7f25291962d5a6e1bca5ac6631b5d /bin/notify-actions.sh | |
| download | rofi-scripts-1d527c4e47514540541abf57aa1adb6a14ae5b54.tar.gz rofi-scripts-1d527c4e47514540541abf57aa1adb6a14ae5b54.zip | |
Initial commit: rofi-scripts, the scripts behind the rofi menus
Power menu, launcher, screenshot picker, SSH host cards, pass browser,
emoji picker, Firefox profile picker, notification actions and an
sd-server model picker. install.sh symlinks them into ~/bin; their
layouts come from unified-desktop-theme.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'bin/notify-actions.sh')
| -rwxr-xr-x | bin/notify-actions.sh | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/bin/notify-actions.sh b/bin/notify-actions.sh new file mode 100755 index 0000000..0c49c6b --- /dev/null +++ b/bin/notify-actions.sh @@ -0,0 +1,41 @@ +#!/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" \ + -theme "$HOME/.config/rofi/udt/menu.rasi")" +[[ -n "$choice" ]] || exit 0 + +for i in "${!labels[@]}"; do + if [[ "${labels[$i]}" == "$choice" ]]; then + notifyctl action "$id" "${keys[$i]}" + exit $? + fi +done |
