2019-09-14 05:33:40 +02:00
|
|
|
-- temperature widget type for GNU/Linux
|
|
|
|
-- Copyright (C) 2010 Adrian C. <anrxc@sysphere.org>
|
|
|
|
-- Copyright (C) 2017 mutlusun <mutlusun@github.com>
|
|
|
|
--
|
|
|
|
-- This file is part of Vicious.
|
|
|
|
--
|
|
|
|
-- Vicious is free software: you can redistribute it and/or modify
|
|
|
|
-- it under the terms of the GNU General Public License as
|
|
|
|
-- published by the Free Software Foundation, either version 2 of the
|
|
|
|
-- License, or (at your option) any later version.
|
|
|
|
--
|
|
|
|
-- Vicious is distributed in the hope that it will be useful,
|
|
|
|
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
-- GNU General Public License for more details.
|
|
|
|
--
|
|
|
|
-- You should have received a copy of the GNU General Public License
|
|
|
|
-- along with Vicious. If not, see <https://www.gnu.org/licenses/>.
|
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
|
|
|
|
local string = { match = string.match }
|
2015-09-21 04:13:31 +02:00
|
|
|
local math = { floor = math.floor }
|
2019-09-14 05:33:40 +02: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
|
2017-01-25 17:55:23 +01:00
|
|
|
local thermal_linux = {}
|
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},
|
2015-09-21 04:13:31 +02:00
|
|
|
["hwmon"] = {"/sys/class/hwmon/", file = "temp1_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
|
2015-09-21 04:13:31 +02:00
|
|
|
return {math.floor(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
|
|
|
|
2019-09-14 05:33:40 +02:00
|
|
|
return helpers.setcall(thermal_linux, worker)
|