You are not logged in.

#1 2009-11-01 17:30:11

RedArcher
Member
From: South Africa
Registered: 2009-09-03
Posts: 106

Conky "if connected to the Internetz"

the following conky is originaly from:
http://blog.pakos.biz/desktopowe-zmiany/
http://dl.pakos.biz/files/conkyrc

>>> Click here to see image

#Pakos | ja(at)pakos.biz | http://pakos.biz
# Use Xft?
use_xft yes
xftfont SonyEricssonLogo:size=8:bold

# Update interval in seconds
update_interval 1

# This is the number of times Conky will update before quitting.
# Set to zero to run forever.
total_run_times 0

# Create own window instead of using desktop (required in nautilus)
own_window  yes
own_window_transparent no
own_window_type normal
own_window_hints undecorate,sticky,skip_taskbar,skip_pager 
own_window_title blue bottom left panel

# Use double buffering (reduces flicker, may not work for everyone)
double_buffer yes

# Draw shades?
draw_shades no

# Draw outlines?
draw_outline no

# Draw borders around text
draw_borders no
draw_graph_borders no

# Stippled borders?
stippled_borders 0

# border margins
border_margin 6

# border width
border_width 1

# Default colors and also border colors
color1 5598d7
color2 d4d4d4
default_color 444444
#default_shade_color white
#default_outline_color black
own_window_colour 444444

# Text alignment, other possible values are commented
#alignment top_left
#alignment top_right
alignment bottom_left
#alignment bottom_right

# Gap between borders of screen and text
# same thing as passing -x at command line
gap_x 7
gap_y 6
minimum_size 1110
# Subtract file system buffers from used memory?
no_buffers yes

# set to yes if you want all text to be in uppercase
uppercase no

# Force UTF8? note that UTF8 support required XFT
override_utf8_locale yes

# Add spaces to keep things from moving about?  This only affects certain objects.
use_spacer yes

TEXT
${color1}Uptime:  ${color2}$uptime_short ${color1}Cpu:  ${color2}${cpu}% ${freq}MHz ${color 3c3c3c}${cpugraph 7,50 92C1EE 5598d7} ${color1}Ram:  ${color2}$memperc%  $mem ${color1}Swp:  ${color2}$swapperc%  $swap ${if_existing /proc/net/route eth0}${color1}Download: ${color2}${downspeed eth0}KiB/s ${color 3c3c3c}${downspeedgraph eth0 7,50 92C1EE 5598d7} ${color1}Total: ${color2}${totaldown eth0} ${color1}Upload: ${color2}${upspeed eth0}KiB/s ${color 3c3c3c}${upspeedgraph eth0 7,50 92c1ee 5598d7} ${color1}Total:${color2} ${totalup eth0}${else}${if_existing /proc/net/route wlan0}${color1}Download: ${color2}${downspeed wlan0}KiB/s ${color 3c3c3c}${downspeedgraph wlan0 7,50 92C1EE 5598d7} ${color1}Total: ${color2}${totaldown wlan0} ${color1}Upload: ${color2}${upspeed wlan0}KiB/s ${color 3c3c3c}${upspeedgraph wlan0 7,50 92c1ee 5598d7} ${color1}Total:${color2} ${totalup wlan0}${else}${color1}Download: ${color2}${downspeed lo}KiB/s ${color 3c3c3c}${downspeedgraph lo 7,50 92C1EE 5598d7} ${color1}Total: ${color2}${totaldown lo} ${color1}Upload: ${color2}${upspeed lo}KiB/s ${color 3c3c3c}${upspeedgraph lo 7,50 92c1ee 5598d7} ${color1}Total:${color2} ${totalup lo}${endif}${endif}  ${color1}Sda:  ${color2}${fs_free_perc /}% ${fs_free /}/ ${fs_size /}

as you can see, this conky checks if it is connected to eth0 (Wired) and if not it is not then it checks wlan0 (WiFi) and if not than it shows the state of the lo interface (we can replace it with the message "You are not connected to the internetz")


My Problem is the following line/information/parameter etc.
${color1}External IP:$alignr${color2}${execi 300 wget www.whatismyip.com/automation/n09230945.asp -O - -q}

${alignc}${color1}NETWORK ${if_up wmaster0}${if_existing /proc/net/route eth0}(Wired)

${color1}Down:${color2} ${downspeed eth0} k/s $alignr${color1} Up:${color2} ${upspeed eth0} k/s
${color1}${downspeedgraph eth0 27,120 000000 FF0000 100} $alignr${upspeedgraph eth0 27,120 000000 FFFF00 100}
${color2}${totaldown eth0}$alignr${color2}${totalup eth0}

