[LUA / DE] AwesomeWM & Vicious Widgets


 
Thread Tools Search this Thread
Special Forums UNIX Desktop Questions & Answers [LUA / DE] AwesomeWM & Vicious Widgets
# 1  
Old 04-24-2014
[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:
PHP Code:
    -- Volume widget
    hlcolor 
"#d7e0ea"
    
volumewidget wibox.widget.textbox()
    
volumewidget:buttons({
       
button({  }, 4, function () volume("up"volumewidgetend),
       
button({  }, 5, function () volume("down"volumewidgetend),
       
button({  }, 1, function () volume("mute"volumewidgetend)
    })
    
vicious.register(volumewidgetvicious.widgets.volume" Vol: <span color='" .. hlcolor .. "'>$1$2</span> | ",61"Master")
....
globalkeys awful.util.table.join(
....
    -- 
Volume controls Multimedia keysVolume Up/Down Mute
    awful
.key({ }, "XF86AudioRaiseVolume", function () volume("up"volumewidgetend),
    
awful.key({ }, "XF86AudioLowerVolume", function () volume("down"volumewidgetend),
    
awful.key({ }, "XF86AudioMute", function () volume("mute"volumewidgetend), 
Vicious-cpu-temp
PHP Code:
-- cpu C°
    thermwidget 
wibox.widget.textbox()
    
vicious.register(thermwidgetvicious.widgets.thermal"cpu $1 °C"30, { "coretemp.0""core"}) -- ${core} ${proc}
    
    -- 
Author example fails ?!?
    -- 
vicious.register(tempwidgetvicious.widgets.thermal"Temp: <span color='" .. hlcolor .. "'>$1°С</span> | ",37,"thermal_zone0")
    
    -- 
Future try?    -- thermal_zone0 fails :(
    -- 
vicious.register(tempwidgetvicious.widgets.thermal"cpu $1°С",37,"thermal_zone0")
    -- 
sensors|grep "Core 0" |awk '{print $3}' 
The widget used for the CPU temp is thermal.lua:
PHP Code:
-- $ cat /usr/share/awesome/lib/vicious/widgets/thermal.lua 
---------------------------------------------------
-- 
Licensed under the GNU General Public License v2
--  * (c2010Adrian 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")
-- }}}


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


-- {{{ 
Thermal widget type
local 
function worker(formatwarg)
    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:
https://github.com/sri-arjuna/awesome-config (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
[LUA / DE] AwesomeWM &amp; Vicious Widgets-awesomewm-thermal-volume-issuejpg

Last edited by sea; 04-24-2014 at 12:44 PM..
# 2  
Old 04-27-2014
Heyas, keept trying...
PHP Code:
    -- 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 filecat /sys/devices/platform/coretemp.0/temp1_input,
    --         
Folder is availablebut no file indicating to 'temp'eratur or heat.
    
    -- 
Try2:
    -- 
URL:     https://bbs.archlinux.org/viewtopic.php?id=123941
    
-- Reason:     Confirms Try1its just 'temp2_input' nowalso not available on my system
But figured that file was moved even more..
Code:
/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':
Code:
vicious.register(thermwidget, vicious.widgets.thermal, "cpu $1 °C", 30, { "coretemp.0", "core"})

to working on fedora 21:
Code:
vicious.register(thermwidget, vicious.widgets.thermal, "cpu $1 °C", 30, { "coretemp.0/hwmon/hwmon2", "core"})

Hope this helps others too.
Cheerio Smilie

Last edited by sea; 04-27-2014 at 11:23 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

4 More Discussions You Might Find Interesting

1. Programming

[LUA] Set variables according to if file exists

Heya I'm using Awesome WM with the Vicious widget library. As i'm using multi boot, Win8, Fedora and Arch, i have my WM-Config shared accross my GNU/Linux installations. The regarding snippet: -- Functions -- Its just a workaround for an 'unstable' 'hwmon/hwmon' definition of Fedora21 -... (0 Replies)
Discussion started by: sea
0 Replies

2. Shell Programming and Scripting

[LUA-Awesome] Can i use $XDG_XY_DIR inside a lua script?

Heyas I'm a fan of AwesomeWM, but i had failed to learn lua, though, i'm quite satisfied with the cofniguration i have by now. Either way, i'd like to know if i could 'call' those XDG_XY_DIR variables which are located on my linux ~/.config/user-dirs.dirs. While to call scripts i use... (0 Replies)
Discussion started by: sea
0 Replies

3. Infrastructure Monitoring

Nagios widgets to create custom GUI

Hi, I need to create a custom GUI for Nagios, as follows: - no logo - including monitoring info (network status overview, host/service details & status) as well as some network google map I'm looking for Nagios widgets that can be easily integrated in our HTML page. Can you suggest if there... (0 Replies)
Discussion started by: CHK
0 Replies

4. AIX

create widgets using perl pk module

hi I am posting this for my friend... is it possible to create widgets using perl pk module in IBM AIX 5.3? They dont have a GUI so is it possible to create the above mentioned thing in a CUI? thanks! Sathish (1 Reply)
Discussion started by: sathumenon
1 Replies
Login or Register to Ask a Question