On Sun, Jul 12, 2009 at 12:28 PM, Andrei Thorp<gar...@gmail.com> wrote: > I just thought I'd mention that I'm working on this. It's really buggy though.
Okay, I'm done. Honestly, though, masterLoki: learn to test your stuff. Learn to read the output of awesome and log it. This had lua syntax errors, logic errors, comparisons between strings and ints, and a terrible style with 3 space indents, 4 space indents, and tabs. I understand it's rough work... but I changed/rewrote nearly every line in your code to make it run. Please learn to debug your code in the future. Ask on IRC if you don't know how to debug Awesome code. That said, thanks for the effort. You still need to put in a fair bit more work to add settings (not everyone wants to use that temp zone, and if they don't have it, this crashes!), the readme needs to be written, and features added. Also, please read the patch I wrote on top of yours to fix it to understand where you went wrong. Please also do not make patches with trailing whitespace or backup files included (You had a hidden init.lua~ file that I guess gedit made). Oh, also! I've pushed up your patch + my fixes to the obvious repo, temperature-widget branch. This isn't in master yet because it needs a lot more work. Also see attached. Cheers!
From 4c8e0264aacf1eb047a6a0a37680f4b798205a7f Mon Sep 17 00:00:00 2001 From: Andrei 'Garoth' Thorp <gar...@gmail.com> Date: Sun, 12 Jul 2009 12:42:24 -0400 Subject: [PATCH] Temp Info: Fixed a ton of bugs to make this work --- init.lua | 1 + temp_info/init.lua | 41 +++++++++++++++++++++++++---------------- temp_info/init.lua~ | 44 -------------------------------------------- 3 files changed, 26 insertions(+), 60 deletions(-) delete mode 100644 temp_info/init.lua~ diff --git a/init.lua b/init.lua index 743cac4..c2ff0ef 100644 --- a/init.lua +++ b/init.lua @@ -8,5 +8,6 @@ require("obvious.battery") require("obvious.volume_alsa") require("obvious.wlan") require("obvious.popup_run_prompt") +require("obvious.temp_info") module("obvious") diff --git a/temp_info/init.lua b/temp_info/init.lua index 0988adf..02e480e 100644 --- a/temp_info/init.lua +++ b/temp_info/init.lua @@ -4,39 +4,48 @@ ----------------------------------- local awful = require("awful") - +local setmetatable = setmetatable +local tonumber = tonumber +local tostring = tostring +local type = type +local print = print local capi = { widget = widget, screen = screen } -module("obvious.temp_zone") - +module("obvious.temp_info") + widget = capi.widget({ type = "textbox", - name = "temp_zone", - align = "right" + name = "temp_zone", + align = "right" }) -colors{ +colors = { normal = "#009000", warm = "#909000", hot = "#900000" } -local function update(_zone) - local temp = awful.util.pread('awk \'{print $2 "°C"}\' /proc/acpi/thermal_zone/'.._zone..'/temperature') +function update(_zone) + local temp = awful.util.pread('awk \'{print $2}\' /proc/acpi/thermal_zone/'.._zone..'/temperature') + temp = tonumber(temp) local color if temp < 50 then - color = colors[normal] + color = colors["normal"] + elseif temp >= 50 and temp < 60 then + color = colors["warm"] else - if temp >= 50 and temp < 60 then - color = colors[warm] - else - color = colors[hot] - widget.text = " ".._zone.." :: <span color=\""..color.."\">"..temp.." </span> " + color = colors["hot"] + end + temp = tostring(temp) .. "°C" + widget.text = _zone.." :: <span color=\""..color.."\">"..temp.."</span>" end +update("TZ00") + +awful.hooks.timer.register(5, function () update("TZ00") end) -awful.hooks.timer.register(5, update) +setmetatable(_M, { __call = function () return widget end }) -setmetatable(_M, { __call = function ("TZS0") return widget end }) +-- vim: filetype=lua:expandtab:shiftwidth=3:tabstop=3:softtabstop=3:encoding=utf-8:textwidth=80 diff --git a/temp_info/init.lua~ b/temp_info/init.lua~ deleted file mode 100644 index 4596e52..0000000 --- a/temp_info/init.lua~ +++ /dev/null @@ -1,44 +0,0 @@ ------------------------------------ --- Author: Eligio Becerra -- --- Copyright 2009 Eligio Becerra -- ------------------------------------ - -local awful = require("awful") -local beautiful = require("beautiful") -local naughty = require("naughty") - -local capi = { - widget = widget, - screen = screen -} - -module("obvious.temp_zone") - -widget = capi.widget({ - type = "textbox", - name = "temp_zone", - align = "right" -}) - -colors{ - normal = "#009000", - warm = "#909000", - hot = "#900000" -} - -local function update(_zone) - local temp = awful.util.pread('awk \'{print $2 "°C"}\' /proc/acpi/thermal_zone/'..zone..'/temperature') - local color - if temp < 50 then - color = colors[normal] - else - if temp >= 50 and temp < 60 then - color = colors[warm] - else - color = colors[hot] - widget.text = " ".._zone.." :: <span color=\""..color.."\">"..temp.." </span> " -end - -awful.hooks.timer.register(5, update) - -setmetatable(_M, { __call = function ("TZS0") return widget end }) -- 1.6.3.3