mirror of
https://github.com/ErikReider/SwayNotificationCenter.git
synced 2024-09-11 15:56:04 +03:00
Invoke action from swaync-client
This commit is contained in:
parent
653058beac
commit
0848fa01cf
@ -70,6 +70,9 @@ swaync-client - Client executable
|
||||
*-C, --close-all*
|
||||
Closes all notifications
|
||||
|
||||
*-a, --action [ACTION_ID]*
|
||||
Invokes the action [ACTION_ID] (or 0) of the latest notification
|
||||
|
||||
*-sw, --skip-wait*
|
||||
Doesn't wait when swaync hasn't been started
|
||||
|
||||
|
@ -30,6 +30,8 @@ interface CcDaemon : Object {
|
||||
|
||||
public abstract void set_visibility (bool value) throws DBusError, IOError;
|
||||
|
||||
public abstract void invoke_action (uint32 action) throws DBusError, IOError;
|
||||
|
||||
[DBus (name = "GetSubscribeData")]
|
||||
public abstract SwayncDaemonData get_subscribe_data () throws Error;
|
||||
|
||||
@ -69,6 +71,7 @@ private void print_help (string[] args) {
|
||||
print (" \t --hide-latest \t\t\t Hides latest notification. Still shown in Control Center\n");
|
||||
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_ID]\t\t Invokes the action [ACTION_ID] 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 "
|
||||
@ -190,6 +193,14 @@ public int command_line (string[] args) {
|
||||
cc_daemon.set_dnd (false);
|
||||
print (cc_daemon.get_dnd ().to_string ());
|
||||
break;
|
||||
case "--action":
|
||||
case "-a":
|
||||
int action = 0;
|
||||
if ( args.length >= 3 ) {
|
||||
action = int.parse(args[2]);
|
||||
}
|
||||
cc_daemon.invoke_action ((uint32) action);
|
||||
break;
|
||||
case "--get-inhibited":
|
||||
case "-I":
|
||||
print (cc_daemon.is_inhibited ().to_string ());
|
||||
|
@ -88,6 +88,12 @@ namespace SwayNotificationCenter {
|
||||
manually_close_notification (id, !close);
|
||||
}
|
||||
|
||||
/** Activates the `noti_id` action of the latest notification */
|
||||
public void invoke_action (uint32 noti_id)
|
||||
throws DBusError, IOError {
|
||||
NotificationWindow.instance.latest_notification_action (noti_id);
|
||||
}
|
||||
|
||||
/*
|
||||
* D-Bus Specification
|
||||
* https://specifications.freedesktop.org/notification-spec/latest/ar01s09.html
|
||||
|
@ -270,5 +270,22 @@ namespace SwayNotificationCenter {
|
||||
Notification noti = (Notification) child;
|
||||
return noti.param.applied_id;
|
||||
}
|
||||
|
||||
public void latest_notification_action (uint32 action) {
|
||||
List<weak Gtk.Widget> children = box.get_children ();
|
||||
if (children.is_empty ()) return;
|
||||
|
||||
Gtk.Widget ? child = null;
|
||||
if (list_reverse) {
|
||||
child = children.last ().data;
|
||||
} else {
|
||||
child = children.first ().data;
|
||||
}
|
||||
|
||||
if (child == null || !(child is Notification)) return;
|
||||
Notification noti = (Notification) child;
|
||||
noti.click_alt_action (action);
|
||||
noti.close_notification ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -254,6 +254,12 @@ namespace SwayNotificationCenter {
|
||||
noti_daemon.control_center.close_notification (id, true);
|
||||
}
|
||||
|
||||
/** Activates the `noti_id` action of the latest notification */
|
||||
public void invoke_action (uint32 noti_id)
|
||||
throws DBusError, IOError {
|
||||
noti_daemon.invoke_action (noti_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an inhibitor with the Application ID
|
||||
* (ex: "org.erikreider.swaysettings", "swayidle", etc...).
|
||||
|
Loading…
Reference in New Issue
Block a user