Skip to content

Commit

Permalink
Merge pull request #1351 from bynect/add-close-id
Browse files Browse the repository at this point in the history
Add an optional id to `dunstctl close`
  • Loading branch information
bynect authored May 3, 2024
2 parents 2c312c7 + 14ecba5 commit b00dca6
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 23 deletions.
16 changes: 8 additions & 8 deletions completions/_dunstctl.zshcomp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#compdef _dunstctl dunstctl

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

local curcontext="$curcontext" ret=1
Expand All @@ -17,20 +17,20 @@ case $state in
local -a commands
commands=(
'action:Perform the default action, or open the context menu of the notification at the given position'
'close:Close the last notification'
'close-all:Close the all notifications'
'close:Close the last notification or optionally the notification with given ID'
'close-all:Close all the notifications'
'context:Open context menu'
'count:Show the number of notifications'
'history:Display notification history (in JSON)'
'history-pop:Pop the latest notification from history or optionally the notification with given ID.'
'is-paused:Check if dunst is running or paused'
'history-pop:Pop the latest notification from history or optionally the notification with given ID'
'is-paused:Check if pause level is greater than 0'
'set-paused:Set the pause status'
'get-pause-level:Get current dunst's pause level'
'set-pause-level:Set current dunst's pause level'
'get-pause-level:Get the current pause level'
'set-pause-level:Set the pause level'
'rule:Enable or disable a rule by its name'
'rules:Displays configured rules'
'debug:Print debugging information'
'help:Show this help'
'help:Show help'
)
_describe commands commands && ret=0
;;
Expand Down
2 changes: 1 addition & 1 deletion completions/dunstctl.bashcomp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ _dunstctl() {
local opts cur prev
_get_comp_words_by_ref cur prev
COMPREPLY=()
opts='action close close-all context count debug help history history-clear history-pop history-rm is-paused rule rules set-paused'
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'

case "$prev" in
count) COMPREPLY=( $( compgen -W 'displayed history waiting' -- "$cur" ) )
Expand Down
12 changes: 7 additions & 5 deletions completions/dunstctl.fishcomp
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,25 @@ end

# commands
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'
complete -c dunstctl -f -n __fish_use_subcommand -a close -d 'Close the last notification'
complete -c dunstctl -f -n __fish_use_subcommand -a close-all -d 'Close the all notifications'
complete -c dunstctl -f -n __fish_use_subcommand -a close -d 'Close the last notification or optionally the notification with given ID'
complete -c dunstctl -f -n __fish_use_subcommand -a close-all -d 'Close all the notifications'
complete -c dunstctl -f -n __fish_use_subcommand -a context -d 'Open context menu'
complete -c dunstctl -f -n __fish_use_subcommand -a count -d 'Show the number of notifications'
complete -c dunstctl -f -n __fish_use_subcommand -a history -d 'Display notification history (in JSON)'
complete -c dunstctl -f -n __fish_use_subcommand -a history-clear -d 'Delete all notifications from history'
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'
complete -c dunstctl -f -n __fish_use_subcommand -a history-rm -d 'Remove the notification from history with given ID'
complete -c dunstctl -f -n __fish_use_subcommand -a is-paused -d 'Check if dunst is running or paused'
complete -c dunstctl -f -n __fish_use_subcommand -a is-paused -d 'Check if pause level is greater than 0'
complete -c dunstctl -f -n __fish_use_subcommand -a set-paused -d 'Set the pause status'
complete -c dunstctl -f -n __fish_use_subcommand -a get-pause-level -d 'Get the current pause level'
complete -c dunstctl -f -n __fish_use_subcommand -a set-pause-level -d 'Set the pause level'
complete -c dunstctl -f -n __fish_use_subcommand -a rules -d 'Displays configured rules (optionally in JSON)'
complete -c dunstctl -f -n __fish_use_subcommand -a rule -d 'Enable or disable a rule by its name'
complete -c dunstctl -f -n __fish_use_subcommand -a debug -d 'Print debugging information'
complete -c dunstctl -f -n __fish_use_subcommand -a help -d 'Show this help'
complete -c dunstctl -f -n __fish_use_subcommand -a help -d 'Show help'

# command specific arguments
complete -c dunstctl -x -n '__fish_seen_subcommand_from action close close-all context history history-clear is-paused debug help'
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'
complete -c dunstctl -x -n '__fish_seen_subcommand_from count' -a 'displayed history waiting'
complete -c dunstctl -x -n '__fish_seen_subcommand_from history-pop history-rm' -a '(__fish_dunstctl_info history id appname)'
complete -c dunstctl -x -n '__fish_seen_subcommand_from set-paused' -a 'true false toggle'
Expand Down
7 changes: 4 additions & 3 deletions docs/dunstctl.pod
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,16 @@ dunstctl COMMAND [PARAMETER]

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

=item B<close>
=item B<close> [ID]

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

=item B<close-all>

Close all notifications currently being displayed
Close all notifications currently being displayed.

=item B<context>

Expand Down
19 changes: 13 additions & 6 deletions dunstctl
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,27 @@ show_help() {
action Perform the default action, or open the
context menu of the notification at the
given position
close Close the last notification
close-all Close the all notifications
close [ID] Close the last notification or the
notification with given ID.
close-all Close all the notifications
context Open context menu
count [displayed|history|waiting] Show the number of notifications
history Display notification history (in JSON)
history-clear Delete all notifications from history
history-pop [ID] Pop the latest notification from
history or optionally the
notification with given ID.
notification with given ID
history-rm ID Remove the notification from
history with given ID.
is-paused Check if pause level is > 0
is-paused Check if pause level is greater than 0
set-paused true|false|toggle Set the pause status
get-pause-level Get the current pause level
set-pause-level level Set the pause level
rule name enable|disable|toggle Enable or disable a rule by its name
rules [--json] Displays configured rules (optionally
in JSON)
debug Print debugging information
help Show this help
help Show help
EOH
}
dbus_send_checked() {
Expand Down Expand Up @@ -66,7 +67,13 @@ case "${1:-}" in
method_call "${DBUS_IFAC_DUNST}.NotificationAction" "uint32:${2:-0}" >/dev/null
;;
"close")
method_call "${DBUS_IFAC_DUNST}.NotificationCloseLast" >/dev/null
if [ $# -eq 1 ]; then
method_call "${DBUS_IFAC_DUNST}.NotificationCloseLast" >/dev/null
elif [ $# -eq 2 ]; then
method_call "${DBUS_IFAC_FDN}.CloseNotification" "uint32:$2" >/dev/null
else
die "Please pass the right number of arguments. Close takes 0 or 1 arguments"
fi
;;
"close-all")
method_call "${DBUS_IFAC_DUNST}.NotificationCloseAll" >/dev/null
Expand Down

0 comments on commit b00dca6

Please sign in to comment.