我的conky1.10配置笔记

·· / ·– ·· ·-·· ·-·· / ·–· · ·-· ··· ·· ··· - / ··- -· - ·· ·-·· / ·· / ·– ·· -·
linux下的conky可以起到非常不错的美化和实用效果。但conky的高度自定义化配置又确实有些让人望而却步。我刚接触linux不久就尝试安装conky的harmattan主题,但是失败了。。我尝试从.conkyrc外入手,但发现那是没有用的,后来,经过几个小时的尝试,放弃了。
后来从ubuntu换成debian再到现在正在搭建的archlinux,在这一过程中我也开始逐渐阅读和更改配置文件了。终于,在经过google和自己的一番尝试之后,我终于配置好了自己的conky。
写这篇文章,我用的是archlinux,conky1.10,kde5

第一个配置文件

conky.config = {
background = true,
update_interval=1,
double_buffer=true,
imlib_cache_size=10,
draw_shades=false,
draw_outline=false,
draw_borders = false,
draw_graph_borders = false,
show_graph_scale = false,
show_graph_range = false,
minimum_height = 620,
minimum_width = 268,
own_window = true,
own_window_class = 'Conky',
own_window_type = 'normal',
own_window_transparent=true,
border_inner_margin=0,
border_outer_margin=0,
own_window_hints="undecorated,below,sticky,skip_taskbar,skip_pager",
own_window_argb_visual=true,
own_window_argb_value=0,
use_xft = true,
xftalpha=0.8,
font = 'DejaVu Sans Mono:size=12',
text_buffer_size=256,
short_units=true,
short_units=true,
pad_percents=2,
top_name_width=7,
    alignment = 'top_left',
    border_width = 1,
    cpu_avg_samples = 2,
    default_color = 'white',
    gap_x = 5,
    gap_y = 60,
    net_avg_samples = 2,
    no_buffers = true,
    out_to_console = false,
    out_to_stderr = false,
    extra_newline = false,
    stippled_borders = 0,
    update_interval = 1.0,
    uppercase = false,
    use_spacer = 'none',

}

conky.text = [[
${scroll 16 $nodename - $sysname $kernel on $machine | }
$hr
${color grey}Uptime:$color $uptime
${color grey}Frequency (in MHz):$color $freq
${color grey}Frequency (in GHz):$color $freq_g
${color grey}RAM Usage:$color $mem/$memmax - $memperc% ${membar 4}
${color grey}Swap Usage:$color $swap/$swapmax - $swapperc% ${swapbar 4}
${color grey}CPU Usage:$color $cpu% ${cpubar 4}
${color grey}Processes:$color $processes  ${color grey}Running:$color $running_processes
$hr
${color grey}File systems:
 / $color${fs_used /}/${fs_size /} ${fs_bar 6 /}
${color grey}Networking:
Up:$color ${upspeed eth0} ${color grey} - Down:$color ${downspeed eth0}
$hr
${color grey}Name              PID   CPU%   MEM%
${color lightgrey} ${top name 1} ${top pid 1} ${top cpu 1} ${top mem 1}
${color lightgrey} ${top name 2} ${top pid 2} ${top cpu 2} ${top mem 2}
${color lightgrey} ${top name 3} ${top pid 3} ${top cpu 3} ${top mem 3}
${color lightgrey} ${top name 4} ${top pid 4} ${top cpu 4} ${top mem 4}
]]

可以明显的看出来,我的这个文件是照着默认的conky.conf改的。

double_buffer=true,

double buffer要打开,要不然X server刷新率跟不上会导致conky一闪一闪的。

own_window = true,
own_window_class = ‘Conky’,
own_window_type = ‘normal’,

应该是让conky有自己的X window?如果不这样配置可能会是conky莫名消失。

own_window_hints=”undecorated,below,sticky,skip_taskbar,skip_pager”,

窗口微调,去掉这一行conky可能会自己开一个窗口。

own_window_transparent=true,

打开真透明,但我在配置时发现真正起到透明作用的是:

own_window_argb_visual=true,
own_window_argb_value=0,

own_window_argb_value改到255就是不透明。

alignment = ‘top_left’,
border_width = 1,
gap_x = 5,
gap_y = 60,

conky定位方面的调整。

根据这个配置文件显示出来的效果:
我的conky1.10配置笔记_第1张图片

配置Harmattan主题

安装

*1、安装curl和jq这两个包。
2、确认自己装了Droid Sans字体。
3、把.harmattan-assets移到~目录。
4、从.harmattan-themes中找出对应的.conkyrc移到~目录。

一开始我忽略了第一步,结果conky无法生成天气对应图片,并不断报错说找不到.cache中的某个png文件,这个问题卡了我好久。

配置

配置天气
去OpenWeatherMap注册一个私有的API key来获取天气数据。

把API key放到.conkyrc文件的template6变量里。

在这里找到你对应城市的ID,并把它放到.conkyrc文件的template7变量里。

一些问题
下面提一下我遇到的几个问题。
经过的上面的一步,我的conky已经可以显示天气了,然而我的conky显示的效果却不尽人意:我的conky1.10配置笔记_第2张图片

可以看出来以下几个问题:
1、文字偏上。
2、有一大圈黑边。
3、无法显示网络连接情况。
这是我这个情况的配置文件:

