You are not logged in.
Pages: 1
Hi everyone! Hope you're all having a nice life! ![]()
I recently started using awesome wm 4.2 and really like it; has significantly improved my workflow. I wanted to create a widget showing cpu temp, and I made it following instructions from here https://awesomewm.org/apidoc/classes/aw … 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.
I've already searched the forum for answers and found this post https://bbs.archlinux.org/viewtopic.php?id=168537 which is from 2013 and which answer doesn't help in my case.
Thanks in advance for your answers! Any help/advice is much appreciated! ![]()
Last edited by Moltke (2018-09-09 05:08:37)
Judges have decimated, meanings of our laws, already guilt? something has a flow, wrongly accused, blindly confused, open your eyes, wake up realize!
Offline
Please use code tags, not that godawful highlighting, when pasting to the boards: https://wiki.archlinux.org/index.php/Co … s_and_code
To print 43°C you would need to process the output of /sys/class/... rather than just cat it. Awk can do this in one pass, or you could use bash's parameter expansion + printf to acheive it.
Moving to NC...
Offline
Please use code tags, not that godawful highlighting, when pasting to the boards: https://wiki.archlinux.org/index.php/Co … s_and_code
To print 43°C you would need to process the output of /sys/class/... rather than just cat it. Awk can do this in one pass, or you could use bash's parameter expansion + printf to acheive it.
Moving to NC...
Thank you for your answer!
Sorry about the highlighting. I did read https://wiki.archlinux.org/index.php/Co … s_and_code before posting and I thought of using code tags but then it seemed to me that highlighting was more appropiate and clearly I was wrong. I'll fix that. And for future reference, which situations are more appropiate for using one or the other? Is it the content of the rc.lua file and the likes considered as console snippets?
Thanks again for taking the time to answer.
Judges have decimated, meanings of our laws, already guilt? something has a flow, wrongly accused, blindly confused, open your eyes, wake up realize!
Offline
Any time you are pasting code. Among other things, the monospace styling makes it much easier to read.
Offline
Ok, I tried
awful.widget.watch([[bash -c "cat/sys/class/hwmon/hwmon0/device/temp1_input| awk '{print $1/1000 \"°C\"}'"]], 15),but no values are shown. what am I doing wrong?
Judges have decimated, meanings of our laws, already guilt? something has a flow, wrongly accused, blindly confused, open your eyes, wake up realize!
Offline
I'm no programmer, but you need a space between cat and /sys/class/hwmon/hwmon0/device/temp1_input| awk '{print $1/1000 \"°C\"}'"]], 15),
Offline
I'm no programmer, but you need a space between cat and /sys/class/hwmon/hwmon0/device/temp1_input| awk '{print $1/1000 \"°C\"}'"]], 15),
Space or no space is the same resullt; no values are shown. And I did use space but when pasting here it seems I did it wrong. Thanks for your answer!
Judges have decimated, meanings of our laws, already guilt? something has a flow, wrongly accused, blindly confused, open your eyes, wake up realize!
Offline
Not only is there a useless use of cat, but also a useless use of bash:
awful.widget.watch('awk "{print $1/1000 \"°C\";}" /sys/class/hwmon/hwmon0/device/temp1_input', 15),You also seem to have switched out the single quote of the command string to double square brackets. I don't know much lua, but I'm pretty sure that'd not be acceptable.
FWIW, you could also consider sed which would simplify the nested quotes a bit though it would just floor the value rather than round:
awful.widget.watch('sed "s/\(..\).*/\1°C/" /sys/class/hwmon/hwmon0/device/temp1_input', 15),Last edited by Trilby (2018-09-09 03:40:30)
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
Not only is there a useless use of cat, but also a useless use of bash:
awful.widget.watch('awk "{print $1/1000 \"°C\";}" /sys/class/hwmon/hwmon0/device/temp1_input', 15),You also seem to have switched out the single quote of the command string to double square brackets. I don't know much lua, but I'm pretty sure that'd not be acceptable.
FWIW, you could also consider sed which would simplify the nested quotes a bit though it would just floor the value rather than round:
awful.widget.watch('sed "s/\(..\).*/\1°C/" /sys/class/hwmon/hwmon0/device/temp1_input', 15),
Thanks for your answer! I tried your suggestion and same result; no temps values are shown. Check here: https://imgur.com/FSvnzyY
Well, to be honest I haven't used awk command that much. Regarding the use of bash I was following instructions from awesome site, I simply changed it a bit to meet my needs. I don't know much if any lua either. I was doing some trial and error.
Judges have decimated, meanings of our laws, already guilt? something has a flow, wrongly accused, blindly confused, open your eyes, wake up realize!
Offline
And do the awk or sed commands work on their own in a terminal?
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
And do the awk or sed commands work on their own in a terminal?
Awk didn't while sed did but return an error in rc.lua file, something about some wrong sequence. However, I found a solution. I was also posting in another site and they gave it to me:
awful.widget.watch('bash -c "cat /sys/class/hwmon/hwmon0/device/temp1_input"', 15,
function(widget, s) widget:set_text(("%d°C"):format(tonumber(s)/1000)) end),This works as I wanted it to. Check it here: https://imgur.com/oL4OS0T
EDIT: In order to get the "°C", like 43°C, I needed to add ("%d°C"):format.
Last edited by Moltke (2018-09-10 18:33:31)
Judges have decimated, meanings of our laws, already guilt? something has a flow, wrongly accused, blindly confused, open your eyes, wake up realize!
Offline
Pages: 1