Module: naughty.list.actions

Manage a notification action list.

A notification action is a "button" that will trigger an action on the sender process. notify-send doesn't support actions, but libnotify based applications do.

local notif = naughty.notification {
    title   = "A notification",
    message = "This notification has actions!",
    actions = {
        naughty.action {
            name = "Accept",
        },
        naughty.action {
            name = "Refuse",
        },
        naughty.action {
            name = "Ignore",
        },
    }
}

wibox.widget {
    notification = notif,
    widget = naughty.list.actions,
}

This example has a custom vertical widget template:

wibox.widget {
    notification = notif,
    base_layout = wibox.widget {
        spacing        = 3,
        spacing_widget = wibox.widget {
            orientation = "horizontal",
            widget      = wibox.widget.separator,
        },
        layout         = wibox.layout.fixed.vertical
    },
    widget_template = {
        {
            {
                {
                    id     = "text_role",
                    widget = wibox.widget.textbox
                },
                widget = wibox.container.place
            },
            shape              = gears.shape.rounded_rect,
            shape_border_width = 2,
            shape_border_color = beautiful.bg_normal,
            forced_height      = 30,
            widget             = wibox.container.background,
        },
        margins = 4,
        widget  = wibox.container.margin,
    },
    widget = naughty.list.actions,
}

This example has a horizontal widget template and icons:

wibox.widget {
    notification = notif,
    base_layout = wibox.widget {
        spacing        = 3,
        spacing_widget = wibox.widget {
            orientation = "vertical",
            widget      = wibox.widget.separator,
        },
        layout         = wibox.layout.flex.horizontal
    },
    widget_template = {
        {
            {
                {
                    id            = "icon_role",
                    forced_height = 16,
                    forced_width  = 16,
                    widget        = wibox.widget.imagebox
                },
                {
                    id     = "text_role",
                    widget = wibox.widget.textbox
                },
                spacing = 5,
                layout = wibox.layout.fixed.horizontal
            },
            id = "background_role",
            widget             = wibox.container.background,
        },
        margins = 4,
        widget  = wibox.container.margin,
    },
    widget = naughty.list.actions,
}

This example uses the theme/style variables instead of the template. This is less flexible, but easier to put in the theme file. Note that each style variable has a beautiful equivalent.

wibox.widget {
    notification = notif,
    base_layout = wibox.widget {
        spacing        = 3,
        spacing_widget = wibox.widget {
            orientation = "vertical",
            widget      = wibox.widget.separator,
        },
        layout         = wibox.layout.flex.horizontal
    },
    style = {
        underline_normal             = false,
        underline_selected           = true,
        shape_normal                 = gears.shape.octogon,
        shape_selected               = gears.shape.hexagon,
        shape_border_width_normal    = 2,
        shape_border_width_selected  = 4,
        icon_size_normal             = 16,
        icon_size_selected           = 24,
        shape_border_color_normal    = "#0000ff",
        shape_border_color_selected  = "#ff0000",
        bg_normal                    = "#ffff00",
        bg_selected                  = "#00ff00",
    },
    forced_height = beautiful.get_font_height(beautiful.font) * 2.5,
    widget = naughty.list.actions,
}

Class Hierarchy

Info:

Constructors

naughty.list.actions (args, widget_template) Create an action list.

Object properties

notification naughty.notification or nil The actionlist parent notification.
base_layout widget The actionlist layout.
widget_template template or nil The actionlist parent notification.
style table or nil A table with values to override each beautiful.notification_action values.
children table Get or set the children elements. Inherited from wibox.widget.base
all_children table Get all direct and indirect children widgets. Inherited from wibox.widget.base
forced_height number or nil Force a widget height. Inherited from wibox.widget.base
forced_width number or nil Force a widget width. Inherited from wibox.widget.base
opacity number The widget opacity (transparency). Inherited from wibox.widget.base
visible boolean The widget visibility. Inherited from wibox.widget.base
buttons table The widget buttons. Inherited from wibox.widget.base

Object methods

: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
:add_button (button) Add a new awful.button to this widget. Inherited from wibox.widget.base
:emit_signal_recursive (signal_name, ...) Emit a signal and ensure all parent widgets in the hierarchies also forward the signal. Inherited from wibox.widget.base
:index (widget, recursive, ...) -> (number, widget, table) Get the index of a widget. Inherited from wibox.widget.base
:disconnect_signal (name, func) Disonnect from a signal. Inherited from gears.object

Theme variables

