Skip to main content

naughty

The naughty library handles desktop notifications. It receives notifications from applications via the D-Bus org.freedesktop.Notifications interface and displays them on screen.

Upstream documentation: awesomewm.org/apidoc/libraries/naughty.html

SomeWM's naughty implementation is fully compatible with AwesomeWM.

Modules

ModulePurpose
naughty.notifyCreate and display notifications
naughty.notificationNotification object
naughty.layout.boxDefault notification display widget
naughty.widget.iconNotification icon widget
naughty.widget.titleNotification title widget
naughty.widget.messageNotification message widget
naughty.list.actionsNotification action buttons widget
naughty.actionNotification action (clickable button)
ruled.notificationRule-based notification configuration

Display Handler

Naughty requires a request::display handler to show notifications. The default config provides one. If building from scratch:

local naughty = require("naughty")

naughty.connect_signal("request::display", function(n)
naughty.layout.box { notification = n }
end)

naughty.notify

Create a notification:

naughty.notify {
title = "Title",
text = "Body text",
timeout = 5,
}

Parameters

ParameterTypeDefaultDescription
titlestring""Notification title
textstring""Notification body
timeoutnumber5Auto-dismiss time in seconds (0 = never)
urgencystring"normal""low", "normal", or "critical"
positionstring"top_right"Screen position (see Positions)
iconstringnilPath to icon image
icon_sizenumbernilIcon size in pixels
bgstringtheme defaultBackground colour
fgstringtheme defaultForeground colour
actionstable{}List of naughty.action objects
ignore_suspendbooleanfalseShow even when notifications are suspended
categorystringnilNotification category (e.g., "email.arrived")
app_namestringnilApplication name

Actions

naughty.notify {
title = "Download complete",
text = "document.pdf",
actions = {
naughty.action { name = "Open" },
naughty.action { name = "Show in folder" },
},
}

Handle action clicks with the invoked signal:

local n = naughty.notify {
title = "Download complete",
text = "document.pdf",
actions = {
naughty.action { name = "Open" },
naughty.action { name = "Show in folder" },
},
}

n:connect_signal("invoked", function(_, action_index)
if action_index == 1 then
awful.spawn("xdg-open ~/Downloads/document.pdf")
elseif action_index == 2 then
awful.spawn("nautilus ~/Downloads")
end
end)

naughty.config.defaults

Global defaults applied to all notifications:

PropertyTypeDefaultDescription
timeoutnumber5Auto-dismiss time in seconds
positionstring"top_right"Screen position
marginnumber10Margin from screen edge
icon_sizenumber48Default icon size
naughty.config.defaults.timeout = 5
naughty.config.defaults.position = "top_right"
naughty.config.defaults.margin = 10
naughty.config.defaults.icon_size = 48

Spacing

naughty.config.spacing = 4  -- Gap between stacked notifications

Positions

ValueLocation
"top_left"Top-left corner
"top_middle"Top centre
"top_right"Top-right corner (default)
"bottom_left"Bottom-left corner
"bottom_middle"Bottom centre
"bottom_right"Bottom-right corner

Urgency Presets

Configure appearance per urgency level via naughty.config.presets:

PresetDefault TimeoutDescription
naughty.config.presets.low5Subtle, low-priority
naughty.config.presets.normal5Standard notifications
naughty.config.presets.critical0 (never)Requires manual dismissal

Each preset accepts bg, fg, timeout, and other notification properties:

naughty.config.presets.critical.bg = "#ff0000"
naughty.config.presets.critical.fg = "#ffffff"
naughty.config.presets.critical.timeout = 0

Notification Rules

ruled.notification applies properties to notifications matching specified criteria.

local ruled = require("ruled")

ruled.notification.connect_signal("request::rules", function()
ruled.notification.append_rule {
rule = { ... }, -- match criteria
rule_any = { ... }, -- match any of these criteria
properties = { ... }, -- properties to apply
}
end)

Rule Matching Fields

FieldTypeDescription
app_namestringApplication name (e.g., "Spotify", "discord")
titlestringNotification title (supports Lua patterns)
messagestringNotification body text (supports Lua patterns)
urgencystring"low", "normal", or "critical"
categorystringNotification category (e.g., "email.arrived")

Use rule for exact matches. Use rule_any with table values to match any of multiple values:

rule_any = {
app_name = { "Spotify", "vlc" },
category = { "device.error", "network.error" },
}

Rule Settable Properties

PropertyTypeDescription
timeoutnumberAuto-dismiss time in seconds (0 = never)
implicit_timeoutnumberFallback timeout if notification doesn't specify one
never_timeoutbooleanForce timeout to 0
positionstringScreen position
screenscreenTarget screen
ignore_suspendbooleanShow even when suspended
ignorebooleanCompletely ignore this notification
bgstringBackground colour
fgstringForeground colour
iconstringIcon path
icon_sizenumberIcon size in pixels

Suspension

Suspend notifications to prevent them from displaying:

naughty.suspended = true   -- Suspend all notifications
naughty.suspended = false -- Resume (queued notifications appear)

Notifications with ignore_suspend = true still display while suspended.

Access queued notifications during suspension:

for _, n in ipairs(naughty.notifications.suspended) do
print(n.title)
end

Legacy API

naughty.suspend()   -- Deprecated, use naughty.suspended = true
naughty.resume() -- Deprecated, use naughty.suspended = false
naughty.toggle() -- Deprecated, use naughty.suspended = not naughty.suspended

Signals

Notification Lifecycle

SignalArgumentsDescription
request::displaynNotification ready to display (must connect a handler)
request::rules(none)Rules should be registered (via ruled.notification)
addednNotification created
destroyedn, reasonNotification dismissed or expired

Notification Object Signals

SignalArgumentsDescription
invokedn, action_indexUser clicked a notification action
property::titlenTitle changed
property::messagenMessage changed
property::urgencynUrgency changed

Theme Variables

Notifications are styled via beautiful variables. See Theme Variables: Notifications for the full list.

Key variables:

VariableDescription
notification_bgBackground colour
notification_fgForeground colour
notification_border_colorBorder colour
notification_border_widthBorder width in pixels
notification_widthDefault width
notification_max_widthMaximum width
notification_max_heightMaximum height
notification_icon_sizeDefault icon size
notification_fontFont
notification_shapeShape function

See Also