Skip to content

Commit

Permalink
Add new rules and implement proper rule completion in fish
Browse files Browse the repository at this point in the history
  • Loading branch information
zappolowski committed Jan 20, 2024
1 parent 77cb291 commit 4221e15
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions contrib/dunstctl.fishcomp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@ else
end
end

function __fish_dunstctl_rule_complete
set -l parts (string split ' ' $argv[1])
if test (count $parts[-1]) -eq 0 || test $parts[-2] = rule
__fish_dunstctl_info rules name enabled
return
end
# TODO? enable disable might not make sense when the rule is already in the correct state
echo -e 'enable\ndisable\ntoggle'
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'
Expand All @@ -20,16 +30,16 @@ complete -c dunstctl -f -n __fish_use_subcommand -a history-pop -d 'Pop the late
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 set-paused -d 'Set the pause status'
complete -c dunstctl -f -n __fish_use_subcommand -a rules -d 'Displays configured rules (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'

# 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 rules 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'

# TODO: add completion for rule when there is a proper way to get configured rules
complete -c dunstctl -x -n '__fish_seen_subcommand_from rule' -a '(__fish_dunstctl_rule_complete (commandline -c))'

# ex: filetype=fish

0 comments on commit 4221e15

Please sign in to comment.