Open seppal123 opened 3 years ago
Use two colons to escape
python3 ./led-badge-11x44.py "11::07::53 up 17 min, 1 user, load average: 0,00, 0,05, 0,09"
If you want to create a shell one-liner for this, you can use sed
to replace single colons with doubles, and then immediately insert the uptime
output into the badge-script using "string interpolation"
sed "s/find/replace/g"
does _s_ubstitution of find
with replace
, (g = global = don't stop after first replacement) $( ... )
is bash-syntax for command interpolation, i.e. execute ...
and give me its output as string. # uptime
16:54:42 up 0:07, 2 users, load average: 0.46, 0.86, 0.51
# uptime | sed 's/:/::/g'
16::54::59 up 0::07, 2 users, load average:: 0.33, 0.81, 0.49
# echo "bash interpolation! >>$( uptime | sed 's/:/::/g' )<<"
bash interpolation! >> 16::59::21 up 0::11, 2 users, load average:: 0.59, 0.68, 0.52<<
# python3 ./led-badge-11x44.py "$( uptime | sed 's/:/::/g' )"
...
Hi all
I would like to use the LED Badge as Status Monitor for Linux. All i want is to output the uptime command to the LED. see example below. Problem is, that the ":" characters have a buildin funktion for the bitmaps so i cannot show a Timestamp. Is there a way that i can escape the ":" character so that they are not interpreted as Picture ?
Thanks is advance, and a happy new year 2021 Ciao Sandro
---example-- sandro@schleppy:~/led-name-badge-ls32$ uptime 11:16:27 up 26 min, 1 user, load average: 0,56, 0,38, 0,21
sandro@schleppy:~/led-name-badge-ls32$ python3 ./led-badge-11x44.py "11:07:53 up 17 min, 1 user, load average: 0,00, 0,05, 0,09" using [LSicroelectronics LS32 Custm HID] bus=1 dev=13 Traceback (most recent call last): File "./led-badge-11x44.py", line 487, in
msgs.append(bitmap(arg))
File "./led-badge-11x44.py", line 360, in bitmap
return bitmap_text(arg)
File "./led-badge-11x44.py", line 315, in bitmap_text
(b,n) = bitmap_char(c)
File "./led-badge-11x44.py", line 284, in bitmap_char
return bitmap_preloaded[ord(ch)]
IndexError: list index out of range