sed for weather for conky

666 views Asked by At
$ inxi -xxxw
Weather:   Conditions: 23 F (-5 C) - Scattered Clouds Wind: From the West at 15 MPH Humidity: 53%
       Pressure: 29.89 in (1012 mb) Wind Chill: 10 F (-12 C) 
       Location: Chicago IL (USA) Altitude: 184 ft
       Time: November 17, 11:25 AM CST (America/Chicago) Observation Time: November 17, 10:53 AM CST    

1) The above is a terminal command for local weather.

$ inxi -xxxw | sed 's/Co/\nCo/;s/Wind:/\nWind:/;s/Hu/\nHu/;s/Pr/\nPr/;s/Wind Chill/\nWind Chill/;s/Loc/\nLoc/;s/Al/\nAl/;s/Time:/\nTime:/;s/Ob/\nOb/'|sed -r 's/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g'|sed '/^[ \t]/d'
Weather:   
Conditions: 23 F (-5 C) - Scattered Clouds 
Wind: From the West at 15 MPH 
Humidity: 53%
Pressure: 29.89 in (1012 mb) 
Wind Chill: 10 F (-12 C) 
Location: Chicago IL (USA) 
Altitude: 184 ft
Time: November 17, 11:31 AM CST (America/Chicago) 
Observation Time: November 17, 10:53 AM CST

2) The above is the command with sed for vertical display in conky.

12Weather:   12
Conditions 28 F (-2 C) - Mostly Cloudy 12Wind From the WNW at 14 MPH 12
Humidity 69%
12           12
Pressure 29.94 in (1014 mb) 12
Wind Chill 17 F (-8 C) 

3) The above is the result of the vertical display command (2) ran in a conky.conf file.

Question is how do I get (3) to look like (2) ? Just can't get the info for this here.

1

There are 1 answers

2
SzG On

Probably conky's config parser "eats" a lot of your special characters in the sed command. If really that's the problem, you could go for a sed interpreter script instead.

Create the file /usr/local/bin/inxi2conky with the contents below and make it executable:

#!/bin/sed -rf                          
# Remove leading whitespace
s/^[ \t]+//
# Insert linefeeds in front of keys
s/Co|Wind|Hu|Pr|Loc|Al|^Time|Ob/\n&/g
# Remove resulting extra leading linefeeds
s/^\n//

And then add this to conky.conf:

inxi -xxxw | /usr/local/bin/inxi2conky