beautiful.notification_action_underline_normal boolean Whether or not to underline the action name.
beautiful.notification_action_underline_selected boolean Whether or not to underline the selected action name.
beautiful.notification_action_icon_only boolean Whether or not the action label should be shown.
beautiful.notification_action_label_only boolean Whether or not the action icon should be shown.
beautiful.notification_action_shape_normal gears.shape The shape used for a normal action.
beautiful.notification_action_shape_selected gears.shape The shape used for a selected action.
beautiful.notification_action_shape_border_color_normal color The shape border color for normal actions.
beautiful.notification_action_shape_border_color_selected color The shape border color for selected actions.
beautiful.notification_action_shape_border_width_normal number The shape border width for normal actions.
beautiful.notification_action_shape_border_width_selected number The shape border width for selected actions.
beautiful.notification_action_icon_size_normal number The action icon size.
beautiful.notification_action_icon_size_selected number The selected action icon size.
beautiful.notification_action_bg_normal color The background color for normal actions.
beautiful.notification_action_bg_selected color The background color for selected actions.
beautiful.notification_action_fg_normal color The foreground color for normal actions.
beautiful.notification_action_fg_selected color The foreground color for selected actions.
beautiful.notification_action_bgimage_normal gears.surface or string The background image for normal actions.
beautiful.notification_action_bgimage_selected gears.surface or string The background image for selected actions.

Signals

widget::layout_changed When the layout (size) change. Inherited from wibox.widget.base
widget::redraw_needed When the widget content changed. Inherited from wibox.widget.base
button::press When a mouse button is pressed over the widget. Inherited from wibox.widget.base
button::release When a mouse button is released over the widget. Inherited from wibox.widget.base
mouse::enter When the mouse enter a widget. Inherited from wibox.widget.base
mouse::leave When the mouse leave a widget. Inherited from wibox.widget.base


Constructors

🔗 naughty.list.actions (args, widget_template)
Create an action list.

Parameters:

Name Type(s) Description
args table
notification naughty.notification The notification.
base_layout widget The action layout.
style table Override the beautiful values.
style.underline_normal boolean
style.underline_selected boolean
style.shape_normal gears.shape
style.shape_selected gears.shape
style.shape_border_color_normal gears.color or string
style.shape_border_color_selected gears.color or string
style.shape_border_width_normal number
style.shape_border_width_selected number
style.icon_size number
style.bg_normal gears.color or string
style.bg_selected gears.color or string
style.fg_normal gears.color or string
style.fg_selected gears.color or string
style.bgimage_normal gears.surface or string
style.bgimage_selected gears.surface or string
widget_template Optional table A custom widget to be used for each action.

Returns:

    widget The action widget.

Object properties

🔗 notification naughty.notification or nil · 1 signal
The actionlist parent notification.

Constraints:

Default value : nil

See also:

naughty.notification Notification manipulation class. module

Click to display more

Emit signals:

  • property::notification When the notification value changes.
    • self naughty.list.actions The object which changed (useful when connecting many object to the same callback).
    • new_value notification The new value affected to the property.
🔗 base_layout widget · 1 signal
The actionlist layout. If no layout is specified, a wibox.layout.fixed.horizontal will be created automatically.

Constraints:

Default value : wibox.layout.fixed.horizontal

See also:

wibox.layout.fixed.horizontal Creates and returns a new horizontal fixed layout. (wibox.layout.fixed) constructors

Click to display more

Emit signals:

  • property::base_layout When the base_layout value changes.
    • self naughty.list.actions The object which changed (useful when connecting many object to the same callback).
    • new_value base_layout The new value affected to the property.
🔗 widget_template template or nil · 1 signal
The actionlist parent notification.

Constraints:

Default value : nil
Type description:
table : A table containing a widget tree definition. WARNING: This is really a table and NOT a widget object. Use the widget = come.class.here to define the topmost class rather than construct an instance.

Click to display more

Emit signals:

🔗 style table or nil · 1 signal · 19 theme variables
A table with values to override each beautiful.notification_action values.

Constraints:

Default value : {}
Table keys:
underline_normal (boolean|nil)
underline_selected (boolean|nil)
shape_normal (shape|nil)
shape_selected (shape|nil)
shape_border_color_normal (gears.color|string|nil)
shape_border_color_selected (gears.color|string|nil)
shape_border_width_normal (number|nil)
shape_border_width_selected (number|nil)
icon_size (number|nil)
bg_normal (color|string|nil)
bg_selected (color|string|nil)
fg_normal (color|string|nil)
fg_selected (color|string|nil)
bgimage_normal (surface|string|nil)
bgimage_selected (surface|string|nil)

