2009-09-29 22:33:19 +02:00
|
|
|
---------------------------------------------------
|
|
|
|
-- Licensed under the GNU General Public License v2
|
2010-01-02 21:21:54 +01:00
|
|
|
-- * (c) 2010, Adrian C. <anrxc@sysphere.org>
|
2009-09-29 22:33:19 +02:00
|
|
|
---------------------------------------------------
|
Import of vicious source tree.
Vicious is a modular widget library for 'awesome' window manager,
derived from the 'Wicked' widget library.
Summary of changes:
* Original wicked code modularized
* Widgets ported from Wicked:
- CPU, MEM, FS, NET, Date, Uptime, MPD
* CPU widget rewritten, uses pattern matching
* MEM widget rewritten, uses pattern matching
- Swap widget merged with MEM widget type
* FS widget rewritten, uses pattern matching
- Also fixed padding in the process
* NET widget rewritten, uses pattern matching
* MPD widget rewritten, a bit more versatile
* Removed deprecated helper functions
* Widgets written for Vicious:
- Thermal, Battery, Mbox, OrgMode, Volume, Entropy,
Disk I/O, System Load, Wireless, Pacman, Maildir
2009-07-29 17:59:32 +02:00
|
|
|
|
|
|
|
-- {{{ Grab environment
|
2010-02-10 02:49:26 +01:00
|
|
|
local type = type
|
|
|
|
local tonumber = tonumber
|
2009-08-01 23:11:41 +02:00
|
|
|
local setmetatable = setmetatable
|
2010-02-10 02:49:26 +01:00
|
|
|
local string = { match = string.match }
|
2009-11-11 02:57:30 +01:00
|
|
|
local helpers = require("vicious.helpers")
|
Import of vicious source tree.
Vicious is a modular widget library for 'awesome' window manager,
derived from the 'Wicked' widget library.
Summary of changes:
* Original wicked code modularized
* Widgets ported from Wicked:
- CPU, MEM, FS, NET, Date, Uptime, MPD
* CPU widget rewritten, uses pattern matching
* MEM widget rewritten, uses pattern matching
- Swap widget merged with MEM widget type
* FS widget rewritten, uses pattern matching
- Also fixed padding in the process
* NET widget rewritten, uses pattern matching
* MPD widget rewritten, a bit more versatile
* Removed deprecated helper functions
* Widgets written for Vicious:
- Thermal, Battery, Mbox, OrgMode, Volume, Entropy,
Disk I/O, System Load, Wireless, Pacman, Maildir
2009-07-29 17:59:32 +02:00
|
|
|
-- }}}
|
|
|
|
|
|
|
|
|
2010-02-10 02:49:26 +01:00
|
|
|
-- Thermal: provides temperature levels of ACPI and coretemp thermal zones
|
2012-06-15 18:07:05 +02:00
|
|
|
-- vicious.widgets.thermal
|
|
|
|
local thermal = {}
|
Import of vicious source tree.
Vicious is a modular widget library for 'awesome' window manager,
derived from the 'Wicked' widget library.
Summary of changes:
* Original wicked code modularized
* Widgets ported from Wicked:
- CPU, MEM, FS, NET, Date, Uptime, MPD
* CPU widget rewritten, uses pattern matching
* MEM widget rewritten, uses pattern matching
- Swap widget merged with MEM widget type
* FS widget rewritten, uses pattern matching
- Also fixed padding in the process
* NET widget rewritten, uses pattern matching
* MPD widget rewritten, a bit more versatile
* Removed deprecated helper functions
* Widgets written for Vicious:
- Thermal, Battery, Mbox, OrgMode, Volume, Entropy,
Disk I/O, System Load, Wireless, Pacman, Maildir
2009-07-29 17:59:32 +02:00
|
|
|
|
|
|
|
|
|
|
|
-- {{{ Thermal widget type
|
2010-02-10 02:49:26 +01:00
|
|
|
local function worker(format, warg)
|
2010-03-14 03:37:40 +01:00
|
|
|
if not warg then return end
|
|
|
|
|
2010-02-12 00:33:07 +01:00
|
|
|
local zone = { -- Known temperature data sources
|
2010-02-10 02:49:26 +01:00
|
|
|
["sys"] = {"/sys/class/thermal/", file = "temp", div = 1000},
|
2012-03-31 20:53:30 +02:00
|
|
|
["core"] = {"/sys/devices/platform/", file = "temp2_input",div = 1000},
|
2010-02-10 02:49:26 +01:00
|
|
|
["proc"] = {"/proc/acpi/thermal_zone/",file = "temperature"}
|
|
|
|
} -- Default to /sys/class/thermal
|
2010-03-15 17:54:00 +01:00
|
|
|
warg = type(warg) == "table" and warg or { warg, "sys" }
|
2010-02-10 02:49:26 +01:00
|
|
|
|
|
|
|
-- Get temperature from thermal zone
|
2012-06-15 18:07:05 +02:00
|
|
|
local _thermal = helpers.pathtotable(zone[warg[2]][1] .. warg[1])
|
2010-03-15 17:54:00 +01:00
|
|
|
|
2012-06-15 18:07:05 +02:00
|
|
|
local data = warg[3] and _thermal[warg[3]] or _thermal[zone[warg[2]].file]
|
2011-11-19 02:24:34 +01:00
|
|
|
if data then
|
2010-02-10 02:49:26 +01:00
|
|
|
if zone[warg[2]].div then
|
2011-11-19 02:24:34 +01:00
|
|
|
return {data / zone[warg[2]].div}
|
2010-02-10 02:49:26 +01:00
|
|
|
else -- /proc/acpi "temperature: N C"
|
2011-11-19 02:24:34 +01:00
|
|
|
return {tonumber(string.match(data, "[%d]+"))}
|
2010-02-10 02:49:26 +01:00
|
|
|
end
|
2009-11-11 02:57:30 +01:00
|
|
|
end
|
Import of vicious source tree.
Vicious is a modular widget library for 'awesome' window manager,
derived from the 'Wicked' widget library.
Summary of changes:
* Original wicked code modularized
* Widgets ported from Wicked:
- CPU, MEM, FS, NET, Date, Uptime, MPD
* CPU widget rewritten, uses pattern matching
* MEM widget rewritten, uses pattern matching
- Swap widget merged with MEM widget type
* FS widget rewritten, uses pattern matching
- Also fixed padding in the process
* NET widget rewritten, uses pattern matching
* MPD widget rewritten, a bit more versatile
* Removed deprecated helper functions
* Widgets written for Vicious:
- Thermal, Battery, Mbox, OrgMode, Volume, Entropy,
Disk I/O, System Load, Wireless, Pacman, Maildir
2009-07-29 17:59:32 +02:00
|
|
|
|
2009-11-11 02:57:30 +01:00
|
|
|
return {0}
|
Import of vicious source tree.
Vicious is a modular widget library for 'awesome' window manager,
derived from the 'Wicked' widget library.
Summary of changes:
* Original wicked code modularized
* Widgets ported from Wicked:
- CPU, MEM, FS, NET, Date, Uptime, MPD
* CPU widget rewritten, uses pattern matching
* MEM widget rewritten, uses pattern matching
- Swap widget merged with MEM widget type
* FS widget rewritten, uses pattern matching
- Also fixed padding in the process
* NET widget rewritten, uses pattern matching
* MPD widget rewritten, a bit more versatile
* Removed deprecated helper functions
* Widgets written for Vicious:
- Thermal, Battery, Mbox, OrgMode, Volume, Entropy,
Disk I/O, System Load, Wireless, Pacman, Maildir
2009-07-29 17:59:32 +02:00
|
|
|
end
|
|
|
|
-- }}}
|
2009-08-01 23:11:41 +02:00
|
|
|
|
2012-06-15 18:07:05 +02:00
|
|
|
return setmetatable(thermal, { __call = function(_, ...) return worker(...) end })
|