0
$ 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)以上是当地天气的终端命令。

$ 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)以上是在conky中垂直显示的sed命令。

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)以上是垂直显示命令(2)在conky.conf文件中运行的结果。

问题是我如何让 (3) 看起来像 (2) ?只是无法在这里获得相关信息。

4

1 回答 1

0

可能 conky 的配置解析器“吃掉”了命令中的许多特殊字符sed。如果这确实是问题所在,您可以改用 sed 解释器脚本。

使用以下内容创建文件/usr/local/bin/inxi2conky并使其可执行:

#!/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//

然后将其添加到conky.conf

inxi -xxxw | /usr/local/bin/inxi2conky
于 2014-11-17T18:58:23.963 回答