OK, that was for next and it can as well go to master, here's the patch on top of that.
Dunno how it will behave with patches in next tho, maybe better push the 1st one to next and forget this one... your choice B^] koniu
From d3b27865c7de7adaac1306a365650d736395d554 Mon Sep 17 00:00:00 2001 From: koniu <[email protected]> Date: Fri, 8 May 2009 08:01:14 +0100 Subject: [PATCH] naughty: environment cleanup Makes naughty environment handling same as awful modules: - relevant capi members all go to local capi = {} - relevant awful members are all implicitly required Signed-off-by: koniu <[email protected]> --- lib/naughty.lua.in | 47 +++++++++++++++++++++++------------------------ 1 files changed, 23 insertions(+), 24 deletions(-) diff --git a/lib/naughty.lua.in b/lib/naughty.lua.in index 45ec3b5..8a34527 100644 --- a/lib/naughty.lua.in +++ b/lib/naughty.lua.in @@ -7,20 +7,19 @@ -- Package environment local pairs = pairs local table = table -local wibox = wibox -local image = image local type = type +local string = string local tostring = tostring +local capi = { screen = screen, + awesome = awesome, + dbus = dbus, + widget = widget, + wibox = wibox, + image = image } local hooks = require("awful.hooks") -local string = string -local widget = widget local button = require("awful.button") local util = require("awful.util") -local capi = { screen = screen, awesome = awesome } local bt = require("beautiful") -local screen = screen -local awful = awful -local dbus = dbus --- Notification library module("naughty") @@ -139,7 +138,7 @@ local counter = 1 -- @class table notifications = {} -for s = 1, screen.count() do +for s = 1, capi.screen.count() do notifications[s] = { top_left = {}, top_right = {}, @@ -238,7 +237,7 @@ local function getIcon(name) for d, dir in pairs(config.icon_dirs) do for f, format in pairs(config.icon_formats) do local icon = dir .. name .. "." .. format - if awful.util.file_readable(icon) then + if util.file_readable(icon) then return icon end end @@ -327,7 +326,7 @@ function notify(args) end -- create textbox - local textbox = widget({ type = "textbox", align = "flex" }) + local textbox = capi.widget({ type = "textbox", align = "flex" }) textbox:buttons(util.table.join(button({ }, 1, run), button({ }, 3, die))) textbox:margin({ right = config.margin, left = config.margin }) textbox.text = string.format('<span font_desc="%s"><b>%s</b>%s</span>', font, title, text) @@ -337,17 +336,17 @@ function notify(args) local iconbox = nil if icon then -- try to guess icon if the provided one is non-existent/readable - if type(icon) == "string" and not awful.util.file_readable(icon) then + if type(icon) == "string" and not util.file_readable(icon) then icon = getIcon(icon) end -- if we have an icon, use it if icon then - iconbox = widget({ type = "imagebox", align = "left" }) + iconbox = capi.widget({ type = "imagebox", align = "left" }) iconbox:buttons(util.table.join(button({ }, 1, run), button({ }, 3, die))) local img if type(icon) == "string" then - img = image(icon) + img = capi.image(icon) else img = icon end @@ -362,11 +361,11 @@ function notify(args) end -- create container wibox - notification.box = wibox({ position = "floating", - fg = fg, - bg = bg, - border_color = args.preset and args.preset.border_color or config.presets.normal.border_color, - border_width = config.border_width }) + notification.box = capi.wibox({ position = "floating", + fg = fg, + bg = bg, + border_color = args.preset and args.preset.border_color or config.presets.normal.border_color, + border_width = config.border_width }) -- position the wibox local lines = 1; for i in string.gmatch(title..text, "\n") do lines = lines + 1 end @@ -397,8 +396,8 @@ end -- DBUS/Notification support -- Notify -if awful.hooks.dbus then - awful.hooks.dbus.register("org.freedesktop.Notifications", function (data, appname, replaces_id, icon, title, text, actions, hints, expire) +if hooks.dbus then + hooks.dbus.register("org.freedesktop.Notifications", function (data, appname, replaces_id, icon, title, text, actions, hints, expire) args = { preset = { } } if data.member == "Notify" then if text ~= "" then @@ -448,7 +447,7 @@ if awful.hooks.dbus then end end if imgdata then - args.icon = image.argb32(hints.icon_data[1], hints.icon_data[2], imgdata) + args.icon = capi.image.argb32(hints.icon_data[1], hints.icon_data[2], imgdata) end end if replaces_id and replaces_id ~= "" and replaces_id ~= 0 then @@ -472,7 +471,7 @@ if awful.hooks.dbus then end end) - awful.hooks.dbus.register("org.freedesktop.DBus.Introspectable", + hooks.dbus.register("org.freedesktop.DBus.Introspectable", function (data, text) if data.member == "Introspect" then local xml = [=[<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object @@ -516,7 +515,7 @@ if awful.hooks.dbus then end) -- listen for dbus notification requests - dbus.request_name("session", "org.freedesktop.Notifications") + capi.dbus.request_name("session", "org.freedesktop.Notifications") end -- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80 -- 1.6.2.4
