源于conky的clock_rings.lua[code] {
name='downspeedf',
arg='eth0',
max=100,
bg_colour=0xffffff,
bg_alpha=0.2,
fg_colour=0x339900,
fg_alpha=0.8,
x=150, y=500,
radius=25,
thickness=4,
start_angle=-90,
end_angle=180
},
{
name='upspeedf',
arg='eth0',
max=100,
bg_colour=0xffffff,
bg_alpha=0.2,
fg_colour=0xff6600,
fg_alpha=0.8,
x=150, y=500,
radius=20,
thickness=4,
start_angle=-90,
end_angle=180
},[/code]这段代码是用于绘出有线网卡的网速圆形图,我想在添加一个函数判断无线网卡和有线网卡哪个在工作,然后显示那个工作的网卡网速。
在conkyrc可以直接用if_up 判断网卡是否在线,如这段代码:[code]# |--WLAN0
${if_up wlan0}
${voffset 5}${color FFFFFF}${goto 125}↓${downspeed wlan0}${color FF6600}/${totaldown wlan0}
${color FFFFFF}${goto 125}↑${upspeed wlan0}${color FF6600}${color FF6600}/${totalup wlan0}
${color FF6600}${goto 125}Net
${voffset -2}${goto 55} Signal: ${font Liberation Sans:style=Bold:size=8}${color #dcff82}${wireless_essid wlan0} ${color1}${wireless_link_qual wlan0}%
#${color}${font} ${alignr}${color2}${wireless_link_bar 8,60 wlan0}${color}
${voffset 2}${goto 55} ${color FF6600} LocalIP: ${color #FFDC35}${addr wlan0}
# |--ETH0
${else}${if_up eth0}
${voffset 15}${color FFFFFF}${goto 125}↓${downspeed eth0}${color FF6600}/${totaldown eth0}
${color FFFFFF}${goto 125}↑${upspeed eth0}${color FF6600}${color FF6600}/${totalup eth0}
${color FF6600}${goto 125}Net
${voffset 4}${font}${color FF6600}${goto 105}${voffset -4}LocalIP: ${color #FFDC35}${addr eth0}${color}
# |--PPP0
${endif}${else}${if_up ppp0}
${voffset 15}${color FFFFFF}${goto 125}↓${downspeed ppp0}${color FF6600}/${totaldown ppp0}
${color FFFFFF}${goto 125}↑${upspeed ppp0}${color FF6600}${color FF6600}/${totalup ppp0}
${color FF6600}${goto 125}Net
${font}${color FF6600}${goto 32}${voffset -4}LocalIP: ${alignr}${color2}${addr ppp0}${color}
${endif}${else}${voffset 4}${color0}${font PizzaDude Bullets:size=12}4${font}${color}${goto 32}Network Unavailable${endif}${endif}[/code]但在clock_rings.lua中的实现方式网上找了一下没能找到。(我看很像是用C写的,不知道是不是)