[LUA / DE] AwesomeWM & Vicious Widgets

Hello

Allthough i dont know LUA, despite its name, i do love the window manager that was created using that language.
By now, I'm enough familiar with LUA so i could adapt (most of) the recent changes so i have vicous widgets working again - by the means of no error messages on start up.

I managed to get the wifi info back, the volume value is shown, the hdd temp too and power left/until full works now too...
It was already challenging prior to the (upstream) changes done recently (6months) as the syntax was changed (vicious).
So, i managed to fix code i dont (really) understand, but got 'used' to, according to a syntax that had changed to something that i'm yet to explore...

What i want is help with:

  • "Change output volume" (button press produce error message), also neither
  • CPU temp

--------------------------------------------------
Contents of rc.lua - most of this is copy-pasted from diffrent sites and then little modified
--------------------------------------------------
Vicous-Volume-Control:

    -- Volume widget
	hlcolor = "#d7e0ea"
	volumewidget = wibox.widget.textbox()
	volumewidget:buttons({
	   button({  }, 4, function () volume("up", volumewidget) end),
	   button({  }, 5, function () volume("down", volumewidget) end),
	   button({  }, 1, function () volume("mute", volumewidget) end)
	})
	vicious.register(volumewidget, vicious.widgets.volume, " Vol: <span color='" .. hlcolor .. "'>$1$2</span> | ",61, "Master")
....
globalkeys = awful.util.table.join(
....
    -- Volume controls | Multimedia keys: Volume Up/Down Mute
    awful.key({ }, "XF86AudioRaiseVolume", function () volume("up", volumewidget) end),
    awful.key({ }, "XF86AudioLowerVolume", function () volume("down", volumewidget) end),
    awful.key({ }, "XF86AudioMute", function () volume("mute", volumewidget) end),

Vicious-cpu-temp

-- cpu C�
	thermwidget = wibox.widget.textbox()
	vicious.register(thermwidget, vicious.widgets.thermal, "cpu $1 �C", 30, { "coretemp.0", "core"}) -- ${core} ${proc}
	
	-- Author example fails ?!?
	-- vicious.register(tempwidget, vicious.widgets.thermal, "Temp: <span color='" .. hlcolor .. "'>$1�</span> | ",37,"thermal_zone0")
	
	-- Future try?	-- thermal_zone0 fails :(
	-- vicious.register(tempwidget, vicious.widgets.thermal, "cpu $1�",37,"thermal_zone0")
	-- sensors|grep "Core 0" |awk '{print $3}'

The widget used for the CPU temp is thermal.lua:

-- $ cat /usr/share/awesome/lib/vicious/widgets/thermal.lua 
---------------------------------------------------
-- Licensed under the GNU General Public License v2
--  * (c) 2010, Adrian C. <anrxc@sysphere.org>
---------------------------------------------------

-- {{{ Grab environment
local type = type
local tonumber = tonumber
local setmetatable = setmetatable
local string = { match = string.match }
local helpers = require("vicious.helpers")
-- }}}


-- Thermal: provides temperature levels of ACPI and coretemp thermal zones
-- vicious.widgets.thermal
local thermal = {}


-- {{{ Thermal widget type
local function worker(format, warg)
    if not warg then return end

    local zone = { -- Known temperature data sources
        ["sys"]  = {"/sys/class/thermal/",     file = "temp",       div = 1000},
        ["core"] = {"/sys/devices/platform/",  file = "temp2_input",div = 1000},
        ["proc"] = {"/proc/acpi/thermal_zone/",file = "temperature"}
    } --  Default to /sys/class/thermal
    warg = type(warg) == "table" and warg or { warg, "sys" }

    -- Get temperature from thermal zone
    local _thermal = helpers.pathtotable(zone[warg[2]][1] .. warg[1])

    local data = warg[3] and _thermal[warg[3]] or _thermal[zone[warg[2]].file]
    if data then
        if zone[warg[2]].div then
            return {data / zone[warg[2]].div}
        else -- /proc/acpi "temperature: N C"
            return {tonumber(string.match(data, "[%d]+"))}
        end
    end

    return {0}
end
-- }}}

return setmetatable(thermal, { __call = function(_, ...) return worker(...) end })

I hope these code segments are sufficant, otherwise the full config can be found at:
GitHub - sri-arjuna/awesome: Customized ~/.config/awesome (Vicious)

Basicly my issue is this, i dont know what to pass to the vicious.widgets (thermal,volume) to get the desired values/behaviour.

Thank you in advance

EDIT:

  • CPU/MEM usage did work, the laptop just didnt use those much, so i didnt see any change of a flat line.
  • Figured ${link} is signal strength for wifi device.
  • Updated screenshot
  • Added thermal.lua code, in hope of help

Heyas, keept trying...

	-- INFO SYSTEM --
	-- cat /etc/system-release ; uname -r
	-- Fedora release 21 (Rawhide)
	-- 3.15.0-0.rc2.git0.1.fc21.x86_64
	
	-- Try1:
	-- URL: 	http://xor0110.wordpress.com/2010/05/10/cpu-core-temperature-with-vicious-without-acpi/
	-- Reason:  	He refers to a file: cat /sys/devices/platform/coretemp.0/temp1_input,
	-- 		Folder is available, but no file indicating to 'temp'eratur or heat.
	
	-- Try2:
	-- URL: 	https://bbs.archlinux.org/viewtopic.php?id=123941
	-- Reason: 	Confirms Try1, its just 'temp2_input' now, also not available on my system.

But figured that file was moved even more..

/sys/devices/platform/coretemp.0/temp1_input
vs
/sys/devices/platform/coretemp.0/hwmon/hwmon2/temp[0-5]_input

At first i though i need to change the widget...
But on closer look figure i could change my rc.lua too.

Solved by changing 'orginal & working for most':

vicious.register(thermwidget, vicious.widgets.thermal, "cpu $1 �C", 30, { "coretemp.0", "core"})

to working on fedora 21:

vicious.register(thermwidget, vicious.widgets.thermal, "cpu $1 �C", 30, { "coretemp.0/hwmon/hwmon2", "core"})

Hope this helps others too.
Cheerio :slight_smile: