blob: 0c49c6bbabd4ed133d74db51944854ea8c7a89ba (
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
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
|