Hi,
the next enhancement for naughty to support more of the dbus
notification specs.
Regards,
Leon Winter
>From b2dbad702cb6b85a406dfecf9b8c2e0c6781b12a Mon Sep 17 00:00:00 2001
From: Leon Winter <[EMAIL PROTECTED]>
Date: Wed, 10 Dec 2008 18:55:18 +0100
Subject: [PATCH] naughty: support for categories via mapping
---
lib/naughty.lua.in | 44 +++++++++++++++++++++++++++++++-------------
1 files changed, 31 insertions(+), 13 deletions(-)
diff --git a/lib/naughty.lua.in b/lib/naughty.lua.in
index 49f7275..a89b164 100644
--- a/lib/naughty.lua.in
+++ b/lib/naughty.lua.in
@@ -98,10 +98,6 @@ config.presets = {
}
}
--- Counter for the notifications
--- Required for later access via DBUS
-local counter = 1
-
-- DBUS Notification constants
local urgency = {
low = "\0",
@@ -109,6 +105,23 @@ local urgency = {
critical = "\2"
}
+--- DBUS notification to preset mapping
+-- @name config.mapping
+-- The first element is an object containing the filter
+-- If the rules in the filter matches the associated preset will be applied
+-- The rules object can contain: urgency, category, appname
+-- The second element is the preset
+
+config.mapping = {
+ {{urgency = urgency.low}, config.presets.low},
+ {{urgency = urgency.normal}, config.presets.normal},
+ {{urgency = urgency.critical}, config.presets.critical}
+}
+
+-- Counter for the notifications
+-- Required for later access via DBUS
+local counter = 1
+
--- Index of notifications. See config table for valid 'position' values.
-- Each element is a table consisting of:
-- @field box Wibox object containing the popup
@@ -371,7 +384,7 @@ end
-- DBUS/Notification support
-- Notify
-awful.hooks.dbus.register("org.freedesktop.Notifications", function (data, arg1, replaces_id, icon, title, text, actions, hints, expire)
+awful.hooks.dbus.register("org.freedesktop.Notifications", function (data, appname, replaces_id, icon, title, text, actions, hints, expire)
args = {}
if data.member == "Notify" then
if text ~= "" then
@@ -386,13 +399,18 @@ if data.member == "Notify" then
return nil
end
end
- if hints.urgency == urgency.low then
- args.preset = config.presets.low
- elseif hints.urgency == urgency.normal then
- args.preset = config.presets.normal
- elseif hints.urgency == urgency.critical then
- args.preset = config.presets.critical
- end
+ local score = 0
+ table.foreach(config.mapping, function(i, obj)
+ local filter, preset, s = obj[1], obj[2], 0
+ if filter.urgency and filter.urgency ~= hints.urgency then return end
+ if filter.category and filter.category ~= hints.category then return end
+ if filter.appname and filter.appname ~= appname then return end
+ table.foreach(filter, function(j, el) s = s + 1 end)
+ if s > score then
+ score = s
+ args.preset = preset
+ end
+ end)
if icon ~= "" then
args.icon = icon
end
--
1.5.6.5