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
  • Author: Emmanuel Lepage Vallee <[email protected]>

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.
:connect_signal (name, func) Connect to a signal.
:weak_connect_signal (name, func) Connect to a signal weakly.

Signals

invoked When a notification is invoked.


Constructors

naughty.action {[args]}
Create a new action.

Parameters:

  • args The arguments.
    • name string The name.
    • position string The position.
    • icon string The icon.
    • notification naughty.notification The notification object.
    • selected boolean If this action is currently selected.

Returns:

    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.

Usage example

 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,
 }

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 the notif context will cause unexpected results. (default {})
:emit_signal (name, ...)
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)
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)
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.
generated by LDoc 1.4.6 Last updated 2030-01-01 00:00:00