conky.config = {

-------------------------------------
--  Generic Settings
-------------------------------------
background=true,
update_interval=1,
double_buffer=true,
no_buffers=true,
imlib_cache_size=10,

draw_shades=false,
draw_outline=false,
draw_borders=false,
draw_graph_borders=false,
default_graph_height=26,
default_graph_width=80,
show_graph_scale=false,
show_graph_range=false,


-------------------------------------
--  Window Specifications
-------------------------------------
gap_x=100,
gap_y=70,
minimum_height=620,
minimum_width=268,
own_window=true,
own_window_type="normal",
own_window_transparent=true,
own_window_hints="undecorated,below,sticky,skip_taskbar,skip_pager",
border_inner_margin=0,
border_outer_margin=0,
--alignment="middle_middle",
--own_window_argb_visual=true,
--own_window_argb_value=0,


-------------------------------------
--  Text Settings
-------------------------------------
use_xft=true,
xftalpha=0.8,
font="Droid Sans:size=8",
text_buffer_size=256,
override_utf8_locale=true,

short_units=true,
short_units=true,
pad_percents=2,
top_name_width=7,


-------------------------------------
--  Color Scheme
-------------------------------------
default_color="FFFFFF",
color1="FFFFFF",
color2="FFFFFF",
color3="FFFFFF",
color4="FFFFFF",
color5="DCDCDC",
color6="FFFFFF",
color7="FFFFFF",
color8="FFFFFF",


-------------------------------------
--  API Key
-------------------------------------
template6="785c55952ba8b7c41777975b42697401",


-------------------------------------
--  City ID
-------------------------------------
template7="1787093",


-------------------------------------
--  Temp Unit (default, metric, imperial)
-------------------------------------
template8="metric",


-------------------------------------
--  Locale (e.g. "es_ES.UTF-8")
--  Leave empty for default
-------------------------------------
template9=""

}


---------------------------------------------------
---------------------------------------------------


