0

In my wibox taskbar, I have a wibox.widget.textbox whose text is set using the textbox:set_text method.

The text comes from a bash command, whose output is recieved with io:popen():

local fd = io.popen("sensors | grep -oP 'Physical\\s+id\\s+\\d+:\\s+\\+\\K[0-9.]+'")
local out = fd:read("*all")
fd:close()    
temp_widget:set_text(out)

However, out contains a non-ascii symbol: the degree character °.

And in my taskbar, this character is displayed as �, which is itself a unicode character: U+FFFD. So I presume that awesome supports unicode, so why this char isn't displaying correctly?

EDIT: Also, as a side problem, I can't append a string to my output. IE, if I do temp_widget:set_text(out .. "foobar"), the result is the same as temp_widget:set_text(out). How to append a string then?

Antoine C.
  • 3,730
  • 5
  • 32
  • 56

2 Answers2

1

I believe "�" is not necessarily U+FFFD, but also a generic replacement character for any character not in the font you're using. So the problem might simply be one of font support. For example, if I go to a random web page whose title contains a degree sign the browser title bar contains a degree sign. Another possibility is that since Lua strings do not have an explicit encoding you might have to somehow tell the widget which encoding it should assume for input.

As for concatenating strings, are you sure that out doesn't end with a newline, causing the subsequent string to be hidden because it's out of bounds? grep output always ends with a newline, even if the match does not:

$ echo ab | grep -o a | xxd -pu
610a
l0b0
  • 55,365
  • 30
  • 138
  • 223
0

I solved my problem with removing the degree sign from my grep string, and appending it again in lua. So the font wasn't the problem, nor the widget assuming the encoding was not unicode.

l0b0 was right about the out ending with a new line though, it solved my second problem.

Antoine C.
  • 3,730
  • 5
  • 32
  • 56