From 9e5aaf05856454bdc32645bb4b5d16134844c8ba Mon Sep 17 00:00:00 2001 From: bynect <68197565+bynect@users.noreply.github.com> Date: Thu, 2 May 2024 20:08:08 +0200 Subject: [PATCH 1/2] Add an optional id to `dunstctl close` --- docs/dunstctl.pod | 5 +++-- dunstctl | 11 +++++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/docs/dunstctl.pod b/docs/dunstctl.pod index 626972674..c85130480 100644 --- a/docs/dunstctl.pod +++ b/docs/dunstctl.pod @@ -15,11 +15,12 @@ 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 +=item B [ID] Close the topmost notification currently being displayed. +You can optionally pass an ID to close the matching notification (if present). =item B diff --git a/dunstctl b/dunstctl index 97f2dc733..94d33dbbf 100755 --- a/dunstctl +++ b/dunstctl @@ -18,7 +18,8 @@ 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 [ID] Close the last notification or the + notification with given ID. close-all Close the all notifications context Open context menu count [displayed|history|waiting] Show the number of notifications @@ -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 From 14ecba5d44375138aed8bba12d61dced583e83fe Mon Sep 17 00:00:00 2001 From: bynect <68197565+bynect@users.noreply.github.com> Date: Thu, 2 May 2024 23:50:18 +0200 Subject: [PATCH 2/2] Update completions --- completions/_dunstctl.zshcomp | 16 ++++++++-------- completions/dunstctl.bashcomp | 2 +- completions/dunstctl.fishcomp | 12 +++++++----- docs/dunstctl.pod | 2 +- dunstctl | 8 ++++---- 5 files changed, 21 insertions(+), 19 deletions(-) diff --git a/completions/_dunstctl.zshcomp b/completions/_dunstctl.zshcomp index 57a66604c..a278ddd3f 100644 --- a/completions/_dunstctl.zshcomp +++ b/completions/_dunstctl.zshcomp @@ -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 @@ -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 ;; diff --git a/completions/dunstctl.bashcomp b/completions/dunstctl.bashcomp index 821ca021d..49973eef4 100644 --- a/completions/dunstctl.bashcomp +++ b/completions/dunstctl.bashcomp @@ -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" ) ) diff --git a/completions/dunstctl.fishcomp b/completions/dunstctl.fishcomp index 6d4a99b22..4e65364ac 100644 --- a/completions/dunstctl.fishcomp +++ b/completions/dunstctl.fishcomp @@ -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' diff --git a/docs/dunstctl.pod b/docs/dunstctl.pod index c85130480..c98db8314 100644 --- a/docs/dunstctl.pod +++ b/docs/dunstctl.pod @@ -24,7 +24,7 @@ You can optionally pass an ID to close the matching notification (if present). =item B -Close all notifications currently being displayed +Close all notifications currently being displayed. =item B diff --git a/dunstctl b/dunstctl index 94d33dbbf..59097c4e5 100755 --- a/dunstctl +++ b/dunstctl @@ -20,17 +20,17 @@ show_help() { given position close [ID] Close the last notification or the notification with given ID. - close-all Close the all notifications + 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 @@ -38,7 +38,7 @@ show_help() { rules [--json] Displays configured rules (optionally in JSON) debug Print debugging information - help Show this help + help Show help EOH } dbus_send_checked() {