Module: naughty.list.notifications

Get a list of all currently active notifications.

-- 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",
            halign = "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").rundelayedcalls_now()

Class Hierarchy

Info:

Constructors

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

Object properties

notification naughty.notification The notificationlist parent notification.
base_layout widget A wibox.layout to be used to place the entries.
widget_template template or nil The notificationlist parent notification.
style table or nil A table with values to override each beautiful.notification_action values.
filter function or nil A function to prevent some notifications from being added to the list.
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_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 All notifications.
naughty.list.notifications.filter.most_recent Only get the most recent notification(s).

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.notifications {[args]}
Create an notification list.

Parameters:

Note: This constructors uses named parameters calling convention. It means you call it with {} and omit the parantheses. For example, calling this will all default argument would be naughty.list.notifications{}. This is a Lua shortcut syntax equivalent to naughty.list.notifications({}). args is only a placeholder name for the "lone table argument" used in named parameters calls.
Name Type(s) Description
args table
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 Optional table A custom widget to be used for each notifications.

Returns:

    widget The notification list widget.

Object properties

🔗 notification naughty.notification · 1 signal
The notificationlist parent notification.

Constraints:

Default value : This is usually set in the construtor.

See also:

naughty.notification Notification manipulation class. module

Click to display more

Emit signals:

🔗 base_layout widget · 1 signal · 1 theme variable
A wibox.layout to be used to place the entries.

If no layout is specified, a wibox.layout.flex.horizontal will be created automatically.

Constraints:

Default value : wibox.layout.flex.horizontal

See also:

wibox.layout.fixed.horizontal Creates and returns a new horizontal fixed layout. (wibox.layout.fixed) constructors
wibox.layout.fixed.vertical Creates and returns a new vertical fixed layout. (wibox.layout.fixed) constructors
wibox.layout.flex.horizontal Creates and returns a new horizontal flex layout. (wibox.layout.flex) constructors
wibox.layout.flex.vertical Creates and returns a new vertical flex layout. (wibox.layout.flex) constructors
wibox.layout.grid Place multiple widgets in multiple rows and columns. module

Click to display more

Emit signals:

Consumed theme variables:

Theme variable Usage
beautiful.notification_spacing
🔗 widget_template template or nil · 1 signal
The notificationlist 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 · 14 theme variables
A table with values to override each beautiful.notification_action values.

Constraints:

Default value : nil
Type description:
nil : Use the values from beautiful rather than hardcoded ones.

Click to display more

Emit signals:

  • property::style When the style value changes.
    • self naughty.list.notifications 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.notification_shape_normalFallback.
beautiful.notification_shape_selectedFallback.
beautiful.notification_shape_border_color_normalFallback.
beautiful.notification_shape_border_color_selectedFallback.
beautiful.notification_shape_border_width_normalFallback.
beautiful.notification_shape_border_width_selectedFallback.
beautiful.notification_icon_size_normalFallback.
beautiful.notification_icon_size_selectedFallback.
beautiful.notification_bg_normalFallback.
beautiful.notification_bg_selectedFallback.
beautiful.notification_fg_normalFallback.
beautiful.notification_fg_selectedFallback.
beautiful.notification_bgimage_normalFallback.
beautiful.notification_bgimage_selectedFallback.
🔗 filter function or nil · 1 signal
A function to prevent some notifications from being added to the list.

Constraints:

Default value : nil
Function prototype:
Parameters:
n (naughty.notification) : The notification object.
count (number) : The number of notifications in the list.
Return (boolean) : true if the notification is allowed and false if it is rejected.

Click to display more

Emit signals:

  • property::filter When the filter value changes.
    • self naughty.list.notifications The object which changed (useful when connecting many object to the same callback).
    • new_value filter The new value affected to the property.
🔗 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_shape_normal gears.shape
The shape used for a normal notification.

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_shape_selected gears.shape
The shape used for a selected notification.

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_shape_border_color_normal color
The shape border color for normal notifications.

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_shape_border_color_selected color
The shape border color for selected notifications.

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_shape_border_width_normal number
The shape border width for normal notifications.
Click to display more

Used by:

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

Used by:

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

Used by:

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

Used by:

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

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_bg_selected color
The background color for selected notifications.

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_fg_normal color
The foreground color for normal notifications.

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_fg_selected color
The foreground color for selected notifications.

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_bgimage_normal string or gears.surface
The background image for normal notifications.

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_bgimage_selected string or gears.surface
The background image for selected notifications.

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.

List filters

🔗 naughty.list.notifications.filter.all
All notifications.
Name Type(s) Description
n naughty.notification 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
Name Type(s) Description Default value
n naughty.notification The notification. Not applicable
count Optional number The number of recent notifications to allow. 1

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