Some time ago I made two additional widgets for the Lain widget library used by the Awesome window manager. You could place them in ~/.config/awesome/lain/widget/
, or somewhere else in your lua search path.
ryzen.lua
[Download]
The originaltemp.lua
widget seemed to work only on Intel processors, at least on my AMD Ryzen processor it was a total no-go. So I modified it to uselm_sensors
for temperature information instead of /sys pseudofiles. The use of this widget is of course not restricted to AMD Ryzen processors only, and can be easily modified to read other values fromlm_sensors
.--[[
System temperature widget | AMD Ryzen
Using lm_sensors instead of /sys/devices
--]]
local helpers = require("lain.helpers")
local wibox = require("wibox")
local tonumber = tonumber
-- {thermal,core} temperature info
-- lain.widget.ryzen
local function factory(args)
local ryzen = { widget = wibox.widget.textbox() }
local args = args or {}
local dev = args.dev or ""
local sensor = args.sensor
local timeout = args.timeout or 2
local settings = args.settings or function() end
function ryzen.update()
local sensors_cmd = "/usr/bin/sensors -A " .. dev .. " | grep " .. sensor .. " | cut -c16-19"
helpers.async_with_shell(sensors_cmd, function(stdout, exit_code)
coretemp_now = tonumber(stdout)
if (exit_code ~= 0) or (coretemp_now == nil) then coretemp_now = "N/A" end
widget = ryzen.widget
settings()
end)
end
helpers.newtimer("thermal", timeout, ryzen.update)
return ryzen
end
return factory
An usage example. Please see the output of
sensors
for the dev and sensor values of your system.local ryzen = lain.widget.ryzen({
dev = "k10temp-pci-00c3",
sensor = "Tctl",
timeout = 10,
settings = function()
widget:set_markup(markup.fontfg(myfont, mycolor, coretemp_now .. "°C "))
end
})
mouse.lua [Download]
This widget reads the battery status of a wireless mouse. It can also be used to observe any other device supported by UPower. See the output ofupower --dump
for the supported devices on your system.--[[
Mouse, kbd etc. wireless HID device battery
state reading using UPower
--]]
local helpers = require("lain.helpers")
local wibox = require("wibox")
local tonumber = tonumber
-- Wireless HID device battery info
-- lain.widget.mouse
local function factory(args)
local mouse = { widget = wibox.widget.textbox() }
local args = args or {}
local dev = args.dev or ""
local timeout = args.timeout or 60
local settings = args.settings or function() end
function mouse.update()
local upower_cmd = "upower -i " .. dev .. " | grep percentage | grep -E -o '[0-9]+'"
helpers.async_with_shell(upower_cmd, function(stdout, exit_code)
mousebatt = tonumber(stdout)
if (exit_code ~= 0) or (mousebatt == nil) then mousebatt = "N/A" end
widget = mouse.widget
settings()
end)
end
helpers.newtimer("battery", timeout, mouse.update)
return mouse
end
return factory
An usage example for a Logitech Trackball M570
local mouse = lain.widget.mouse({
dev = "/org/freedesktop/UPower/devices/mouse_hidpp_battery_0",
timeout = 3600,
settings = function()
widget:set_markup(markup.fontfg(myfont, mycolor, mousebatt .. "% "))
end
})
(EDIT 18.5.2022: If this suddenly stops working, please recheck the device file path. For example, on kernel 5.17.8 the device file mouse_hidpp_battery_0
was changed to battery_hidpp_battery_0
)