diff --git a/home/.config/awesome/battery.lua b/home/.config/awesome/battery.lua index 6c9f8f2..dff8303 100644 --- a/home/.config/awesome/battery.lua +++ b/home/.config/awesome/battery.lua @@ -1,13 +1,6 @@ local timer = require("gears.timer") local wibox = require("wibox") - -local function readfile(command) - local file = io.open(command) - if not file then return nil end - local text = file:read('*all') - file:close() - return text:gsub("^%s*(.-)%s*$", "%1") -end +local utils = require("utils") local battery_widget = wibox.widget{ markup = 'U00', @@ -20,8 +13,8 @@ timer:connect_signal("timeout", function() update() end) timer:start() function update() - local percent = readfile("/sys/class/power_supply/BAT1/capacity") - local status = readfile("/sys/class/power_supply/BAT1/status") + local percent = utils.readfile("/sys/class/power_supply/BAT1/capacity") + local status = utils.readfile("/sys/class/power_supply/BAT1/status") if status == "Charging" then prefix = "C" diff --git a/home/.config/awesome/rc.lua b/home/.config/awesome/rc.lua index 3a95a9a..e3c73b9 100644 --- a/home/.config/awesome/rc.lua +++ b/home/.config/awesome/rc.lua @@ -241,6 +241,7 @@ awful.screen.connect_for_each_screen(function(s) layout = wibox.layout.fixed.horizontal, wibox.widget.systray(), require("battery"), + require("sensors"), mytextclock, s.mylayoutbox, }, diff --git a/home/.config/awesome/sensors.lua b/home/.config/awesome/sensors.lua new file mode 100644 index 0000000..a439dc3 --- /dev/null +++ b/home/.config/awesome/sensors.lua @@ -0,0 +1,23 @@ +local timer = require("gears.timer") +local wibox = require("wibox") +local utils = require("utils") + +local sensors_widget = wibox.widget{ + markup = '00°C', + align = 'center', + widget = wibox.widget.textbox +} + +timer = timer({ timeout = 10 }) +timer:connect_signal("timeout", function() update() end) +timer:start() + +function update() + local temp = utils.readfile("/sys/class/thermal/thermal_zone1/temp") / 1000 + + sensors_widget:set_markup(string.format("%02d", temp) .. "°C") +end + +update() + +return wibox.container.margin(sensors_widget, 4) diff --git a/home/.config/awesome/utils.lua b/home/.config/awesome/utils.lua new file mode 100644 index 0000000..82cff04 --- /dev/null +++ b/home/.config/awesome/utils.lua @@ -0,0 +1,11 @@ +local utils = {} + +function utils.readfile(command) + local file = io.open(command) + if not file then return nil end + local text = file:read('*all') + file:close() + return text:gsub("^%s*(.-)%s*$", "%1") +end + +return utils