Hi,

i added callbacks to presets that will be called if naughty gets beaten
via DBUS. this way we could update a textbox with the current song
playing if our music player gives us the information via DBUS.

Here is an example for gnome-mplayer (your rc.lua and your pleasure):

-- you need a textbox widget called musicbox for this example
naughty.config.presets.music = {callback = function(data, appname,
replaces_id, icon, title, text, actions, hints, expire)
    musicbox.text = " " ..
tostring(text:gsub("</?%w+>",""):gsub("\n","")) .. " "
    return true
end, bg = "#ffffff", fg = "#000000"
}

table.insert(naughty.config.mapping, {{appname = "gnome-mplayer"},
naughty.config.presets.music})


The second patch is just a minor change for naughty for to provide the
correct awesome version if there was a friendly question via DBUS.

Regards,
Leon Winter

p.s. not concerning naughty, but interesting to me is the state of the
imlib/crop_and_scale-issue, any news?
>From 1439834536dda82f35bc2776ed771db4ead22988 Mon Sep 17 00:00:00 2001
From: Leon Winter <[email protected]>
Date: Wed, 17 Dec 2008 17:47:23 +0100
Subject: [PATCH] naughty: add callbacks for presets

---
 lib/naughty.lua.in |   28 ++++++++++++++++++----------
 1 files changed, 18 insertions(+), 10 deletions(-)

diff --git a/lib/naughty.lua.in b/lib/naughty.lua.in
index 9b62c75..3033063 100644
--- a/lib/naughty.lua.in
+++ b/lib/naughty.lua.in
@@ -9,6 +9,7 @@ local pairs = pairs
 local table = table
 local wibox = wibox
 local image = image
+local type = type
 local tostring = tostring
 local hooks = require("awful.hooks")
 local string = string
@@ -76,6 +77,9 @@ config.border_width = 1
 -- @field height Height of a single line of text. Default: 16
 -- @field icon Popup icon. Default: nil
 -- @field icon_size Size of the icon in pixels. Default: nil
+-- @field callback function that will be called with all arguments
+--  the notification will only be displayed if the function returns true
+--  note: this function is only relevant to notifications sent via dbus
 
 config.presets = {
     low = {
@@ -413,17 +417,21 @@ if data.member == "Notify" then
             end
         end
     end
-    if icon ~= "" then
-        args.icon = icon
-    end
-    if replaces_id and replaces_id ~= "" and replaces_id ~= 0 then
-        args.replaces_id = replaces_id
-    end
-    if expire and expire > -1 then
-        args.timeout = expire / 1000
+    if not args.preset.callback or (type(args.preset.callback) == "function" and
+        args.preset.callback(data, appname, replaces_id, icon, title, text, actions, hints, expire)) then
+        if icon ~= "" then
+            args.icon = icon
+        end
+        if replaces_id and replaces_id ~= "" and replaces_id ~= 0 then
+            args.replaces_id = replaces_id
+        end
+        if expire and expire > -1 then
+            args.timeout = expire / 1000
+        end
+        local id = notify(args).id
+        return "i", id
     end
-    local id = notify(args).id
-    return "i", id
+    return "i", "0"
 elseif data.member == "CloseNotification" then
     local obj = getById(arg1)
     if obj then
-- 
1.5.6.5

>From d25252de67c52cf7367a767100f850ba88f405da Mon Sep 17 00:00:00 2001
From: Leon Winter <[email protected]>
Date: Wed, 17 Dec 2008 17:50:44 +0100
Subject: [PATCH] naughty: return correct awesome version via dbus

---
 lib/naughty.lua.in |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/lib/naughty.lua.in b/lib/naughty.lua.in
index 3033063..403c2d6 100644
--- a/lib/naughty.lua.in
+++ b/lib/naughty.lua.in
@@ -439,7 +439,7 @@ elseif data.member == "CloseNotification" then
     end
 elseif data.member == "GetServerInfo" or data.member == "GetServerInformation" then
     -- name of notification app, name of project, version of notification app, project version
-    return "s", "naughty", "s", "awesome", "s", "1337", "s", "1337"
+    return "s", "naughty", "s", "awesome", "s", "@AWESOME_VERSION@", "s", "1337"
 end
 end)
 
-- 
1.5.6.5

Reply via email to