blob: 651275c68034a231e52dedd3be7fcc1b309cc0ee (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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
|