歡迎您光臨本站 註冊首頁

如何判斷無線是否開啟

←手機掃碼閱讀     火星人 @ 2014-03-26 , reply:0

源於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
},

這段代碼是用於繪出有線網卡的網速圓形圖,我想在添加一個函數判斷無線網卡和有線網卡哪個在工作,然後顯示那個工作的網卡網速。
在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}

但在clock_rings.lua中的實現方式網上找了一下沒能找到。(我看很像是用C寫的,不知道是不是)

[火星人 ] 如何判斷無線是否開啟已經有333次圍觀

http://coctec.com/docs/linux/show-post-183261.html