You are not logged in.
Hi,
I'm trying to write some widgets for awesome following the examples i found around the web. I wrote a couple of simple ones that work, and then I wrote the one below which doesn't work; it basically crashes awesome, but I can't figure out why.
cpuSpeedWidget = widget({ type = "textbox", name = "cpuspeed", align = "left" })
function get_cpu_speed()
local filedescriptor = io.popen('cat /proc/cpuinfo | egrep GHz | cut -c54-70')
local speed = filedescriptor:read()
filedescriptor.close()
return {speed}
end
wicked.register(cpuspeed, get_cpu_speed, ' <span color="white">Clock: </span>$1 ', 60)
Also, is there a wicked reference somewhere like the awesome LUA reference under Docs on the awesome homepage?
Thanks!
-Igor
Last edited by UQ-igor (2009-08-06 11:29:40)
Offline
Can you post Awesome logs?
Offline
Try this:
local speed = filedescriptor:read("*a") --Set read mode as read all.
and
filedescriptor:close() --Needs to be a colon, not a period.
also,
return speed
Why are you using brackets there btw? Note that the wicked register stuff may need changing too, but this should sort out the main bit.
Last edited by Crows (2009-08-06 16:17:11)
Offline
local filedescriptor = io.popen('cat /proc/cpuinfo | egrep GHz | cut -c54-70')
This looks ugly. I have a CPU information widget, in Lua, you might want to check that.
Last edited by anrxc (2009-08-06 16:35:23)
You need to install an RTFM interface.
Offline
Hmm, I tried making changes as Crows suggested but it didn't help, awesome still fails to (re)start.
I ordered a book on LUA since it seems like a nice language to learn; so far i've only been imitating syntax I saw in random dotfiles I found around the web.
I'm digging through anrxc's dotfiles now, and actually getting a much better idea of how LUA works thanks to this. I think i might butcher up your rc.lua anrxc! Hvala!
-igor
Offline
anrxc: I tried using vicious, I hacked up a config file for awesome using vicious, and then added a stripped down version of your widget section. Simple widgets such as seperators (textboxes) and imageboxes work fine. If I add a widget that does any number crunching such as cpu widget, awesome crashes. I'm running awesome 3.3.1 (Bionic). Could this be the problem?
-igor
Offline
You are doing something wrong. In both cases, your widget or my widget, you should use Xephyr to debug. It's the most convenient way of debugging awesome, you don't have to restart X and everything is printed to the terminal emulator where you started the second instance of awesome. You can also place "print(something)" in any suspicious part of rc.lua. to do checks. If you never used Xephyr use this tutorial: http://awesome.naquadah.org/wiki/Using_Xephyr
You need to install an RTFM interface.
Offline
you should use Xephyr to debug.
+1 vote for Xeph. Incredibly useful. I assume the book you're talking about is Programming in Lua? If yes, got it myself a few weeks ago. Very good read. It has a lot of useful stuff in it that isn't in the online first version.
I'm currently setting up my rc.lua for some new stuff. At some point I'll be making a CPU widget. I'll post the code if you want.
Offline
Yeah, I got Programming in LUA as well, but it might take a while to arrive here (got it from Amazon US, shipping to Australia). Anyway, I'm still struggling with some LUA concepts, but the book should clear it all up.
Plz post the code for CPU widget when you write one!
Thanks,
-Igor
Offline