Skip to content

Commit d0b6518

Browse files
committed
Generalize __fish_dunstctl_history to __fish_dunstctl_info
This can be re-used to retrieve other pairs of information (e.g. history id message could be helpful as well).
1 parent 474620d commit d0b6518

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

contrib/dunstctl.fishcomp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
if command -q jq
2-
function __fish_dunstctl_history
3-
dunstctl history | jq -r '.data[][] | "\(.id.data)\t\(.appname.data)"'
2+
function __fish_dunstctl_info
3+
dunstctl $argv[1] | jq -r ".data[][] | \"\(.$argv[2].data)\t\(.$argv[3].data)\""
44
end
55
else
6-
function __fish_dunstctl_history
7-
dunstctl history | awk '/"id" :/ {getline; getline; print $3}'
6+
function __fish_dunstctl_info
7+
dunstctl $argv[1] | awk -vpattern="\"$argv[2]\" :" '$0 ~ pattern {getline; getline; gsub("\"", "", $3); print $3}'
88
end
99
end
1010

@@ -27,7 +27,7 @@ complete -c dunstctl -f -n __fish_use_subcommand -a help -d 'Show this help'
2727
# command specific arguments
2828
complete -c dunstctl -x -n '__fish_seen_subcommand_from action close close-all context history history-clear is-paused debug help'
2929
complete -c dunstctl -x -n '__fish_seen_subcommand_from count' -a 'displayed history waiting'
30-
complete -c dunstctl -x -n '__fish_seen_subcommand_from history-pop history-rm' -a '(__fish_dunstctl_history)'
30+
complete -c dunstctl -x -n '__fish_seen_subcommand_from history-pop history-rm' -a '(__fish_dunstctl_info history id appname)'
3131
complete -c dunstctl -x -n '__fish_seen_subcommand_from set-paused' -a 'true false toggle'
3232

3333
# TODO: add completion for rule when there is a proper way to get configured rules

0 commit comments

Comments
 (0)