Read the change log, man. Replace `add_signal` with `connect_signal`.
On Fri, Jan 04, 2013 at 09:40:39AM +0100, Stefano Di Martino wrote:
> On 03.01.2013 13:36, Piotr Adamus wrote:
> >Hello,
> >
> >I think you must rewrite your widgets:
> >
> >"widget" Library Changes
> >
> >"widget" Library Replacement
> >There is no longer a thing like widget in the API, so different
> >widgets which were provided by its type parameter can be found in
> >different places.
> >One of them is a new module named wibox. Please note that wibox is no
> >longer a part of the standard API, so you need to require("wibox") to
> >use it.
> >textbox
> >Migrated to wibox.widget.textbox()
> >imagebox
> >Migrated to wibox.widget.imagebox()
> >systray
> >Migrated to wibox.widget.systray()
> >
> >Kr.
> >
> >Piotr.
>
> Hi Piotr,
> thx, for your reply. I tried to port this, but I get the following
> error on line 41:
>
> "attempt to call method 'add_signal' (a nil value)"
>
> It's about the timer module which was already deprecated on awesome 3.4.
> Maybe someone can handle this?
>
> 1 local wibox = require("wibox")
> 2 local awful = require("awful")
> 3 --local timer = require("timer")
> 4
> 5 volume_widget = wibox.widget.textbox()
> 6 volume_widget:set_align("right")
> 7
> 8 function update_volume(widget)
> 9 local fd = io.popen("amixer sget Master")
> 10 local status = fd:read("*all")
> 11 fd:close()
> 12
> 13 local volume = tonumber(string.match(status, "(%d?%d?%d)%%")) / 100
> 14 -- volume = string.format("% 3d", volume)
> 15
> 16 status = string.match(status, "%[(o[^%]]*)%]")
> 17
> 18 -- starting colour
> 19 local sr, sg, sb = 0x3F, 0x3F, 0x3F
> 20 -- ending colour
> 21 local er, eg, eb = 0xDC, 0xDC, 0xCC
> 22
> 23 local ir = volume * (er - sr) + sr
> 24 local ig = volume * (eg - sg) + sg
> 25 local ib = volume * (eb - sb) + sb
> 26 interpol_colour = string.format("%.2x%.2x%.2x", ir, ig, ib)
> 27 if string.find(status, "on", 1, true) then
> 28 volume = " <span background='#" .. interpol_colour .. "'>
> </span>"
> 29 else
> 30 volume = " <span color='red' background='#" ..
> interpol_colour .. "'> M </span>"
> 31 end
> 32 widget:set_text(volume)
> 33 end
> 34
> 35 update_volume(volume_widget)
> 36 --awful.hooks.timer.register(1, function ()
> update_volume(volume_widget) end)
> 37
> 38 mytimer = timer({ timeout = 1 })
> 39
> 40 -- error: attempt to call method 'add_signal' (a nil value)
> 41 mytimer:add_signal("timeout", function ()
> update_volume(volume_widget) end)
> 42 mytimer:start()
>
> Best regards
> Stefano
>
> --
> To unsubscribe, send mail to [email protected].
--
PHAM Van Diep
[email protected] - [email protected]
www.favadi.com - (+84) 984 339 841
Phone: (84 4) 3 974 3410 - Ext: 165
System Administrator, Adtech, VCCorp, VN
--
There are 10 types of people,
those who understand binary and those who don't.
--
To unsubscribe, send mail to [email protected].