You are not logged in.
I have a Qtile wm setup on a vanilla Arch install. As my laptop is old, I want to monitor the fan speed, so I created this simple widget:
widget.GenPollText(update_interval=1, func=lambda: subprocess.check_output("/home/paul/.config/qtile/scripts/fan.sh").decode("utf-8"), fmt='{}'),
I haven't tweaked it yet but it runs with no error. The output is a four digit number followed by a space then RPM, like this: 2490 RPM. The problem is, it is rendered out of position on the bar. It is based half-way up the width of the bar. I think I need to adjust
.decode("utf-8")
but I don't know how. How do I get the output centered?
Last edited by Gabachin (2022-05-14 00:27:45)
Offline
> The problem is, it is rendered out of position on the bar. It is based half-way up the width of the bar.
Is the text shown outside the widget, or inside?
If it is inside, you should be able to use string formatting to get the output centered within the widget. Try doing
.decode("utf-8").strip()
This removes the newline character at the end.
If it is outside, something is wrong. What is the string output given by your fan.sh script?
Offline
The output was half-in, half-out of the widget, displaced vertically. When I changed utf-8 to utf-16, it centered properly, but of course, the characters were not rendered properly. Your suggestion worked. Can you explain what "This removes the newline character at the end" means? Thanks!
Offline
Can you explain what "This removes the newline character at the end" means?
The output of a command usually has a newline character (a "\n") at the end. So the widget was actually showing the fan speed and an empty line. .strip() is a python string method to remove all whitespace before and after the string, this includes newlines.
Happy to have been of help!
Offline
Got it!
Offline