Reputation: 23
I am configuring the widgets in awesome wm (v3.5.5-1) using vicious (v2.1.3-1). I want to show the time in a widget. And then show the date in the tooltip when I hover over the time widget.
The following code using vicious in my rc.lua file works fine:
myclock = wibox.widget.textbox()
vicious.register(myclock, vicious.widgets.date, " <span color='#ffffff'>%H:%M</span> ")
myclock_tooltip = awful.tooltip ({ objects = { myclock } })
vicious.register(myclock_tooltip, vicious.widgets.date, " %a %d %b ", 60)
However, when I try to combine the two vicious.register
statements (based on the Format functions section of the vicious readme file):
myclock = wibox.widget.textbox()
myclock_tooltip = awful.tooltip ({ objects = { myclock } })
vicious.register(myclock, vicious.widgets.date,
function (widget, args)
myclock_tooltip.set_text(" %a %d %b ")
return " <span color='#ffffff'>%H:%M</span> "
end)
I get the following error:
/usr/share/lua/5.2/vicious/widgets/date.lua:23: bad argument #1 to 'date' (string expected, got function)
Any suggestions where I'm going wrong?
Upvotes: 2
Views: 1290
Reputation: 9867
Why do you need that format function at all? Doesn't the following work?
myclock = wibox.widget.textbox()
myclock_tooltip = awful.tooltip ({ objects = { myclock } })
vicious.register(myclock, vicious.widgets.date, " <span color='#fffff'>%H:%M</span> ")
myclock_tooltip_timer = timer({ timeout = 3600 })
myclock_tooltip_timer:connect_signal("timeout", function()
myclock_tooltip:set_text(os.date(" %a %d %b "))
end)
myclock_tooltip_timer:start()
myclock_tooltip_timer:emit_signal("timeout")
This uses the "normal" vicious stuff for the widget and updates your tooltip with a seperate timer which fires once per hour.
Upvotes: 2
Reputation: 80951
I don't believe you are doing anything wrong from a technical perspective. I think (and a quick look at the source confirms) that that widget just doesn't accept a function format.
It looks like some widgets take format strings (to be used by the widget function) and some accept format functions (to be called with the result of the widget function) but I don't see any clear indication from that README which are which.
Compare the worker
function in date.lua against the worker
function in uptime.lua for example.
The date.lua
function uses the format
argument in a call to os.date
(which is what is generating the error you are getting, try calling os.date(function()end)
locally).
The uptime.lua
function does not use the format
argument at all (presumably it gets called by vicious
internally on the return value from that function.
It is probably worth asking to get the documentation updated to make this clearer (or fixing the documentation up yourself and submitting a patch for it).
Upvotes: 1