${color1}Local    IP:${alignr}${color2}${addr eth0} (eth0)${else}${if_existing /proc/net/route wlan0}(Wireless)

${color1}Down:${color2} ${downspeed wlan0} k/s $alignr${color1} Up:${color2} ${upspeed wlan0} k/s
${color1}${downspeedgraph wlan0 27,120 000000 FF0000 100} $alignr${color1}${upspeedgraph wlan0 27,120 000000 FFFF00 100}
${color2}${totaldown wlan0}$alignr${color2}${totalup wlan0}

${color1}Quality:${color2} ${wireless_bitrate wlan0}    ${wireless_link_qual_perc wlan0}% ${alignr}${color1}${wireless_link_bar 7,135 wlan0}
${color1}ESSID:$alignr${color2}${wireless_essid wlan0}
${color1}BSSID:$alignr${color2}${wireless_ap wlan0}
${color1}Local    IP:${alignr}${color2}${addr wlan0} (wlan0)${endif}${endif}
${color1}External IP:$alignr${color2}${execi 300 wget www.whatismyip.com/automation/n09230945.asp -O - -q}

${else}(Offline)





${color2}${font zekton:pixelsize=36}${alignc}Disconnected${endif}

instead of asking "if connected to the internetz" it asks ${if_up wmaster0} means "is the wireless switch is on" but I find it useless because I usually turning it off and no matter if the Wired Interface is "online", as long as the wireless switch is off the message will be "Disconnected"

and... the problem with this line:
${color1}External IP:$alignr${color2}${execi 300 wget www.whatismyip.com/automation/n09230945.asp -O - -q}
is that it's relevant to both wlan0 and eth0 interfaces and I find in inefficient to copy the exact same line in thhe same script (actually, it is more than one line)

How to ask conky "if connected to the internetz"?

Last edited by RedArcher (2009-11-01 19:04:12)

Offline

#2 2009-11-02 17:14:43

munkyeetr
Member
From: Merritt, BC
Registered: 2008-08-07
Posts: 83

Re: Conky "if connected to the Internetz"

This is what I use in my conkyrc to tell whether I am connected, and what type of connection I have.

I know many of the lines are repeated inside the if statements, and I don't know if there is another way. There is no way to call a function in conky that I know of (I could be wrong though)

NOTE: I removed all my $color and $offset entries to make this more easily readable.

${if_gw}
${if_existing /proc/net/route wlan0}Connection Type: Wireless
ESSID: ${wireless_essid wlan0}
Public IP:${execi 3600 wget -O - http://whatismyip.org/ | tail}
Local IP:${addr wlan0}

UP: ${upspeedf wlan0} DN: ${downspeedf wlan0}kb/s${endif}${if_existing /proc/net/route eth0}Connection Type: Wired
Public IP: ${execi 3600 wget -O - http://whatismyip.org/ | tail}
Local IP: ${addr eth0}

UP: ${upspeedf eth0} DN: ${downspeedf eth0}kb/s${endif}${else}
Not Connected${endif}

If the advice you're given in this forum solves your issue, please mark the post as [SOLVED] in consideration to others.

"More than any time in history mankind faces a crossroads. One path leads to despair and utter hopelessness, the other to total extinction.
Let us pray that we have the wisdom to choose correctly." -- Woody Allen

Offline

#3 2009-11-02 20:05:43

RedArcher
Member
From: South Africa
Registered: 2009-09-03
Posts: 106

Re: Conky "if connected to the Internetz"

Hello, munkyeetr.

http://conky.sourceforge.net/variables.html
if_gw: if there is at least one default gateway, display everything between $if_gw and the matching $endif

I already tried ${if_gw} but it didn't worked sad

I'm trying to do this under "Conky 1.6.1"


Thank you for replying.

Offline

#4 2009-11-06 18:10:38

RedArcher
Member
From: South Africa
Registered: 2009-09-03
Posts: 106

Re: Conky "if connected to the Internetz"

@munkyeetr
Your code: from 12 to 11 lines.

${if_gw}
${if_existing /proc/net/route wlan0}Connection Type: Wireless
UP: ${upspeedf wlan0} DN: ${downspeedf wlan0}kb/s

ESSID: ${wireless_essid wlan0}
Local IP:${addr wlan0}${endif}${if_existing /proc/net/route eth0}Connection Type: Wired
UP: ${upspeedf eth0} DN: ${downspeedf eth0}kb/s

Local IP: ${addr eth0}${endif}
Public IP: ${execi 3600 wget -O - http://whatismyip.org/ | tail}${else}
Not Connected${endif}

tongue

Last edited by RedArcher (2009-11-06 18:12:04)

Offline

Board footer

Powered by FluxBB