You are not logged in.

#1 2009-08-06 11:28:59

UQ-igor
Member
Registered: 2009-03-05
Posts: 42

Awesome widget problem

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

#2 2009-08-06 16:04:58

jdiez
Member
Registered: 2009-08-03
Posts: 40

Re: Awesome widget problem

Can you post Awesome logs?

Offline

#3 2009-08-06 16:15:15

Crows
Member
From: Wales
Registered: 2008-09-05
Posts: 92

Re: Awesome widget problem

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

#4 2009-08-06 16:33:16

anrxc
Member
From: Croatia
Registered: 2008-03-22
Posts: 834
Website

Re: Awesome widget problem

UQ-igor wrote:

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

#5 2009-08-07 10:35:31

UQ-igor
Member
Registered: 2009-03-05
Posts: 42

Re: Awesome widget problem

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

#6 2009-08-07 13:05:36

UQ-igor
Member
Registered: 2009-03-05
Posts: 42

Re: Awesome widget problem

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

#7 2009-08-07 16:04:00

anrxc
Member
From: Croatia
Registered: 2008-03-22
Posts: 834
Website

Re: Awesome widget problem

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

#8 2009-08-07 16:49:27

Crows
Member
From: Wales
Registered: 2008-09-05
Posts: 92

Re: Awesome widget problem

anrxc wrote:

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

#9 2009-08-08 08:43:43

UQ-igor
Member
Registered: 2009-03-05
Posts: 42

Re: Awesome widget problem

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

Board footer

Powered by FluxBB