Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions man/swaync-client.1.scd
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ swaync-client - Client executable
*-a, --action [ACTION_INDEX]*
Invokes the action [ACTION_INDEX] (or 0) of the latest notification

*-ad, --action-default*
Invokes the default action of the latest notification

*-sw, --skip-wait*
Doesn't wait when swaync hasn't been started

Expand Down
10 changes: 9 additions & 1 deletion src/client.vala
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ interface CcDaemon : Object {

public abstract void latest_invoke_action (uint32 action_index) throws DBusError, IOError;

public abstract void latest_invoke_default_action () throws DBusError, IOError;

public abstract bool set_cc_monitor (string monitor) throws DBusError, IOError;
public abstract bool set_noti_window_monitor (string monitor) throws DBusError, IOError;

Expand Down Expand Up @@ -78,7 +80,9 @@ private void print_help (string[] args) {
print (" \t --close-latest \t\t Closes latest notification\n");
print (" -C, \t --close-all \t\t\t Closes all notifications\n");
print (" -a, \t --action [ACTION_INDEX]\t " +
"Invokes the action [ACTION_INDEX] of the latest notification\n");
"Invokes the action [ACTION_INDEX] (or 0) of the latest notification\n");
print (" -ad,\t --action-default \t\t " +
"Invokes the default action of the latest notification\n");
print (" -sw, \t --skip-wait \t\t\t Doesn't wait when swaync hasn't been started\n");
print (" -s, \t --subscribe \t\t\t Subscribe to notification add and close events\n");
print (" -swb, --subscribe-waybar \t\t Subscribe to notification add and close events "
Expand Down Expand Up @@ -216,6 +220,10 @@ public int command_line (ref string[] args, bool skip_wait) {
}
cc_daemon.latest_invoke_action ((uint32) action_index);
break;
case "--action-default":
case "-ad":
cc_daemon.latest_invoke_default_action ();
break;
case "--get-inhibited":
case "-I":
print (cc_daemon.is_inhibited ().to_string ());
Expand Down
5 changes: 5 additions & 0 deletions src/notiDaemon/notiDaemon.vala
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,11 @@ namespace SwayNotificationCenter {
floating_notifications.latest_notification_action (action_index);
}

/** Activates the default action of the latest notification */
internal void invoke_latest_floating_default_action () {
floating_notifications.latest_notification_default_action ();
}

/*
* D-Bus Specification
* https://specifications.freedesktop.org/notification-spec/latest/ar01s09.html
Expand Down
11 changes: 11 additions & 0 deletions src/notificationWindow/notificationWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,17 @@ namespace SwayNotificationCenter {
noti.click_alt_action (action);
}

public void latest_notification_default_action () {
unowned AnimatedListItem ?item = list.get_first_item ();
if (item == null || !(item.child is Notification)) {
warn_if_reached ();
return;
}

Notification noti = (Notification) item.child;
noti.click_default_action ();
}

public void set_monitor (Gdk.Monitor ?monitor) {
debug ("Setting monitor for Floating Notifications: %s",
Functions.monitor_to_string (monitor) ?? "Monitor Picked by Compositor");
Expand Down
6 changes: 6 additions & 0 deletions src/swayncDaemon/swayncDaemon.vala
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,12 @@ namespace SwayNotificationCenter {
noti_daemon.invoke_latest_floating_action (action_index);
}

/** Activates the default action of the latest floating notification */
public inline void latest_invoke_default_action ()
throws DBusError, IOError {
noti_daemon.invoke_latest_floating_default_action ();
}

/**
* Adds an inhibitor with the Application ID
* (ex: "org.erikreider.swaysettings", "swayidle", etc...).
Expand Down
Loading