Module: naughty.action
A notification action.
A notification can have multiple actions to chose from. This module allows to manage such actions. An action object can be shared by multiple notifications.
Info:
- Copyright: 2019 Emmanuel Lepage Vallee
-
Originally authored by: Emmanuel Lepage Vallee <elv1313@gmail.com>
(Full contributors list available on our github project)
Constructors
naughty.action {[args]} | Create a new action. |
Object properties
position | number | The action position (index). | |
icon | gears.surface or string | The action icon. | |
icon_only | boolean | If the action should hide the label and only display the icon. |
Object methods
:invoke ([notif={}]) | Execute this action. | |
:emit_signal (name, ...) | Emit a signal. | Inherited from gears.object |
:connect_signal (name, func) | Connect to a signal. | Inherited from gears.object |
:weak_connect_signal (name, func) | Connect to a signal weakly. | Inherited from gears.object |
Signals
invoked | When a notification is invoked. |
Constructors
Object properties
- position number · 1 signal
-
The action position (index).
Click to display more Emit signals:
property::position
When the position value changes.self
naughty.action The object which changed (useful when connecting many object to the same callback).new_value
number
The new value affected to the property.
- icon gears.surface or string · 1 signal
-
The action icon.
Click to display more Emit signals:
property::icon
When the icon value changes.self
naughty.action The object which changed (useful when connecting many object to the same callback).new_value
icon The new value affected to the property.
- icon_only boolean · 1 signal
-
If the action should hide the label and only display the icon.
local notif = naughty.notification { title = "A notification", message = "This notification has actions!", actions = { naughty.action { name = "Accept", icon = beautiful.awesome_icon, icon_only = true, }, naughty.action { name = "Refuse", icon = beautiful.awesome_icon, icon_only = true, }, naughty.action { name = "Ignore", icon = beautiful.awesome_icon, icon_only = true, }, } } wibox.widget { notification = notif, widget = naughty.list.actions, }
Click to display more Emit signals:
property::icon_only
When the icon_only value changes.self
naughty.action The object which changed (useful when connecting many object to the same callback).new_value
boolean
The new value affected to the property.
Object methods
- :invoke ([notif={}])
-
Execute this action.
This only emits the invoked signal.
Parameters:
- notif
naughty.notification
A notification object on which
the action was invoked. If a notification is shared by many object (like
a "mute" or "snooze" action added to all notification), calling
:invoke()
without adding thenotif
context will cause unexpected results. (default {})
- notif
naughty.notification
A notification object on which
the action was invoked. If a notification is shared by many object (like
a "mute" or "snooze" action added to all notification), calling
- :emit_signal (name, ...) · Inherited from gears.object
-
Emit a signal.
Parameters:
- name string The name of the signal.
- ... Extra arguments for the callback functions. Each connected function receives the object as first argument and then any extra arguments that are given to emit_signal().
- :connect_signal (name, func) · Inherited from gears.object
-
Connect to a signal.
Parameters:
- name string The name of the signal.
- func function The callback to call when the signal is emitted.
- :weak_connect_signal (name, func) · Inherited from gears.object
-
Connect to a signal weakly.
This allows the callback function to be garbage collected and automatically disconnects the signal when that happens.
Warning: Only use this function if you really, really, really know what you are doing.
Parameters:
- name string The name of the signal.
- func function The callback to call when the signal is emitted.
Signals
- invoked
-
When a notification is invoked.
Note that it is possible to call
:invoke()
without a notification object. It is possible thenotification
parameter will be nil.Arguments:
- action naughty.action The action.
- notification naughty.notification or nil The notification, if known.