diff --git a/lib/naughty/dbus.lua b/lib/naughty/dbus.lua index 67be524c..3c8d2089 100644 --- a/lib/naughty/dbus.lua +++ b/lib/naughty/dbus.lua @@ -141,9 +141,12 @@ function notif_methods.Notify(sender, object_path, interface, method, parameters return end end + if appname ~= "" then - args.appname = appname + args.appname = appname --TODO v6 Remove this. + args.app_name = appname end + local preset = args.preset or cst.config.defaults local notification if actions then diff --git a/lib/naughty/layout/box.lua b/lib/naughty/layout/box.lua index 79ab70e9..a4846794 100644 --- a/lib/naughty/layout/box.lua +++ b/lib/naughty/layout/box.lua @@ -17,6 +17,7 @@ local popup = require("awful.popup") local awcommon = require("awful.widget.common") local placement = require("awful.placement") local abutton = require("awful.button") +local dpi = require("beautiful").xresources.apply_dpi local default_widget = require("naughty.widget._default") @@ -136,9 +137,13 @@ end local function generate_widget(args, n) local w = wibox.widget.base.make_widget_from_value( - args.widget_template or default_widget + args.widget_template or (n and n.widget_template) or default_widget ) + if w.set_width then + w:set_width(n.max_width or beautiful.notification_max_width or dpi(500)) + end + -- Call `:set_notification` on all children awcommon._set_common_property(w, "notification", n or args.notification) @@ -224,7 +229,7 @@ local function new(args) new_args = args and setmetatable(new_args, {__index = args}) or new_args -- Generate the box before the popup is created to avoid the size changing - new_args.widget = generate_widget(new_args) + new_args.widget = generate_widget(new_args, new_args.notification) local ret = popup(new_args) ret._private.args = new_args diff --git a/lib/naughty/notification.lua b/lib/naughty/notification.lua index 81205386..72ecab22 100644 --- a/lib/naughty/notification.lua +++ b/lib/naughty/notification.lua @@ -407,6 +407,31 @@ local notification = {} -- @property clients -- @param table +--- The maximum popup width. +-- +-- Some notifications have overlong message, cap them to this width. Note that +-- this is ignored by `naughty.list.notifications` because it delegate this +-- decision to the layout. +-- +-- @property[opt=500] max_width +-- @param number + +--- The application name specified by the notification. +-- +-- This can be anything. It is usually less relevant than the `clients` +-- property, but can sometime to specified for remote or headless notifications. +-- In these case, it helps to triage and detect the notification from the rules. +-- @property app_name +-- @param string + +--- The widget template used to represent the notification. +-- +-- Some notifications, such as chat messages or music applications are better +-- off with a specialized notification widget. +-- +-- @property widget_template +-- @param table + --FIXME remove the screen attribute, let the handlers decide -- document all handler extra properties @@ -526,7 +551,8 @@ local properties = { "shape" , "opacity" , "margin" , "ignore_suspend", "destroy" , "preset" , "callback", "actions" , "run" , "id" , "ignore" , "auto_reset_timeout", - "urgency" , "image" , "images" , + "urgency" , "image" , "images" , "widget_template", + "max_width", "app_name", } for _, prop in ipairs(properties) do