Skip to content

Commit fea33d6

Browse files
Gusser93emersion
authored andcommitted
makoctl: add command to list history
1 parent a69041b commit fea33d6

File tree

6 files changed

+25
-4
lines changed

6 files changed

+25
-4
lines changed

contrib/completions/bash/makoctl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ _makoctl()
1111
'invoke'
1212
'menu'
1313
'list'
14+
'history'
1415
'reload'
1516
'set-mode'
1617
'help'

contrib/completions/fish/makoctl.fish

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ complete -c makoctl -n '__fish_makoctl_complete_no_subcommand' -a restore -d 'Re
1212
complete -c makoctl -n '__fish_makoctl_complete_no_subcommand' -a invoke -d 'Invoke an action on the notification (the last one if none is given)' -x
1313
complete -c makoctl -n '__fish_makoctl_complete_no_subcommand' -a menu -d 'Use a program to select one action to be invoked on the notification (the last one if none is given)' -x
1414
complete -c makoctl -n '__fish_makoctl_complete_no_subcommand' -a list -d 'List notifications' -x
15+
complete -c makoctl -n '__fish_makoctl_complete_no_subcommand' -a history -d 'List history' -x
1516
complete -c makoctl -n '__fish_makoctl_complete_no_subcommand' -a reload -d 'Reload the configuration file' -x
1617
complete -c makoctl -n '__fish_makoctl_complete_no_subcommand' -a help -d 'Show help message and quit' -x
1718

contrib/completions/zsh/_makoctl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ makoctl_cmds=(
77
'restore:Restore the most recently expired notification from the history buffer'
88
'invoke:Invoke an action on the first notification. If action is not specified, invoke the default action'
99
'list:Retrieve a list of current notifications'
10+
'history:Retrieve a list of dismissed notifications'
1011
'reload:Reload the configuration file'
1112
'help:Show help message and quit'
1213
)

dbus/mako.c

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,7 @@ static int handle_restore_action(sd_bus_message *msg, void *data,
140140
return sd_bus_reply_method_return(msg, "");
141141
}
142142

143-
static int handle_list_notifications(sd_bus_message *msg, void *data,
144-
sd_bus_error *ret_error) {
145-
struct mako_state *state = data;
143+
static int handle_list(sd_bus_message *msg, struct wl_list *list) {
146144

147145
sd_bus_message *reply = NULL;
148146
int ret = sd_bus_message_new_method_return(msg, &reply);
@@ -156,7 +154,7 @@ static int handle_list_notifications(sd_bus_message *msg, void *data,
156154
}
157155

158156
struct mako_notification *notif;
159-
wl_list_for_each(notif, &state->notifications, link) {
157+
wl_list_for_each(notif, list, link) {
160158
ret = sd_bus_message_open_container(reply, 'a', "{sv}");
161159
if (ret < 0) {
162160
return ret;
@@ -267,6 +265,18 @@ static int handle_list_notifications(sd_bus_message *msg, void *data,
267265
return 0;
268266
}
269267

268+
static int handle_list_notifications(sd_bus_message *msg, void *data,
269+
sd_bus_error *ret_error) {
270+
struct mako_state *state = data;
271+
return handle_list(msg, &state->notifications);
272+
}
273+
274+
static int handle_list_history(sd_bus_message *msg, void *data,
275+
sd_bus_error *ret_error) {
276+
struct mako_state *state = data;
277+
return handle_list(msg, &state->history);
278+
}
279+
270280
/**
271281
* The way surfaces are re-build here is not quite intuitive.
272282
* 1. All surfaces are destroyed.
@@ -428,6 +438,7 @@ static const sd_bus_vtable service_vtable[] = {
428438
SD_BUS_METHOD("InvokeAction", "us", "", handle_invoke_action, SD_BUS_VTABLE_UNPRIVILEGED),
429439
SD_BUS_METHOD("RestoreNotification", "", "", handle_restore_action, SD_BUS_VTABLE_UNPRIVILEGED),
430440
SD_BUS_METHOD("ListNotifications", "", "aa{sv}", handle_list_notifications, SD_BUS_VTABLE_UNPRIVILEGED),
441+
SD_BUS_METHOD("ListHistory", "", "aa{sv}", handle_list_history, SD_BUS_VTABLE_UNPRIVILEGED),
431442
SD_BUS_METHOD("Reload", "", "", handle_reload, SD_BUS_VTABLE_UNPRIVILEGED),
432443
SD_BUS_METHOD("SetMode", "s", "", handle_set_mode, SD_BUS_VTABLE_UNPRIVILEGED),
433444
SD_BUS_METHOD("ListModes", "", "as", handle_list_modes, SD_BUS_VTABLE_UNPRIVILEGED),

makoctl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ usage() {
2020
echo " with the given id, or the last"
2121
echo " notification if none is given"
2222
echo " list List notifications"
23+
echo " history List history"
2324
echo " reload Reload the configuration file"
2425
echo " mode List modes"
2526
echo " mode [-a mode]... [-r mode]... Add/remove modes"
@@ -133,6 +134,9 @@ case "$1" in
133134
"list")
134135
call ListNotifications
135136
;;
137+
"history")
138+
call ListHistory
139+
;;
136140
"reload")
137141
call Reload
138142
;;

makoctl.1.scd

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ Sends IPC commands to the running mako daemon via dbus.
6767
*list*
6868
Retrieve a list of current notifications.
6969

70+
*history*
71+
Retrieve a list of dismissed notifications.
72+
7073
*reload*
7174
Reloads the configuration file.
7275

0 commit comments

Comments
 (0)