Skip to content

Commit b00dca6

Browse files
authored
Merge pull request #1351 from bynect/add-close-id
Add an optional id to `dunstctl close`
2 parents 2c312c7 + 14ecba5 commit b00dca6

File tree

5 files changed

+33
-23
lines changed

5 files changed

+33
-23
lines changed

completions/_dunstctl.zshcomp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#compdef _dunstctl dunstctl
22

3-
# ZSH arguments completion script for the dunstctl commnd
3+
# ZSH arguments completion script for the dunstctl command
44
# Depends on: gAWK (rule), jq (history-pop)
55

66
local curcontext="$curcontext" ret=1
@@ -17,20 +17,20 @@ case $state in
1717
local -a commands
1818
commands=(
1919
'action:Perform the default action, or open the context menu of the notification at the given position'
20-
'close:Close the last notification'
21-
'close-all:Close the all notifications'
20+
'close:Close the last notification or optionally the notification with given ID'
21+
'close-all:Close all the notifications'
2222
'context:Open context menu'
2323
'count:Show the number of notifications'
2424
'history:Display notification history (in JSON)'
25-
'history-pop:Pop the latest notification from history or optionally the notification with given ID.'
26-
'is-paused:Check if dunst is running or paused'
25+
'history-pop:Pop the latest notification from history or optionally the notification with given ID'
26+
'is-paused:Check if pause level is greater than 0'
2727
'set-paused:Set the pause status'
28-
'get-pause-level:Get current dunst's pause level'
29-
'set-pause-level:Set current dunst's pause level'
28+
'get-pause-level:Get the current pause level'
29+
'set-pause-level:Set the pause level'
3030
'rule:Enable or disable a rule by its name'
3131
'rules:Displays configured rules'
3232
'debug:Print debugging information'
33-
'help:Show this help'
33+
'help:Show help'
3434
)
3535
_describe commands commands && ret=0
3636
;;

completions/dunstctl.bashcomp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ _dunstctl() {
22
local opts cur prev
33
_get_comp_words_by_ref cur prev
44
COMPREPLY=()
5-
opts='action close close-all context count debug help history history-clear history-pop history-rm is-paused rule rules set-paused'
5+
opts='action close close-all context count debug help history history-clear history-pop history-rm is-paused rule rules set-paused get-pause-level set-pause-level'
66

77
case "$prev" in
88
count) COMPREPLY=( $( compgen -W 'displayed history waiting' -- "$cur" ) )

completions/dunstctl.fishcomp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,25 @@ end
1414

1515
# commands
1616
complete -c dunstctl -f -n __fish_use_subcommand -a action -d 'Perform the default action, or open the context menu of the notification at the given position'
17-
complete -c dunstctl -f -n __fish_use_subcommand -a close -d 'Close the last notification'
18-
complete -c dunstctl -f -n __fish_use_subcommand -a close-all -d 'Close the all notifications'
17+
complete -c dunstctl -f -n __fish_use_subcommand -a close -d 'Close the last notification or optionally the notification with given ID'
18+
complete -c dunstctl -f -n __fish_use_subcommand -a close-all -d 'Close all the notifications'
1919
complete -c dunstctl -f -n __fish_use_subcommand -a context -d 'Open context menu'
2020
complete -c dunstctl -f -n __fish_use_subcommand -a count -d 'Show the number of notifications'
2121
complete -c dunstctl -f -n __fish_use_subcommand -a history -d 'Display notification history (in JSON)'
2222
complete -c dunstctl -f -n __fish_use_subcommand -a history-clear -d 'Delete all notifications from history'
2323
complete -c dunstctl -f -n __fish_use_subcommand -a history-pop -d 'Pop the latest notification from history or optionally the notification with given ID'
2424
complete -c dunstctl -f -n __fish_use_subcommand -a history-rm -d 'Remove the notification from history with given ID'
25-
complete -c dunstctl -f -n __fish_use_subcommand -a is-paused -d 'Check if dunst is running or paused'
25+
complete -c dunstctl -f -n __fish_use_subcommand -a is-paused -d 'Check if pause level is greater than 0'
2626
complete -c dunstctl -f -n __fish_use_subcommand -a set-paused -d 'Set the pause status'
27+
complete -c dunstctl -f -n __fish_use_subcommand -a get-pause-level -d 'Get the current pause level'
28+
complete -c dunstctl -f -n __fish_use_subcommand -a set-pause-level -d 'Set the pause level'
2729
complete -c dunstctl -f -n __fish_use_subcommand -a rules -d 'Displays configured rules (optionally in JSON)'
2830
complete -c dunstctl -f -n __fish_use_subcommand -a rule -d 'Enable or disable a rule by its name'
2931
complete -c dunstctl -f -n __fish_use_subcommand -a debug -d 'Print debugging information'
30-
complete -c dunstctl -f -n __fish_use_subcommand -a help -d 'Show this help'
32+
complete -c dunstctl -f -n __fish_use_subcommand -a help -d 'Show help'
3133

