You are not logged in.

#1 2011-11-19 16:54:07

slipperysubject
Member
Registered: 2011-11-19
Posts: 3

lua awesomewm widget

hey, i'm messing around with awesomewm for the first time and getting familiar with lua by trying to write some widgets.  my first is a simple battery notifcation widget that uses a text widget and awful progresbar

can anybody tell my why this is crashing awesome?  I am requreing it after awful in my rc.lua and adding both the text and progrsesbar to the wibox

Bw = {
   charge = "n/a",
   time	  = "n/a",

   update = function(self, pbar, time)
	      stats = io.popen('acpi')
	      str = stats:read("*all")
	      self:parse_charge(str)
	      self:parse_time(str)
	      pbar.set_value(self.charge)
	      time.text = self.time
	      end,
   
   parse_charge = function(self, str)
	      match = "%d%d%d?%%"
	      chargeraw = string.match(str, match)
	      chargei = string.sub(chargeraw, 0, -2)
	      self.charge = chargei/100
	    end,

   parse_time = function(self, str)
	      match = "%d%d:%d%d:%d%d"
	      timestr = string.match(str, match)
	      self.time = timestr
	    end
}

bat_text = widget({ type = "textbox", name = "bat_text", align = "right" })
bat_text.text = ""

batprog = awful.widget.progressbar()
batprog:set_width(8)
batprog:set_height(10)
batprog:set_vertical(true)
batprog:set_background_color('#494B4F')
batprog:set_color('#AECF96')
batprog:set_gradient_colors({ '#AECF96', '#88A175', '#FF5656' })

Bw:update(batprog, bat_text)

bwtimer = timer({ timeout = 300 })
bwtimer:add_signal("timeout", function() Bw:update(batprog, bat_text) end)
bwtimer:start()

Offline

#2 2011-11-19 17:08:13

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

Re: lua awesomewm widget

Don't you think including the error would be a good idea?


You need to install an RTFM interface.

Offline

#3 2011-11-19 17:16:34

slipperysubject
Member
Registered: 2011-11-19
Posts: 3

Re: lua awesomewm widget

no error.  awesome fails to load the script and reverts back to default config file, which i know because the theme changes.  awesome -k shows that my config file is fine.

Offline

#4 2011-11-20 21:52:21

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

Re: lua awesomewm widget

no error.

Not possible, read your stderr. Your code is broken somewhere and the lua stack trace will tell you where. I don't have motivation to debug your code line by line.

Edit: if you still can't figure it out, do it like this http://awesome.naquadah.org/wiki/Using_Xephyr

Last edited by anrxc (2011-11-20 21:53:44)


You need to install an RTFM interface.

Offline

#5 2011-11-21 04:47:54

slipperysubject
Member
Registered: 2011-11-19
Posts: 3

Re: lua awesomewm widget

i figured it out by looking at stderr.  problem was pbar.set_time() instead of pbar:set_time().  too used to python and php hmm

thanks for your help.

Offline

#6 2011-11-21 19:47:31

ANOKNUSA
Member
Registered: 2010-10-22
Posts: 2,141

Re: lua awesomewm widget

Hey, slipperysubject.  A couple pointers: first, when you find a solution it's usually good to share it for posterity (which you did) and mark the topic as "Solved;" just edit the title.  Second, as anrxc pointed out, using Xephyr can really save you from a headache if you make a mistake in rc.lua.  There's even a package in the AUR--awmtt--that let's you do this easily.  I use it any time I make changes to rc.lua, even if it's just changing a path to a theme file.

Offline

#7 2011-11-22 01:15:53

xolan
Member
From: Norway
Registered: 2011-11-22
Posts: 1

Re: lua awesomewm widget

You can check .xsession-errors for errors as well.

Offline

Board footer

Powered by FluxBB