Click to display more

Emit signals:

  • property::style When the style value changes.
    • self naughty.list.actions The object which changed (useful when connecting many object to the same callback).
    • new_value style The new value affected to the property.

Consumed theme variables:

Theme variable Usage
beautiful.fontFallback when the font property isn't set.
beautiful.notification_action_underline_normalFallback.
beautiful.notification_action_underline_selectedFallback.
beautiful.notification_action_icon_onlyFallback.
beautiful.notification_action_label_onlyFallback.
beautiful.notification_action_shape_normalFallback.
beautiful.notification_action_shape_selectedFallback.
beautiful.notification_action_shape_border_color_normalFallback.
beautiful.notification_action_shape_border_color_selectedFallback.
beautiful.notification_action_shape_border_width_normalFallback.
beautiful.notification_action_shape_border_width_selectedFallback.
beautiful.notification_action_icon_size_normalFallback.
beautiful.notification_action_icon_size_selectedFallback.
beautiful.notification_action_bg_normalFallback.
beautiful.notification_action_bg_selectedFallback.
beautiful.notification_action_fg_normalFallback.
beautiful.notification_action_fg_selectedFallback.
beautiful.notification_action_bgimage_normalFallback.
beautiful.notification_action_bgimage_selectedFallback.
🔗 children table · Inherited from wibox.widget.base
Get or set the children elements.

Constraints:

Default value : {}
Table content : A list of wibox.widget.

See also:

all_children Get all direct and indirect children widgets. object properties
🔗 all_children table · Inherited from wibox.widget.base
Get all direct and indirect children widgets. This will scan all containers recursively to find widgets Warning: This method it prone to stack overflow if there is a loop in the widgets hierarchy. A hierarchy loop is when a widget, or any of its children, contain (directly or indirectly) itself.

Constraints:

Default value : {}
Table content : A list of wibox.widget.

See also:

children Get or set the children elements. object properties
🔗 forced_height number or nil · Inherited from wibox.widget.base
Force a widget height.

Constraints:

Default value : nil
Type description:
nil : Let the layout decide the height. Usually using the widget native height.
number : Enforce a number of pixels.
Unit : pixel
Negative allowed : false

See also:

forced_width Force a widget width. object properties
🔗 forced_width number or nil · Inherited from wibox.widget.base
Force a widget width.

Constraints:

Default value : nil
Type description:
nil : Let the layout decide the width. Usually using the widget native width.
number : Enforce a number of pixels.
Unit : pixel
Negative allowed : false

See also:

forced_height Force a widget height. object properties
🔗 opacity number · Inherited from wibox.widget.base
The widget opacity (transparency).

Constraints:

Default value : 1.0
Unit : A gradient between transparent (0.0) and opaque (1.0).
Minimum value : 0.0
Maximum value : 1.0

See also:

visible The widget visibility. object properties
🔗 visible boolean · Inherited from wibox.widget.base
The widget visibility.

Constraints:

Default value : true
Valid values : true or false.

See also:

opacity The widget opacity (transparency). object properties
🔗 buttons table · Inherited from wibox.widget.base
The widget buttons.

The table contains a list of awful.button objects.

Constraints:

Default value : {}
Table content : A list of awful.button.

See also:

awful.button Create easily new buttons objects ignoring certain modifiers. module

Object methods

🔗 :emit_signal (name, ...) · Inherited from gears.object
Emit a signal.

Parameters:

Name Type(s) Description
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 Type(s) Description
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 Type(s) Description
name string The name of the signal.
func function The callback to call when the signal is emitted.
🔗 :add_button (button) · Inherited from wibox.widget.base
Add a new awful.button to this widget.

Parameters:

Name Type(s) Description
button awful.button The button to add.
🔗 :emit_signal_recursive (signal_name, ...) · Inherited from wibox.widget.base

Emit a signal and ensure all parent widgets in the hierarchies also forward the signal.

This is useful to track signals when there is a dynamic set of containers and layouts wrapping the widget.

Note that this function has some flaws:

  1. The signal is only forwarded once the widget tree has been built. This happens after all currently scheduled functions have been executed. Therefore, it will not start to work right away.
  2. In case the widget is present multiple times in a single widget tree, this function will also forward the signal multiple times (once per upward tree path).
  3. If the widget is removed from the widget tree, the signal is still forwarded for some time, similar to the first case.

Parameters:

Name Type(s) Description
signal_name string
... Other arguments
🔗 :index (widget, recursive, ...) -> (number, widget, table) · Inherited from wibox.widget.base
Get the index of a widget.

Parameters:

Name Type(s) Description
widget widget The widget to look for.
recursive Optional boolean Recursively check accross the sub-widgets hierarchy.
... Optional widget Additional widgets to add at the end of the sub-widgets hierarchy "path".

Returns:

  1. number The widget index.
  2. widget The parent widget.
  3. table The hierarchy path between "self" and "widget".
🔗 :disconnect_signal (name, func) · Inherited from gears.object
Disonnect from a signal.

Parameters:

Name Type(s) Description
name string The name of the signal.
func function The callback that should be disconnected.

Theme variables

🔗 beautiful.notification_action_underline_normal boolean
Whether or not to underline the action name.
Click to display more

Used by:

  • style A table with values to override each `beautiful.notification_action` values.
🔗 beautiful.notification_action_underline_selected boolean
Whether or not to underline the selected action name.
Click to display more

Used by:

  • style A table with values to override each `beautiful.notification_action` values.
🔗 beautiful.notification_action_icon_only boolean
Whether or not the action label should be shown.
Click to display more

Used by:

  • style A table with values to override each `beautiful.notification_action` values.
🔗 beautiful.notification_action_label_only boolean
Whether or not the action icon should be shown.
Click to display more

Used by:

  • style A table with values to override each `beautiful.notification_action` values.
🔗 beautiful.notification_action_shape_normal gears.shape
The shape used for a normal action.

See also:

gears.shape Module dedicated to gather common shape painters. module

Click to display more

Used by:

  • style A table with values to override each `beautiful.notification_action` values.
🔗 beautiful.notification_action_shape_selected gears.shape
The shape used for a selected action.

See also:

gears.shape Module dedicated to gather common shape painters. module

Click to display more

Used by:

  • style A table with values to override each `beautiful.notification_action` values.
🔗 beautiful.notification_action_shape_border_color_normal color
The shape border color for normal actions.

See also:

gears.color This module simplifies the creation of cairo pattern objects. module

Click to display more

Used by:

  • style A table with values to override each `beautiful.notification_action` values.
🔗 beautiful.notification_action_shape_border_color_selected color
The shape border color for selected actions.

See also:

gears.color This module simplifies the creation of cairo pattern objects. module

Click to display more

Used by:

  • style A table with values to override each `beautiful.notification_action` values.
🔗 beautiful.notification_action_shape_border_width_normal number
The shape border width for normal actions.
Click to display more

Used by:

  • style A table with values to override each `beautiful.notification_action` values.
🔗 beautiful.notification_action_shape_border_width_selected number
The shape border width for selected actions.
Click to display more

Used by:

  • style A table with values to override each `beautiful.notification_action` values.
🔗 beautiful.notification_action_icon_size_normal number
The action icon size.
Click to display more

Used by:

  • style A table with values to override each `beautiful.notification_action` values.
🔗 beautiful.notification_action_icon_size_selected number
The selected action icon size.
Click to display more

Used by:

  • style A table with values to override each `beautiful.notification_action` values.
🔗 beautiful.notification_action_bg_normal color
The background color for normal actions.

See also:

gears.color This module simplifies the creation of cairo pattern objects. module

Click to display more

Used by:

  • style A table with values to override each `beautiful.notification_action` values.
🔗 beautiful.notification_action_bg_selected color
The background color for selected actions.

See also:

gears.color This module simplifies the creation of cairo pattern objects. module

Click to display more

Used by:

  • style A table with values to override each `beautiful.notification_action` values.
🔗 beautiful.notification_action_fg_normal color
The foreground color for normal actions.

See also:

gears.color This module simplifies the creation of cairo pattern objects. module

Click to display more

Used by:

  • style A table with values to override each `beautiful.notification_action` values.
🔗 beautiful.notification_action_fg_selected color
The foreground color for selected actions.

See also:

gears.color This module simplifies the creation of cairo pattern objects. module

Click to display more

Used by:

  • style A table with values to override each `beautiful.notification_action` values.
🔗 beautiful.notification_action_bgimage_normal gears.surface or string
The background image for normal actions.

See also:

gears.surface Utilities to integrate and manipulate Cairo drawing surfaces. module

Click to display more

Used by:

  • style A table with values to override each `beautiful.notification_action` values.
🔗 beautiful.notification_action_bgimage_selected gears.surface or string
The background image for selected actions.

See also:

gears.surface Utilities to integrate and manipulate Cairo drawing surfaces. module

Click to display more