conky.text = [[
\
\
${execi 300 l=${template9}; l=${l%%_*}; curl -s "api.openweathermap.org/data/2.5/forecast/daily?APPID=${template6}&id=${template7}&cnt=5&units=${template8}&lang=$l" -o ~/.cache/forecast.json}\
${execi 300 l=${template9}; l=${l%%_*}; curl -s "api.openweathermap.org/data/2.5/weather?APPID=${template6}&id=${template7}&cnt=5&units=${template8}&lang=$l" -o ~/.cache/weather.json}\
\
\
\
\
${image ~/.harmattan-assets/misc/Metro/God-Mode/fav-color-1.png -p 20,30 -s 228x61}\
${execi 300 cp -f ~/.harmattan-assets/photos/smallest/$(jq .weather[0].id ~/.cache/weather.json).png ~/.cache/weather.png}${image ~/.cache/weather.png -p 20,91 -s 228x86}\
${image ~/.harmattan-assets/misc/Metro/God-Mode/fav-color-3.png -p 20,177 -s 228x86}\
${image ~/.harmattan-assets/misc/Metro/God-Mode/fav-color-4.png -p 20,263 -s 228x105}\
${image ~/.harmattan-assets/misc/Metro/God-Mode/fav-color-5.png -p 20,368 -s 228x105}\
${image ~/.harmattan-assets/misc/Metro/God-Mode/fav-color-6.png -p 20,473 -s 228x119}\
${image ~/.harmattan-assets/misc/Metro/God-Mode/fav-color-7.png -p 20,478 -s 228x14}\
${image ~/.harmattan-assets/misc/Metro/God-Mode/border.png -p 20,30 -s 228x562}\
${image ~/.harmattan-assets/misc/Metro/God-Mode/border-4.png -p 20,90 -s 228x88}\
${image ~/.harmattan-assets/misc/Metro/God-Mode/border-3.png -p 20,478 -s 228x14}\
${image ~/.harmattan-assets/misc/Metro/God-Mode/separator-v.png -p 95,185 -s 1x76}\
${image ~/.harmattan-assets/misc/Metro/God-Mode/separator-v.png -p 172,185 -s 1x76}\
${image ~/.harmattan-assets/misc/Metro/God-Mode/separator-h.png -p 33,369 -s 202x1}\
${image ~/.harmattan-assets/misc/Metro/God-Mode/separator-h.png -p 33,269 -s 202x1}\
\
\
\
\
${color3}${voffset 172}${alignc 77}${execi 300 LANG=${template9} LC_TIME=${template9} date +%^a}${color}
${color3}${voffset -13}${alignc}${execi 300 LANG=${template9} LC_TIME=${template9} date -d +1day +%^a}${color}
${color3}${voffset -13}${alignc -77}${execi 300 LANG=${template9} LC_TIME=${template9} date -d +2day +%^a}${color}
\
\
\
\
${color2}${voffset 51}${alignc 77}${execi 300 jq -r .list[0].temp.min ~/.cache/forecast.json | awk '{print int($1+0.5)}' # round num}°/${execi 300 jq -r .list[0].temp.max ~/.cache/forecast.json | awk '{print int($1+0.5)}' # round num}°${color}
${color2}${voffset -13}${alignc}${execi 300 jq -r .list[1].temp.min ~/.cache/forecast.json | awk '{print int($1+0.5)}' # round num}°/${execi 300 jq -r .list[1].temp.max ~/.cache/forecast.json | awk '{print int($1+0.5)}' # round num}°${color}
${color2}${voffset -13}${alignc -77}${execi 300 jq -r .list[2].temp.min ~/.cache/forecast.json | awk '{print int($1+0.5)}' # round num}°/${execi 300 jq -r .list[2].temp.max ~/.cache/forecast.json | awk '{print int($1+0.5)}' # round num}°${color}
\
\
\
\
${goto 36}${voffset -172}${font Droid Sans :size=36}${color1}${execi 300 jq -r .main.temp ~/.cache/weather.json | awk '{print int($1+0.5)}' # round num}°${font}${color}
${goto 46}${voffset 14}${font Droid Sans :size=12}${color1}${execi 300 jq -r .weather[0].description ~/.cache/weather.json | sed "s|\<.|\U&|g"}${font}${color}
${color1}${alignr 52}${voffset -73}${execi 300 jq -r .main.pressure ~/.cache/weather.json | awk '{print int($1+0.5)}' # round num} hPa
${color1}${alignr 52}${voffset 7}${execi 300 jq -r .main.humidity ~/.cache/weather.json | awk '{print int($1+0.5)}' # round num} %${color}
${color1}${alignr 52}${voffset 7}${execi 300 jq -r .wind.speed ~/.cache/weather.json | awk '{print int($1+0.5)}' # round num}${if_match "$template8" == "metric"} m/s${else}${if_match "$template8" == "default"} m/s${else}${if_match "$template8" == "imperial"} mi/h${endif}${endif}${endif}${color}
\
\
\
\
${voffset -117}${font Droid Sans Mono :size=22}${alignc}${color2}${time %H:%M}${font}${color}
${voffset 4}${font Droid Sans :size=10}${alignc}${color6}${execi 300 LANG=${template9} LC_TIME=${template9} date +"%A, %B %-d"}${font}${color}
\
\
\
\
${voffset 294}${goto 40}${color2}Cpu:${color}
${voffset 4}${goto 40}${color2}Mem:${color}
${voffset 4}${goto 40}${color2}Uptime:${color}
${voffset -47}${alignr 39}${color2}${cpu cpu0}%${color}
${voffset 4}${alignr 39}${color2}${memperc}%${color}
${voffset 4}${alignr 39}${color2}${uptime_short}${color}
${voffset -47}${alignc}${color2}${cpubar 5,36}${color}
${voffset 4}${alignc}${color2}${membar 5,36}${color}
${voffset 29}${goto 40}${loadgraph 26,190 FFFFFF FFFFFF -l}
\
\
\
\
${voffset 26}${goto 40}${color2}${top_mem name 1}${color}
${voffset 4}${goto 40}${color2}${top_mem name 2}${color}
${voffset 4}${goto 40}${color2}${top_mem name 3}${color}
${voffset 4}${goto 40}${color2}${top_mem name 4}${color}
${voffset 4}${goto 40}${color2}${top_mem name 5}${color}
${voffset -81}${alignc}${color5}${top_mem mem 1}%${color}
${voffset 4}${alignc}${color5}${top_mem mem 2}%${color}
${voffset 4}${alignc}${color5}${top_mem mem 3}%${color}
${voffset 4}${alignc}${color5}${top_mem mem 4}%${color}
${voffset 4}${alignc}${color5}${top_mem mem 5}%${color}
${voffset -81}${alignr 39}${color6}${top_mem mem_res 1}${color}
${voffset 4}${alignr 39}${color6}${top_mem mem_res 2}${color}
${voffset 4}${alignr 39}${color6}${top_mem mem_res 3}${color}
${voffset 4}${alignr 39}${color6}${top_mem mem_res 4}${color}
${voffset 4}${alignr 39}${color6}${top_mem mem_res 5}${color}
${voffset -104}${goto 40}${color1}Proc${color}
${voffset -13}${alignc}${color1}Mem%${color}
${voffset -13}${alignr 39}${color1}Mem${color}
\
\
\
\
${if_existing /proc/net/route ppp0}
${voffset -227}${goto 40}${color5}Up: ${color2}${upspeed ppp0}${color5}${goto 150}Down: ${color2}${downspeed ppp0}
${voffset 10}${goto 40}${upspeedgraph ppp0 26,80 FFFFFF FFFFFF}${goto 150}${downspeedgraph ppp0 26,80 FFFFFF FFFFFF}
${voffset 9}${goto 40}${color5}Sent: ${color2}${totalup ppp0}${color5}${goto 150}Received: ${color2}${totaldown ppp0}
${else}
${if_existing /proc/net/route ppp1}
${voffset -240}${goto 40}${color5}Up: ${color2}${upspeed ppp1}${color5}${goto 150}Down: ${color2}${downspeed ppp1}
${voffset 10}${goto 40}${upspeedgraph ppp1 26,80 FFFFFF FFFFFF}${goto 150}${downspeedgraph ppp1 26,80 FFFFFF FFFFFF}
${voffset 9}${goto 40}${color5}Sent: ${color2}${totalup ppp1}${color5}${goto 150}Received: ${color2}${totaldown ppp1}
${else}
${if_existing /proc/net/route wlp2s1}
${voffset -253}${goto 40}${color5}Up: ${color2}${upspeed wlp2s1}${color5}${goto 150}Down: ${color2}${downspeed wlp2s1}
${voffset 10}${goto 40}${upspeedgraph wlp2s1 26,80 FFFFFF FFFFFF}${goto 150}${downspeedgraph wlp2s1 26,80 FFFFFF FFFFFF}
${voffset 9}${goto 40}${color5}Sent: ${color2}${totalup wlp2s1}${color5}${goto 150}Received: ${color2}${totaldown wlp2s1}
${else}
${if_existing /proc/net/route wlp2s0}
${voffset -266}${goto 40}${color5}Up: ${color2}${upspeed wlp2s0}${color5}${goto 150}Down: ${color2}${downspeed wlp2s0}
${voffset 10}${goto 40}${upspeedgraph wlp2s0 26,80 FFFFFF FFFFFF}${goto 150}${downspeedgraph wlp2s0 26,80 FFFFFF FFFFFF}
${voffset 9}${goto 40}${color5}Sent: ${color2}${totalup wlp2s0}${color5}${goto 150}Received: ${color2}${totaldown wlp2s0}
${else}
${if_existing /proc/net/route wlan0}
${voffset -279}${goto 40}${color5}Up: ${color2}${upspeed wlan0}${color5}${goto 150}Down: ${color2}${downspeed wlan0}
${voffset 8}${goto 40}${upspeedgraph wlan0 26,80 FFFFFF FFFFFF}${goto 150}${downspeedgraph wlan0 26,80 FFFFFF FFFFFF}
${voffset 9}${goto 40}${color5}Sent: ${color2}${totalup wlan0}${color5}${goto 150}Received: ${color2}${totaldown wlan0}
${else}
${if_existing /proc/net/route wlan1}
${voffset -292}${goto 40}${color5}Up: ${color2}${upspeed wlan1}${color5}${goto 150}Down: ${color2}${downspeed wlan1}
${voffset 10}${goto 40}${upspeedgraph wlan1 26,80 FFFFFF FFFFFF}${goto 150}${downspeedgraph wlan1 26,80 FFFFFF FFFFFF}
${voffset 9}${goto 40}${color5}Sent: ${color2}${totalup wlan1}${color5}${goto 150}Received: ${color2}${totaldown wlan1}
${else}
${if_existing /proc/net/route eth1}
${voffset -305}${goto 40}${color5}Up: ${color2}${upspeed eth1}${color5}${goto 150}Down: ${color2}${downspeed eth1}
${voffset 10}${goto 40}${upspeedgraph eth1 26,80 FFFFFF FFFFFF}${goto 150}${downspeedgraph eth1 26,80 FFFFFF FFFFFF}
${voffset 9}${goto 40}${color5}Sent: ${color2}${totalup eth1}${color5}${goto 150}Received: ${color2}${totaldown eth1}
${else}
${if_existing /proc/net/route eth0}
${voffset -318}${goto 40}${color5}Up: ${color2}${upspeed eth0}${color5}${goto 150}Down: ${color2}${downspeed eth0}
${voffset 10}${goto 40}${upspeedgraph eth0 26,80 FFFFFF FFFFFF}${goto 150}${downspeedgraph eth0 26,80 FFFFFF FFFFFF}
${voffset 9}${goto 40}${color5}Sent: ${color2}${totalup eth0}${color5}${goto 150}Received: ${color2}${totaldown eth0}
${else}
${if_existing /proc/net/route enp0s0}
${voffset -331}${goto 40}${color5}Up: ${color2}${upspeed enp0s0}${color5}${goto 150}Down: ${color2}${downspeed enp0s0}
${voffset 10}${goto 40}${upspeedgraph enp0s0 26,80 FFFFFF FFFFFF}${goto 150}${downspeedgraph enp0s0 26,80 FFFFFF FFFFFF}
${voffset 9}${goto 40}${color5}Sent: ${color2}${totalup enp0s0}${color5}${goto 150}Received: ${color2}${totaldown enp0s0}
${else}
${if_existing /proc/net/route enp0s1}
${voffset -344}${goto 40}${color5}Up: ${color2}${upspeed enp0s1}${color5}${goto 150}Down: ${color2}${downspeed enp0s1}
${voffset 10}${goto 40}${upspeedgraph enp0s1 26,80 FFFFFF FFFFFF}${goto 150}${downspeedgraph enp0s1 26,80 FFFFFF FFFFFF}
${voffset 9}${goto 40}${color5}Sent: ${color2}${totalup enp0s1}${color5}${goto 150}Received: ${color2}${totaldown enp0s1}
${else}
${voffset -311}${goto 40}${color5}Network disconnected${color}
${image ~/.harmattan-assets/misc/Metro/God-Mode/offline.png -p 44,284 -s 16x16}
${endif}${endif}${endif}${endif}${endif}${endif}${endif}${endif}${endif}${endif}
\
\
\
\
${image ~/.harmattan-assets/misc/Metro/God-Mode/pressure.png -p 224,95 -s 16x16}\
${image ~/.harmattan-assets/misc/Metro/God-Mode/humidity.png -p 224,115 -s 16x16}\
${image ~/.harmattan-assets/misc/Metro/God-Mode/wind-2.png -p 224,136 -s 16x16}\
${execi 300 cp -f ~/.harmattan-assets/icons/#fff__32/$(jq .list[0].weather[0].id ~/.cache/forecast.json).png ~/.cache/weather-1.png}${image ~/.cache/weather-1.png -p 41,207 -s 32x32}\
${execi 300 cp -f ~/.harmattan-assets/icons/#fff__32/$(jq .list[1].weather[0].id ~/.cache/forecast.json).png ~/.cache/weather-2.png}${image ~/.cache/weather-2.png -p 119,207 -s 32x32}\
${execi 300 cp -f ~/.harmattan-assets/icons/#fff__32/$(jq .list[2].weather[0].id ~/.cache/forecast.json).png ~/.cache/weather-3.png}${image ~/.cache/weather-3.png -p 195,207 -s 32x32}${font}${voffset -120}\

]]

针对文字偏上的问题。这个问题还是比较让人纠结的。Harmattan主题默认是针对72dpi来优化的,许多96dpi的屏幕可就“有福”了。我通过修改voffset来改变文字位置。

${goto 36}${voffset -172}${font Droid Sans :size=36}${color1}${execi 300 jq -r .main.temp ~/.cache/weather.json | awk '{print int($1+0.5)}' # round num}°${font}${color}
//这一行涉及整体文字(除了Day以及Temperature)的位置
${color3}${voffset 172}${alignc 77}${execi 300 LANG=${template9} LC_TIME=${template9} date +%^a}${color}
//这一行涉及Day以及Temperature的位置

更改voffset后的值至合适的值(这个要凭感觉)。更新:voffset规定的是当前行图形与上一行图形的相对偏移。

针对黑边的问题。我一开始以为是kde的compositor的问题(xfce等可能会遇到这个问题),但后来发现不是(更新:其实有关,我后来在openbox中用xcompmgr作compositor时,即使不开own_window_argb_visual=true,也一样没有黑边)。其实这和没开启透明有关。只需要把下面两行开头的”–(注意:这里我是想打两个减号的,但是显示成了一个,下同)”去掉就行了(conky配置文件中用”–(这是两个减号)”来注释掉一行),如果没有,就加上这两行,然后去掉”–”。

–own_window_argb_visual=true,
–own_window_argb_value=0,

针对无法显示网络状况的问题。在终端执行ip link命令,查看输出的interface,无线设备接口应该是以”w”开头,比如wlp2s1。
我的是wlp4s0。翻看.conkyrc发现以下内容。

${if_existing /proc/net/route ppp0}
${voffset -227}${goto 40}${color5}Up: ${color2}${upspeed ppp0}${color5}${goto 150}Down: ${color2}${downspeed ppp0}
${voffset 10}${goto 40}${upspeedgraph ppp0 26,80 FFFFFF FFFFFF}${goto 150}${downspeedgraph ppp0 26,80 FFFFFF FFFFFF}
${voffset 9}${goto 40}${color5}Sent: ${color2}${totalup ppp0}${color5}${goto 150}Received: ${color2}${totaldown ppp0}
${else}
${if_existing /proc/net/route ppp1}
${voffset -240}${goto 40}${color5}Up: ${color2}${upspeed ppp1}${color5}${goto 150}Down: ${color2}${downspeed ppp1}
${voffset 10}${goto 40}${upspeedgraph ppp1 26,80 FFFFFF FFFFFF}${goto 150}${downspeedgraph ppp1 26,80 FFFFFF FFFFFF}
${voffset 9}${goto 40}${color5}Sent: ${color2}${totalup ppp1}${color5}${goto 150}Received: ${color2}${totaldown ppp1}
${else}
${if_existing /proc/net/route wlp2s1}
${voffset -253}${goto 40}${color5}Up: ${color2}${upspeed wlp2s1}${color5}${goto 150}Down: ${color2}${downspeed wlp2s1}
${voffset 10}${goto 40}${upspeedgraph wlp2s1 26,80 FFFFFF FFFFFF}${goto 150}${downspeedgraph wlp2s1 26,80 FFFFFF FFFFFF}
${voffset 9}${goto 40}${color5}Sent: ${color2}${totalup wlp2s1}${color5}${goto 150}Received: ${color2}${totaldown wlp2s1}
${else}
${if_existing /proc/net/route wlp2s0}
${voffset -266}${goto 40}${color5}Up: ${color2}${upspeed wlp2s0}${color5}${goto 150}Down: ${color2}${downspeed wlp2s0}
${voffset 10}${goto 40}${upspeedgraph wlp2s0 26,80 FFFFFF FFFFFF}${goto 150}${downspeedgraph wlp2s0 26,80 FFFFFF FFFFFF}
${voffset 9}${goto 40}${color5}Sent: ${color2}${totalup wlp2s0}${color5}${goto 150}Received: ${color2}${totaldown wlp2s0}
${else}
${if_existing /proc/net/route wlan0}
${voffset -279}${goto 40}${color5}Up: ${color2}${upspeed wlan0}${color5}${goto 150}Down: ${color2}${downspeed wlan0}
${voffset 8}${goto 40}${upspeedgraph wlan0 26,80 FFFFFF FFFFFF}${goto 150}${downspeedgraph wlan0 26,80 FFFFFF FFFFFF}
${voffset 9}${goto 40}${color5}Sent: ${color2}${totalup wlan0}${color5}${goto 150}Received: ${color2}${totaldown wlan0}
${else}

这明显是在枚举连接接口,但是其中就是没有我的wlp4s0,于是我暴力把wlp2s1替换成了wlp4s0。保存文件,问题被解决了。

贴一下我最终的配置文件(安全起见,API key和City ID是fake的):

conky.config = {

-------------------------------------
--  Generic Settings
-------------------------------------
background=true,
update_interval=1,
double_buffer=true,
no_buffers=true,
imlib_cache_size=10,

draw_shades=false,
draw_outline=false,
draw_borders=false,
draw_graph_borders=false,
default_graph_height=26,
default_graph_width=80,
show_graph_scale=false,
show_graph_range=false,


-------------------------------------
--  Window Specifications
-------------------------------------
gap_x=0,
gap_y=50,
minimum_height=620,
minimum_width=268,
own_window=true,
own_window_class = 'Conky',
own_window_type="normal",
own_window_transparent=false,
own_window_hints="undecorated,below,sticky,skip_taskbar,skip_pager",
border_inner_margin=0,
border_outer_margin=0,
alignment="top_left",
own_window_argb_visual=true,
own_window_argb_value=0,


-------------------------------------
--  Text Settings
-------------------------------------
use_xft=true,
xftalpha=0.8,
font="Droid Sans:size=8",
text_buffer_size=256,
override_utf8_locale=true,

short_units=true,
short_units=true,
pad_percents=2,
top_name_width=7,


-------------------------------------
--  Color Scheme
-------------------------------------
default_color="FFFFFF",
color1="FFFFFF",
color2="FFFFFF",
color3="FFFFFF",
color4="FFFFFF",
color5="DCDCDC",
color6="FFFFFF",
color7="FFFFFF",
color8="FFFFFF",


-------------------------------------
--  API Key
-------------------------------------
template6="785c55952ba8b7c41777975b4269e531",


-------------------------------------
--  City ID
-------------------------------------
template7="1736093",


-------------------------------------
--  Temp Unit (default, metric, imperial)
-------------------------------------
template8="metric",


-------------------------------------
--  Locale (e.g. "es_ES.UTF-8")
--  Leave empty for default
-------------------------------------
template9=""

}


---------------------------------------------------
---------------------------------------------------


conky.text = [[
\
\
${execi 300 l=${template9}; l=${l%%_*}; curl -s "api.openweathermap.org/data/2.5/forecast/daily?APPID=${template6}&id=${template7}&cnt=5&units=${template8}&lang=$l" -o ~/.cache/forecast.json}\
${execi 300 l=${template9}; l=${l%%_*}; curl -s "api.openweathermap.org/data/2.5/weather?APPID=${template6}&id=${template7}&cnt=5&units=${template8}&lang=$l" -o ~/.cache/weather.json}\
\
\
\
\
${image ~/.harmattan-assets/misc/Metro/God-Mode/fav-color-1.png -p 20,30 -s 228x61}\
${execi 300 cp -f ~/.harmattan-assets/photos/smallest/$(jq .weather[0].id ~/.cache/weather.json).png ~/.cache/weather.png}${image ~/.cache/weather.png -p 20,91 -s 228x86}\
${image ~/.harmattan-assets/misc/Metro/God-Mode/fav-color-3.png -p 20,177 -s 228x86}\
${image ~/.harmattan-assets/misc/Metro/God-Mode/fav-color-4.png -p 20,263 -s 228x105}\
${image ~/.harmattan-assets/misc/Metro/God-Mode/fav-color-5.png -p 20,368 -s 228x105}\
${image ~/.harmattan-assets/misc/Metro/God-Mode/fav-color-6.png -p 20,473 -s 228x119}\
${image ~/.harmattan-assets/misc/Metro/God-Mode/fav-color-7.png -p 20,478 -s 228x14}\
${image ~/.harmattan-assets/misc/Metro/God-Mode/border.png -p 20,30 -s 228x562}\
${image ~/.harmattan-assets/misc/Metro/God-Mode/border-4.png -p 20,90 -s 228x88}\
${image ~/.harmattan-assets/misc/Metro/God-Mode/border-3.png -p 20,478 -s 228x14}\
${image ~/.harmattan-assets/misc/Metro/God-Mode/separator-v.png -p 95,185 -s 1x76}\
${image ~/.harmattan-assets/misc/Metro/God-Mode/separator-v.png -p 172,185 -s 1x76}\
${image ~/.harmattan-assets/misc/Metro/God-Mode/separator-h.png -p 33,369 -s 202x1}\
${image ~/.harmattan-assets/misc/Metro/God-Mode/separator-h.png -p 33,269 -s 202x1}\
\
\
\
\
${color3}${voffset 185}${alignc 77}${execi 300 LANG=${template9} LC_TIME=${template9} date +%^a}${color}
${color3}${voffset -13}${alignc}${execi 300 LANG=${template9} LC_TIME=${template9} date -d +1day +%^a}${color}
${color3}${voffset -13}${alignc -77}${execi 300 LANG=${template9} LC_TIME=${template9} date -d +2day +%^a}${color}
\
\
\
\
${color2}${voffset 51}${alignc 77}${execi 300 jq -r .list[0].temp.min ~/.cache/forecast.json | awk '{print int($1+0.5)}' # round num}°/${execi 300 jq -r .list[0].temp.max ~/.cache/forecast.json | awk '{print int($1+0.5)}' # round num}°${color}
${color2}${voffset -13}${alignc}${execi 300 jq -r .list[1].temp.min ~/.cache/forecast.json | awk '{print int($1+0.5)}' # round num}°/${execi 300 jq -r .list[1].temp.max ~/.cache/forecast.json | awk '{print int($1+0.5)}' # round num}°${color}
${color2}${voffset -13}${alignc -77}${execi 300 jq -r .list[2].temp.min ~/.cache/forecast.json | awk '{print int($1+0.5)}' # round num}°/${execi 300 jq -r .list[2].temp.max ~/.cache/forecast.json | awk '{print int($1+0.5)}' # round num}°${color}
\
\
\
\
${goto 36}${voffset -171}${font Droid Sans :size=36}${color1}${execi 300 jq -r .main.temp ~/.cache/weather.json | awk '{print int($1+0.5)}' # round num}°${font}${color}
${goto 46}${voffset 14}${font Droid Sans :size=12}${color1}${execi 300 jq -r .weather[0].description ~/.cache/weather.json | sed "s|\<.|\U&|g"}${font}${color}
${color1}${alignr 52}${voffset -73}${execi 300 jq -r .main.pressure ~/.cache/weather.json | awk '{print int($1+0.5)}' # round num} hPa
${color1}${alignr 52}${voffset 7}${execi 300 jq -r .main.humidity ~/.cache/weather.json | awk '{print int($1+0.5)}' # round num} %${color}
${color1}${alignr 52}${voffset 7}${execi 300 jq -r .wind.speed ~/.cache/weather.json | awk '{print int($1+0.5)}' # round num}${if_match "$template8" == "metric"} m/s${else}${if_match "$template8" == "default"} m/s${else}${if_match "$template8" == "imperial"} mi/h${endif}${endif}${endif}${color}
\
\
\
\
${voffset -117}${font Droid Sans Mono :size=22}${alignc}${color2}${time %H:%M}${font}${color}
${voffset 4}${font Droid Sans :size=10}${alignc}${color6}${execi 300 LANG=${template9} LC_TIME=${template9} date +"%A, %B %-d"}${font}${color}
\
\
\
\
${voffset 294}${goto 40}${color2}Cpu:${color}
${voffset 4}${goto 40}${color2}Mem:${color}
${voffset 4}${goto 40}${color2}Uptime:${color}
${voffset -47}${alignr 39}${color2}${cpu cpu0}%${color}
${voffset 4}${alignr 39}${color2}${memperc}%${color}
${voffset 4}${alignr 39}${color2}${uptime_short}${color}
${voffset -47}${alignc}${color2}${cpubar 5,36}${color}
${voffset 4}${alignc}${color2}${membar 5,36}${color}
${voffset 29}${goto 40}${loadgraph 26,190 FFFFFF FFFFFF -l}
\
\
\
\
${voffset 26}${goto 40}${color2}${top_mem name 1}${color}
${voffset 4}${goto 40}${color2}${top_mem name 2}${color}
${voffset 4}${goto 40}${color2}${top_mem name 3}${color}
${voffset 4}${goto 40}${color2}${top_mem name 4}${color}
${voffset 4}${goto 40}${color2}${top_mem name 5}${color}
${voffset -81}${alignc}${color5}${top_mem mem 1}%${color}
${voffset 4}${alignc}${color5}${top_mem mem 2}%${color}
${voffset 4}${alignc}${color5}${top_mem mem 3}%${color}
${voffset 4}${alignc}${color5}${top_mem mem 4}%${color}
${voffset 4}${alignc}${color5}${top_mem mem 5}%${color}
${voffset -81}${alignr 39}${color6}${top_mem mem_res 1}${color}
${voffset 4}${alignr 39}${color6}${top_mem mem_res 2}${color}
${voffset 4}${alignr 39}${color6}${top_mem mem_res 3}${color}
${voffset 4}${alignr 39}${color6}${top_mem mem_res 4}${color}
${voffset 4}${alignr 39}${color6}${top_mem mem_res 5}${color}
${voffset -104}${goto 40}${color1}Proc${color}
${voffset -13}${alignc}${color1}Mem%${color}
${voffset -13}${alignr 39}${color1}Mem${color}
\
\
\
\
${if_existing /proc/net/route ppp0}
${voffset -227}${goto 40}${color5}Up: ${color2}${upspeed ppp0}${color5}${goto 150}Down: ${color2}${downspeed ppp0}
${voffset 10}${goto 40}${upspeedgraph ppp0 26,80 FFFFFF FFFFFF}${goto 150}${downspeedgraph ppp0 26,80 FFFFFF FFFFFF}
${voffset 9}${goto 40}${color5}Sent: ${color2}${totalup ppp0}${color5}${goto 150}Received: ${color2}${totaldown ppp0}
${else}
${if_existing /proc/net/route ppp1}
${voffset -240}${goto 40}${color5}Up: ${color2}${upspeed ppp1}${color5}${goto 150}Down: ${color2}${downspeed ppp1}
${voffset 10}${goto 40}${upspeedgraph ppp1 26,80 FFFFFF FFFFFF}${goto 150}${downspeedgraph ppp1 26,80 FFFFFF FFFFFF}
${voffset 9}${goto 40}${color5}Sent: ${color2}${totalup ppp1}${color5}${goto 150}Received: ${color2}${totaldown ppp1}
${else}
${if_existing /proc/net/route wlp2s1}
${voffset -253}${goto 40}${color5}Up: ${color2}${upspeed wlp2s1}${color5}${goto 150}Down: ${color2}${downspeed wlp2s1}
${voffset 10}${goto 40}${upspeedgraph wlp2s1 26,80 FFFFFF FFFFFF}${goto 150}${downspeedgraph wlp2s1 26,80 FFFFFF FFFFFF}
${voffset 9}${goto 40}${color5}Sent: ${color2}${totalup wlp2s1}${color5}${goto 150}Received: ${color2}${totaldown wlp2s1}
${else}
${if_existing /proc/net/route wlp4s0}
${voffset -266}${goto 40}${color5}Up: ${color2}${upspeed wlp4s0}${color5}${goto 150}Down: ${color2}${downspeed wlp4s0}
${voffset 10}${goto 40}${upspeedgraph wlp4s0 26,80 FFFFFF FFFFFF}${goto 150}${downspeedgraph wlp4s0 26,80 FFFFFF FFFFFF}
${voffset 9}${goto 40}${color5}Sent: ${color2}${totalup wlp4s0}${color5}${goto 150}Received: ${color2}${totaldown wlp4s0}
${else}
${if_existing /proc/net/route wlan0}
${voffset -279}${goto 40}${color5}Up: ${color2}${upspeed wlan0}${color5}${goto 150}Down: ${color2}${downspeed wlan0}
${voffset 8}${goto 40}${upspeedgraph wlan0 26,80 FFFFFF FFFFFF}${goto 150}${downspeedgraph wlan0 26,80 FFFFFF FFFFFF}
${voffset 9}${goto 40}${color5}Sent: ${color2}${totalup wlan0}${color5}${goto 150}Received: ${color2}${totaldown wlan0}
${else}
${if_existing /proc/net/route wlan1}
${voffset -292}${goto 40}${color5}Up: ${color2}${upspeed wlan1}${color5}${goto 150}Down: ${color2}${downspeed wlan1}
${voffset 10}${goto 40}${upspeedgraph wlan1 26,80 FFFFFF FFFFFF}${goto 150}${downspeedgraph wlan1 26,80 FFFFFF FFFFFF}
${voffset 9}${goto 40}${color5}Sent: ${color2}${totalup wlan1}${color5}${goto 150}Received: ${color2}${totaldown wlan1}
${else}
${if_existing /proc/net/route eth1}
${voffset -305}${goto 40}${color5}Up: ${color2}${upspeed eth1}${color5}${goto 150}Down: ${color2}${downspeed eth1}
${voffset 10}${goto 40}${upspeedgraph eth1 26,80 FFFFFF FFFFFF}${goto 150}${downspeedgraph eth1 26,80 FFFFFF FFFFFF}
${voffset 9}${goto 40}${color5}Sent: ${color2}${totalup eth1}${color5}${goto 150}Received: ${color2}${totaldown eth1}
${else}
${if_existing /proc/net/route eth0}
${voffset -318}${goto 40}${color5}Up: ${color2}${upspeed eth0}${color5}${goto 150}Down: ${color2}${downspeed eth0}
${voffset 10}${goto 40}${upspeedgraph eth0 26,80 FFFFFF FFFFFF}${goto 150}${downspeedgraph eth0 26,80 FFFFFF FFFFFF}
${voffset 9}${goto 40}${color5}Sent: ${color2}${totalup eth0}${color5}${goto 150}Received: ${color2}${totaldown eth0}
${else}
${if_existing /proc/net/route enp0s0}
${voffset -331}${goto 40}${color5}Up: ${color2}${upspeed enp0s0}${color5}${goto 150}Down: ${color2}${downspeed enp0s0}
${voffset 10}${goto 40}${upspeedgraph enp0s0 26,80 FFFFFF FFFFFF}${goto 150}${downspeedgraph enp0s0 26,80 FFFFFF FFFFFF}
${voffset 9}${goto 40}${color5}Sent: ${color2}${totalup enp0s0}${color5}${goto 150}Received: ${color2}${totaldown enp0s0}
${else}
${if_existing /proc/net/route enp0s1}
${voffset -344}${goto 40}${color5}Up: ${color2}${upspeed enp0s1}${color5}${goto 150}Down: ${color2}${downspeed enp0s1}
${voffset 10}${goto 40}${upspeedgraph enp0s1 26,80 FFFFFF FFFFFF}${goto 150}${downspeedgraph enp0s1 26,80 FFFFFF FFFFFF}
${voffset 9}${goto 40}${color5}Sent: ${color2}${totalup enp0s1}${color5}${goto 150}Received: ${color2}${totaldown enp0s1}
${else}
${voffset -311}${goto 40}${color5}Network disconnected${color}
${image ~/.harmattan-assets/misc/Metro/God-Mode/offline.png -p 44,284 -s 16x16}
${endif}${endif}${endif}${endif}${endif}${endif}${endif}${endif}${endif}${endif}
\
\
\
\
${image ~/.harmattan-assets/misc/Metro/God-Mode/pressure.png -p 224,95 -s 16x16}\
${image ~/.harmattan-assets/misc/Metro/God-Mode/humidity.png -p 224,115 -s 16x16}\
${image ~/.harmattan-assets/misc/Metro/God-Mode/wind-2.png -p 224,136 -s 16x16}\
${execi 300 cp -f ~/.harmattan-assets/icons/#fff__32/$(jq .list[0].weather[0].id ~/.cache/forecast.json).png ~/.cache/weather-1.png}${image ~/.cache/weather-1.png -p 41,207 -s 32x32}\
${execi 300 cp -f ~/.harmattan-assets/icons/#fff__32/$(jq .list[1].weather[0].id ~/.cache/forecast.json).png ~/.cache/weather-2.png}${image ~/.cache/weather-2.png -p 119,207 -s 32x32}\
${execi 300 cp -f ~/.harmattan-assets/icons/#fff__32/$(jq .list[2].weather[0].id ~/.cache/forecast.json).png ~/.cache/weather-3.png}${image ~/.cache/weather-3.png -p 195,207 -s 32x32}${font}${voffset -120}\

]]

这样配置后,我的conky显示效果就比较不错了:
我的conky1.10配置笔记_第3张图片

你可能感兴趣的:(archlinux)