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.

Usage example

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:

Usage example

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:

Usage example

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.

Usage example

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

See also:

Info:

  • Copyright: 2017 Emmanuel Lepage Vallee
  • Author: Emmanuel Lepage Vallee <[email protected]>

Constructors

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

Functions

naughty.list.actions.add_button (button) Add a new awful.button to this widget.

Object properties

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

Object methods

:setup {[args]} Set a declarative widget hierarchy description.
:emit_signal_recursive (signal_name, ...) Emit a signal and ensure all parent widgets in the hierarchies also forward the signal.
: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

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

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.


Constructors

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

Parameters:

  • args
    • 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 table A custom widget to be used for each action. (optional)

Returns:

    widget The action widget.

Functions

naughty.list.actions.add_button (button)
Add a new awful.button to this widget.

Parameters:

  • button awful.button The button to add.

Object properties

notification (notification)
The actionlist parent notification.

See also:

layout (widget)
The actionlist layout. If no layout is specified, a wibox.layout.fixed.horizontal will be created automatically.

See also:

widget_template (table)
The actionlist parent notification.
style (table)
A table with values to override each beautiful.notification_action values.
children (table)
Get or set the children elements.

Type constraints:

all_children (table)
Get all direct and indirect children widgets. This will scan all containers recursively to find widgets Warning: This method it prone to stack overflow id the widget, or any of its children, contain (directly or indirectly) itself.

Type constraints:

forced_height (number or nil)
Force a widget height.

Type constraints:

  • height number or nil The height (nil for automatic)
forced_width (number or nil)
Force a widget width.

Type constraints:

  • width number or nil The width (nil for automatic)
opacity (number)
The widget opacity (transparency).

Type constraints:

  • opacity number The opacity (between 0 and 1) (default 1)
visible (boolean)
The widget visibility.
buttons (table)
The widget buttons.

The table contains a list of awful.button objects.

See also:

Object methods

:setup {[args]}
Set a declarative widget hierarchy description. See The declarative layout system

Parameters:

  • args An array containing the widgets disposition
:emit_signal_recursive (signal_name, ...)
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.

Parameters:

  • signal_name string
  • ... Other arguments
: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

widget::layout_changed
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. 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:

button::press
When a mouse button is pressed over the widget.

Arguments:

  • 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 The entry from the result of wibox.drawable: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:

button::release
When a mouse button is released over the widget.

Arguments:

  • 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 The entry from the result of wibox.drawable: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::enter
When the mouse enter a widget.

Arguments:

  • find_widgets_result The entry from the result of wibox.drawable: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::leave
When the mouse leave a widget.

Arguments:

  • find_widgets_result The entry from the result of wibox.drawable: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:

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.

See also:

beautiful.notification_action_shape_selected (gears.shape)
The shape used for a selected action.

See also:

beautiful.notification_action_shape_border_color_normal (color)
The shape border color for normal actions.

See also:

beautiful.notification_action_shape_border_color_selected (color)
The shape border color for selected actions.

See also:

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.

See also:

beautiful.notification_action_bg_selected (color)
The background color for selected actions.

See also:

beautiful.notification_action_fg_normal (color)
The foreground color for normal actions.

See also:

beautiful.notification_action_fg_selected (color)
The foreground color for selected actions.

See also:

beautiful.notification_action_bgimage_normal (gears.surface or string)
The background image for normal actions.

See also:

beautiful.notification_action_bgimage_selected (gears.surface or string)
The background image for selected actions.

See also:

generated by LDoc 1.4.6 Last updated 2030-01-01 00:00:00