cpu temp widget in awesome wm

cpu temp widget in awesome wm



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 i.e 43000 instead of 43. How can I change that? and if possible 43°C.




1 Answer
1



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)






Thanks for yur answer. I tried your suggestion but then no values are shown. Check in here: imgur.com/FSvnzyY

– Moltke
Sep 9 '18 at 3:24







it seems like the callback takes two parameters instead of one and there was space missing between cat and the filename, so I updated the example to fix both. If it still doesn't work, show the content of temp1_input file.

– Paul Kulchenko
Sep 9 '18 at 3:31


cat


temp1_input






Same result; no temp values are shown. The content of temp1_input is a number, right now is 43000 and if close and open again it's another higher or lower one. Thanks for your answer.

– Moltke
Sep 9 '18 at 3:41






Ok, updated the example with setting the explicit value for the widget.

– Paul Kulchenko
Sep 9 '18 at 4:08






Thanks a lot! that worked! check it out: imgur.com/d2WwG9j

– Moltke
Sep 9 '18 at 4:47



Thanks for contributing an answer to Stack Overflow!



But avoid



To learn more, see our tips on writing great answers.



Required, but never shown



Required, but never shown




By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

Edmonton

Crossroads (UK TV series)