3234
# command specific arguments
33-
complete -c dunstctl -x -n '__fish_seen_subcommand_from action close close-all context history history-clear is-paused debug help'
35+
complete -c dunstctl -x -n '__fish_seen_subcommand_from action close close-all context history history-clear is-paused get-pause-level set-pause-level debug help'
3436
complete -c dunstctl -x -n '__fish_seen_subcommand_from count' -a 'displayed history waiting'
3537
complete -c dunstctl -x -n '__fish_seen_subcommand_from history-pop history-rm' -a '(__fish_dunstctl_info history id appname)'
3638
complete -c dunstctl -x -n '__fish_seen_subcommand_from set-paused' -a 'true false toggle'

docs/dunstctl.pod

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,16 @@ dunstctl COMMAND [PARAMETER]
1515

1616
Performs the default action or, if not available, opens the context menu of the
1717
notification at the given position (starting count at the top, first
18-
notification being 0).
18+
notification being 0).
1919

20-
=item B<close>
20+
=item B<close> [ID]
2121

2222
Close the topmost notification currently being displayed.
23+
You can optionally pass an ID to close the matching notification (if present).
2324

2425
=item B<close-all>
2526

26-
Close all notifications currently being displayed
27+
Close all notifications currently being displayed.
2728

2829
=item B<context>
2930

dunstctl

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,26 +18,27 @@ show_help() {
1818
action Perform the default action, or open the
1919
context menu of the notification at the
2020
given position
21-
close Close the last notification
22-
close-all Close the all notifications
21+
close [ID] Close the last notification or the
22+
notification with given ID.
23+
close-all Close all the notifications
2324
context Open context menu
2425
count [displayed|history|waiting] Show the number of notifications
2526
history Display notification history (in JSON)
2627
history-clear Delete all notifications from history
2728
history-pop [ID] Pop the latest notification from
2829
history or optionally the
29-
notification with given ID.
30+
notification with given ID
3031
history-rm ID Remove the notification from
3132
history with given ID.
32-
is-paused Check if pause level is > 0
33+
is-paused Check if pause level is greater than 0
3334
set-paused true|false|toggle Set the pause status
3435
get-pause-level Get the current pause level
3536
set-pause-level level Set the pause level
3637
rule name enable|disable|toggle Enable or disable a rule by its name
3738
rules [--json] Displays configured rules (optionally
3839
in JSON)
3940
debug Print debugging information
40-
help Show this help
41+
help Show help
4142
EOH
4243
}
4344
dbus_send_checked() {
@@ -66,7 +67,13 @@ case "${1:-}" in
6667
method_call "${DBUS_IFAC_DUNST}.NotificationAction" "uint32:${2:-0}" >/dev/null
6768
;;
6869
"close")
69-
method_call "${DBUS_IFAC_DUNST}.NotificationCloseLast" >/dev/null
70+
if [ $# -eq 1 ]; then
71+
method_call "${DBUS_IFAC_DUNST}.NotificationCloseLast" >/dev/null
72+
elif [ $# -eq 2 ]; then
73+
method_call "${DBUS_IFAC_FDN}.CloseNotification" "uint32:$2" >/dev/null
74+
else
75+
die "Please pass the right number of arguments. Close takes 0 or 1 arguments"
76+
fi
7077
;;
7178
"close-all")
7279
method_call "${DBUS_IFAC_DUNST}.NotificationCloseAll" >/dev/null

0 commit comments

Comments
 (0)