18.04 版 Conky 网络问题

18.04 版 Conky 网络问题

所以我听说过很多关于 conky 的事情,想尝试一下。我补充道蒂吉帕,安装并下载官方主题包。问题是,conky 无法检测网络接口。在谷歌上花了一些时间后,我意识到我必须替换eth0enp1s0才能让 conky 在网络连接下工作。所以这是我当前systemstat随附的小部件透明瓷砖V3主题:

TEXT
${voffset -2}${font Open Sans Light:bold:size=9}HARD DRIVEs$font${voffset 10}
HOME ${alignr}${color5}${fs_bar 12,200 /home}
${voffset -18}${offset 5}${color}${alignr 5}$color${fs_free /home}$color$font
SYSTEM ${alignr}${color5}${fs_bar 12,200 /}
${voffset -18}${offset 5}${color}${alignr 5}$color${fs_free /} free$color$font
${voffset -8}
${font Open Sans Light:bold:size=9}NETWORK$font${voffset -14}
${if_existing /proc/net/route wlan0}
${color}Up:${color} ${color2}${upspeed wlan0}${color}${alignr}${color}Sent:${color} ${color2}${totalup wlan0}${color}
${color}Down:${color} ${color2}${downspeed wlan0}${color}${alignr}${color}Received:${color} ${color2}${totaldown wlan0}${color}
${else}${if_existing /proc/net/route wlan1}
${color}Up:${color} ${color2}${upspeed wlan1}${color}${alignr}${color}Sent:${color} ${color2}${totalup wlan1}${color}
${color}Down:${color} ${color2}${downspeed wlan1}${color}${alignr}${color}Received:${color} ${color2}${totaldown wlan1}${color}
${else}${if_existing /proc/net/route enp1s0}
${color}Up:${color} ${color2}${upspeed enp1s0}${color}${alignr}${color}Sent:${color} ${color2}${totalup enp1s0}${color}
${color}Down:${color} ${color2}${downspeed enp1s0}${color}${alignr}${color}Received:${color} ${color2}${totaldown enp1s0}${color}
${else}${if_existing /proc/net/route eth1}
${color}Up:${color} ${color2}${upspeed eth1}${color}${alignr}${color}Sent:${color} ${color2}${totalup eth1}${color}
${color}Down:${color} ${color2}${downspeed eth1}${color}${alignr}${color}Received:${color} ${color2}${totaldown eth1}${color}
${else}${if_existing /proc/net/route ppp0}
${color}Up:${color} ${color2}${upspeed ppp0}${color}${alignr}${color}Sent:${color} ${color2}${totalup ppp0}${color}
${color}Down:${color} ${color2}${downspeed ppp0}${color}${alignr}${color}Received:${color} ${color2}${totaldown ppp0}${color}
${else}${if_existing /proc/net/route ppp1}
${color}Up:${color} ${color2}${upspeed ppp1}${color}${alignr}${color}Sent:${color} ${color2}${totalup ppp1}${color}
${color}Down:${color} ${color2}${downspeed ppp1}${color}${alignr}${color}Received:${color} ${color2}${totaldown ppp1}${color}
${else}${if_existing /proc/net/route usb0}
${color}Up:${color} ${color2}${upspeed usb0}${color}${alignr}${color}Sent:${color} ${color2}${totalup usb0}${color}
${color}Down:${color} ${color2}${downspeed usb0}${color}${alignr}${color}Received:${color} ${color2}${totaldown usb0}${color}
${else}${if_existing /proc/net/route usb1}
${color}Up:${color} ${color2}${upspeed usb1}${color}${alignr}${color}Sent:${color} ${color2}${totalup usb1}${color}
${color}Down:${color} ${color2}${downspeed usb1}${color}${alignr}${color}Received:${color} ${color2}${totaldown usb1}${color}
${else}
Network disconnected
${color5}Connect to a network to see statistics${color}
${voffset 74}
${endif}${endif}${endif}${endif}${endif}${endif}${endif}${endif}${voffset -61}

我刚刚搜索了文本:eth0 并将其替换为 enp1s0,但并非所有小部件都带有文本eth0,例如新闻小部件:

# conky package by qaisar nawaz
# Conky settings #
background no
update_interval 900
double_buffer yes
no_buffers yes

# Window specifications #
own_window yes
own_window_type normal
own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager
own_window_title
own_window_colour bebebe
own_window_argb_visual yes
own_window_argb_value 205

minimum_size 549 85
maximum_width 549

# Alignment #
alignment tr
gap_x 55
gap_y 341

border_inner_margin 10
border_outer_margin 0

# Graphics settings #
draw_shades no
draw_outline no
draw_borders no
draw_graph_borders no

# Text settings #
use_xft yes
xftalpha 0
xftfont Open Sans Light:size=10

override_utf8_locale yes

imlib_cache_size 0

# Color scheme #
default_color 333333

color1 0099CC
color2 9933CC
color3 669900
color4 FF8800
color5 CC0000
color6 AAAAAA
color7 DDDDDD

TEXT
${voffset -4}${color1}${font Open Sans Light:size=12}Top Stories - Google News$color$font
${voffset 1}${exec python ./news.py}
${voffset -28}

我甚至尝试将 TEXT 部分包装在 for 循环中,如下所示:

TEXT
${if_existing /proc/net/route enp1s0}
${voffset -4}${color1}${font Open Sans Light:size=12}Top Stories - Google News$color$font
${voffset 1}${exec python ./news.py}
${voffset -28}
${endif}

但还是没有运气...我怎样才能告诉 conky 全局使用 enp1s0,而不是 eth0?

相关内容