I recently started using awesome wm version 4.2 and really like it; has significantly improved my workflow. I tried some themes like copycats and others but they're too fancy for me. I like the default configuration and been reading here: https://awesomewm.org/apidoc/index.html as well the rc.lua and theme.lua files from copycats and others and have implemented some of those; keybindings, layout manipulation, startup programs. I wanted to create a widget showing cpu temp, and I made it following intructions from here https://awesomewm.org/apidoc/classes/awful.widget.watch.html like this:
wibox.widget.textbox(' | '),
awful.widget.watch(
'bash -c "cat/sys/class/hwmon/hwmon0/device/temp1_input"', 15),
wibox.widget.textbox(' | '),
awful.widget.watch(
'bash -c "cat /sys/class/hwmon/hwmon0/device/temp3_input"', 15),
It works, but it shows big numbers ie 43000 instead of 43. How can I change that? and if possible 43°C.
If you get the correct number and just want to divide it by 1000, you can use the optional callback :
awful.widget.watch('bash -c "cat /sys/class/hwmon/hwmon0/device/temp1_input"', 15,
function(widget, s) widget:set_text(tonumber(s)/1000) end)
Just use sensors
, it is easier. I achieved this by creating a widget that updates to the value of sensors
:
local wibox = require("wibox")
local awful = require("awful")
local temprature = wibox.widget {
widget = awful.widget.watch('bash -c "sensors | grep CPU | awk \'{print $2}\' | se
d \'s/C/C /\'"', 5),
}
local temprature_clr = wibox.widget.background()
temprature_clr:set_widget(temprature)
temprature_clr:set_fg("#e5a75b")
return temprature_clr
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.