Used by:

  • style A table with values to override each `beautiful.notification_action` values.

Signals

🔗 widget::layout_changed · Inherited from wibox.widget.base
When the layout (size) change. This signal is emitted when the previous results of :layout() and :fit() are no longer valid. Unless this signal is emitted, :layout() and :fit() must return the same result when called with the same arguments.

See also:

widget::redraw_needed When the widget content changed. signals
🔗 widget::redraw_needed · Inherited from wibox.widget.base
When the widget content changed. This signal is emitted when the content of the widget changes. The widget will be redrawn, it is not re-layouted. Put differently, it is assumed that :layout() and :fit() would still return the same results as before.

See also:

widget::layout_changed When the layout (size) change. signals
🔗 button::press · Inherited from wibox.widget.base
When a mouse button is pressed over the widget.

Arguments:

Name Type(s) Description
self table The current object instance itself.
lx number The horizontal position relative to the (0,0) position in the widget.
ly number The vertical position relative to the (0,0) position in the widget.
button number The button number.
mods table The modifiers (mod4, mod1 (alt), Control, Shift)
find_widgets_result table The entry from the result of wibox:find_widgets for the position that the mouse hit.
drawable wibox.drawable The drawable containing the widget.
widget widget The widget being displayed.
hierarchy wibox.hierarchy The hierarchy managing the widget's geometry.
x number An approximation of the X position that the widget is visible at on the surface.
y number An approximation of the Y position that the widget is visible at on the surface.
width number An approximation of the width that the widget is visible at on the surface.
height number An approximation of the height that the widget is visible at on the surface.
widget_width number The exact width of the widget in its local coordinate system.
widget_height number The exact height of the widget in its local coordinate system.

See also:

mouse Manipulate and inspect the mouse cursor. module
🔗 button::release · Inherited from wibox.widget.base
When a mouse button is released over the widget.

Arguments:

Name Type(s) Description
self table The current object instance itself.
lx number The horizontal position relative to the (0,0) position in the widget.
ly number The vertical position relative to the (0,0) position in the widget.
button number The button number.
mods table The modifiers (mod4, mod1 (alt), Control, Shift)
find_widgets_result table The entry from the result of wibox:find_widgets for the position that the mouse hit.
drawable wibox.drawable The drawable containing the widget.
widget widget The widget being displayed.
hierarchy wibox.hierarchy The hierarchy managing the widget's geometry.
x number An approximation of the X position that the widget is visible at on the surface.
y number An approximation of the Y position that the widget is visible at on the surface.
width number An approximation of the width that the widget is visible at on the surface.
height number An approximation of the height that the widget is visible at on the surface.
widget_width number The exact width of the widget in its local coordinate system.
widget_height number The exact height of the widget in its local coordinate system.

See also:

mouse Manipulate and inspect the mouse cursor. module
🔗 mouse::enter · Inherited from wibox.widget.base
When the mouse enter a widget.

Arguments:

Name Type(s) Description
self table The current object instance itself.
find_widgets_result table The entry from the result of wibox:find_widgets for the position that the mouse hit.
drawable wibox.drawable The drawable containing the widget.
widget widget The widget being displayed.
hierarchy wibox.hierarchy The hierarchy managing the widget's geometry.
x number An approximation of the X position that the widget is visible at on the surface.
y number An approximation of the Y position that the widget is visible at on the surface.
width number An approximation of the width that the widget is visible at on the surface.
height number An approximation of the height that the widget is visible at on the surface.
widget_width number The exact width of the widget in its local coordinate system.
widget_height number The exact height of the widget in its local coordinate system.

See also:

mouse Manipulate and inspect the mouse cursor. module
🔗 mouse::leave · Inherited from wibox.widget.base
When the mouse leave a widget.

Arguments:

Name Type(s) Description
self table The current object instance itself.
find_widgets_result table The entry from the result of wibox:find_widgets for the position that the mouse hit.
drawable wibox.drawable The drawable containing the widget.
widget widget The widget being displayed.
hierarchy wibox.hierarchy The hierarchy managing the widget's geometry.
x number An approximation of the X position that the widget is visible at on the surface.
y number An approximation of the Y position that the widget is visible at on the surface.
width number An approximation of the width that the widget is visible at on the surface.
height number An approximation of the height that the widget is visible at on the surface.
widget_width number The exact width of the widget in its local coordinate system.
widget_height number The exact height of the widget in its local coordinate system.

See also:

mouse Manipulate and inspect the mouse cursor. module
generated by LDoc 1.4.6