Module: naughty.list.notifications

Get a list of all currently active notifications.

Usage example

-- This awful.wibar will be placed at the bottom and contain the notifications.
local notif_wb = awful.wibar {
    position = 'bottom',
    height   = 48,
    visible  = #naughty.active > 0,
}

notif_wb:setup {
    nil,
    {
        base_layout = wibox.widget {
            spacing_widget = wibox.widget {
                orientation = 'vertical',
                span_ratio  = 0.5,
                widget      = wibox.widget.separator,
            },
            forced_height = 30,
            spacing       = 3,
            layout        = wibox.layout.flex.horizontal
        },
        widget_template = {
            {
                naughty.widget.icon,
                {
                    naughty.widget.title,
                    naughty.widget.message,
                    {
                        layout = wibox.widget {
                            -- Adding the wibox.widget allows to share a
                            -- single instance for all spacers.
                            spacing_widget = wibox.widget {
                                orientation = 'vertical',
                                span_ratio  = 0.9,
                                widget      = wibox.widget.separator,
                            },
                            spacing = 3,
                            layout  = wibox.layout.flex.horizontal
                        },
                        widget = naughty.list.widgets,
                    },
                    layout = wibox.layout.align.vertical
                },
                spacing = 10,
                fill_space = true,
                layout  = wibox.layout.fixed.horizontal
            },
            margins = 5,
            widget  = wibox.container.margin
        },
        widget = naughty.list.notifications,
    },
    -- Add a button to dismiss all notifications, because why not.
    {
        {
            text   = 'Dismiss all',
            align  = 'center',
            valign = 'center',
            widget = wibox.widget.textbox
        },
        buttons = gears.table.join(
            awful.button({ }, 1, function() naughty.destroy_all_notifications() end)
        ),
        forced_width       = 75,
        shape              = gears.shape.rounded_bar,
        shape_border_width = 1,
        shape_border_color = beautiful.bg_highlight,
        widget = wibox.container.background
    },
    layout = wibox.layout.align.horizontal
}

-- We don't want to have that bar all the time, only when there is content.
naughty.connect_signal('property::active', function()
    notif_wb.visible = #naughty.active > 0
end)

require(‘gears.timer’).run_delayed_calls_now()

See also:

Info:

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

Constructors

naughty.list.notifications {[args]} Create an notification list.

Functions

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

Object properties

notification notification The notificationlist parent notification.
layout widget The notificationlist layout.
widget_template table The notificationlist parent notification.
style table A table with values to override each beautiful.notification_action values.
base_layout widget A wibox.layout to be used to place the entries.
filter function A function to prevent some notifications from being added to the list.
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_shape_normal gears.shape The shape used for a normal notification.
beautiful.notification_shape_selected gears.shape The shape used for a selected notification.
beautiful.notification_shape_border_color_normal color The shape border color for normal notifications.
beautiful.notification_shape_border_color_selected color The shape border color for selected notifications.
beautiful.notification_shape_border_width_normal number The shape border width for normal notifications.
beautiful.notification_shape_border_width_selected number The shape border width for selected notifications.
beautiful.notification_icon_size_normal number The notification icon size.
beautiful.notification_icon_size_selected number The selected notification icon size.
beautiful.notification_bg_normal color The background color for normal notifications.
beautiful.notification_bg_selected color The background color for selected notifications.
beautiful.notification_fg_normal color The foreground color for normal notifications.
beautiful.notification_fg_selected color The foreground color for selected notifications.
beautiful.notification_bgimage_normal string or gears.surface The background image for normal notifications.
beautiful.notification_bgimage_selected string or gears.surface The background image for selected notifications.

List filters

naughty.list.notifications.filter.all
naughty.list.notifications.filter.most_recent Only get the most recent notification(s).


Constructors

naughty.list.notifications {[args]}
Create an notification list.

Parameters:

  • args
    • base_layout widget The notification list base_layout.
    • filter widget The list filter.
    • style table Override the beautiful values.
    • 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 notifications. (optional)

Returns:

    widget The notification list widget.

Functions

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

Parameters:

  • button awful.button The button to add.

Object properties

notification (notification)
The notificationlist parent notification.

See also:

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

See also:

widget_template (table)
The notificationlist parent notification.
style (table)
A table with values to override each beautiful.notification_action values.
base_layout (widget)
A wibox.layout to be used to place the entries.

See also:

filter (function)
A function to prevent some notifications from being added to the list.
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_shape_normal (gears.shape)
The shape used for a normal notification.

See also:

beautiful.notification_shape_selected (gears.shape)
The shape used for a selected notification.

See also:

beautiful.notification_shape_border_color_normal (color)
The shape border color for normal notifications.

See also:

beautiful.notification_shape_border_color_selected (color)
The shape border color for selected notifications.

See also:

beautiful.notification_shape_border_width_normal (number)
The shape border width for normal notifications.
beautiful.notification_shape_border_width_selected (number)
The shape border width for selected notifications.
beautiful.notification_icon_size_normal (number)
The notification icon size.
beautiful.notification_icon_size_selected (number)
The selected notification icon size.
beautiful.notification_bg_normal (color)
The background color for normal notifications.

See also:

beautiful.notification_bg_selected (color)
The background color for selected notifications.

See also:

beautiful.notification_fg_normal (color)
The foreground color for normal notifications.

See also:

beautiful.notification_fg_selected (color)
The foreground color for selected notifications.

See also:

beautiful.notification_bgimage_normal (string or gears.surface)
The background image for normal notifications.

See also:

beautiful.notification_bgimage_selected (string or gears.surface)
The background image for selected notifications.

See also:

List filters

naughty.list.notifications.filter.all
  • n The notification.
naughty.list.notifications.filter.most_recent

Only get the most recent notification(s).

To set the count, the function needs to be wrapped:

filter = function(n) return naughty.list.notifications.filter.most_recent(n, 3) end
  • n The notification.
  • count number The number of recent notifications to allow. (default 1)
generated by LDoc 1.4.6 Last updated 2030-01-01 00:00:00