Hi,
I use awesome for some time and I think that it is even more awesome than just
awesome.
But one thing was disturbing me - huge notifications. Sometimes I get really
large notifications from IM and I wasn't able to make them smaller.
Now, this patch adds two variables to nughty's notifications:
max_width
min_width
Names talk for themselves.
What does this patch do? Well, it calculates width nedded to display notify and
and substracts margins and the eventual iconboxs width and with that value
modifies the text wifth wful.util.linewrap.
Hope it'll be useful
grodzik
--- naughty.lua.orig 2010-02-12 08:05:59.000000000 +0100
+++ naughty.lua 2010-02-12 08:05:26.000000000 +0100
@@ -255,6 +255,8 @@
local ontop = args.ontop or preset.ontop or true
local width = args.width or preset.width
local height = args.height or preset.height
+ local max_width = args.max_width or preset.max_width or nil
+ local min_width = args.min_width or preset.min_width or nil
local hover_timeout = args.hover_timeout or preset.hover_timeout
local opacity = args.opacity or preset.opacity
local margin = args.margin or preset.margin or "5"
@@ -364,6 +366,34 @@
if hover_timeout then notification.box:add_signal("mouse::enter",
hover_destroy) end
+ -- calculate the width
+ if not width then
+ width = textbox:extents().width + (iconbox and iconbox:extents().width
+ 2 * margin or 0) + 2 * margin
+ if min_width and min_width > width then
+ width = min_width
+ end
+ if max_width and max_width < width then
+ width = max_width
+ local l = textbox:extents().width / (width - ( iconbox and
iconbox:extents().width + 2 * margin or 0) - 2 * margin)
+ textbox.text = string.format('<span
font_desc="%s"><b>%s</b>%s</span>',
+ font,
+ util.linewrap(title, #title / l, 0),
+ util.linewrap(text:gsub("<br.->", "\n"), #text / l, 0))
+ end
+ else
+ if max_width and max_width < width then
+ width = max_width
+ end
+ if min_width and min_width > width then
+ width = min_width
+ end
+ local l = textbox:extents().width / (width - ( iconbox and
iconbox:extents().width + 2 * margin or 0) - 2 * margin)
+ textbox.text = string.format('<span font_desc="%s"><b>%s</b>%s</span>',
+ font,
+ util.linewrap(title, #title / l, 0),
+ util.linewrap(text:gsub("<br.->", "\n"), #text / l, 0))
+ end
+
-- calculate the height
if not height then
if iconbox and iconbox:extents().height + 2 * margin >
textbox:extents().height + 2 * margin then
@@ -373,10 +403,6 @@
end
end
- -- calculate the width
- if not width then
- width = textbox:extents().width + (iconbox and iconbox:extents().width
+ 2 * margin or 0) + 2 * margin
- end
-- crop to workarea size if too big
local workarea = capi.screen[screen].workarea