Hullo, a little continuation of recent naughty love - tidy environment is important :)
More (importantly) to come - I'm trying to tackle a pretty severe bug I've been seeing recently. When we have a single notification in the screen which takes up the whole space, as soon as another popup replaces it, positioning of any further notifications goes to deep misery. This is not easy to track down since I can't watch variable values using... naughty and print doesn't help much these days. koniu
From 03fe4ad49e7123749152c435b6192a799099e194 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 3122083..1528fd7 100644 --- a/lib/naughty.lua.in +++ b/lib/naughty.lua.in @@ -7,19 +7,18 @@ -- Package environment local pairs = pairs local table = table -local wibox = wibox -local image = image local type = type -local hooks = require("awful.hooks") local string = string -local widget = widget +local capi = { screen = screen, + awesome = awesome, + dbus = dbus, + widget = widget, + wibox = wibox, + image = image } +local hooks = require("awful.hooks") 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") @@ -103,7 +102,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 = {}, @@ -202,7 +201,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 @@ -309,7 +308,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 = margin, left = margin, bottom = 2 * margin }) textbox.text = string.format('<span font_desc="%s"><b>%s</b>%s</span>', font, title, text) @@ -319,17 +318,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 @@ -344,11 +343,11 @@ function notify(args) end -- create container wibox - notification.box = wibox({ position = "floating", - fg = fg, - bg = bg, - border_color = border_color, - border_width = border_width }) + notification.box = capi.wibox({ position = "floating", + fg = fg, + bg = bg, + border_color = border_color, + border_width = border_width }) -- calculate the height if not height then @@ -398,8 +397,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 @@ -449,7 +448,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 @@ -473,7 +472,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 @@ -517,7 +516,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
