SEARCH

Enter your search query in the box above ^, or use the forum search tool.

You are not logged in.

#1 2009-04-30 12:55:37

Linzt
Member
From: England
Registered: 2009-04-21
Posts: 35

Help with conky script

Hi all,

I'm new to python. But I've been hacking around, chopping and adding conky scripts now for like the past 2 months. So I'm going to raise the bar a little and actually learn more about the language.

My conky script is static - and I've come to dislike that.

What I would like is for it to be more intuitive. I'd like the 'network' section of it to activate and display my

  • Internal IP

  • External IP

when there is a default gateway active, respectively.

As far as I have learned (in the past two hours) this will depend on Python if and endif statements - am I correct?

I have the following in my conky script:

${offset 25}${font monospace:pixelsize=12}Internal: ${if_gw} ${texeci 1800 addr eth1} ${endif}
${offset 25}${font monospace:pixelsize=12}External: ${if_gw} ${texeci 1800 wget -q -O - http://homer.meso.com/remoteip.php} ${endif}

What is wrong here? I know that something is because the internal and external IP's don't show.

(note - it might be more constructive for my learning if you could guide me in the right direction as opposed to straight out telling me =P)

Ideally, the network section would stay absent until there is an active gateway. Would this then mean that I would have to include an if, else and endif statement over the top of the networking section of the conky script?

Regards

http://img158.imageshack.us/my.php?image=desktopz.jpg


I don't have a sig...

Offline

Be excellent to each other!

#2 2009-04-30 20:24:41

fhsm
#! Junkie
From: New Hampshire, USA
Registered: 2009-01-05
Posts: 445

Re: Help with conky script

(note - it might be more constructive for my learning if you could guide me in the right direction as opposed to straight out telling me =P)

Lot of respect for this approach to asking for help.  I'll try and get you going in the right direction / keep you off the wrong course...

First, you do not need Python to accomplish the goal you have outlined.  Obviously if you want to use it you can.  But you don't need it.

You need a Conky block that displays only when a network adapter is present (look upif_existing in the conky man).  That block needs to contains the LAN IP which is an included Conky variable (it should take you less than 12 characters to make that show up) and the remote IP which can be fetched with (I'm just going to tell you this one):

${execi 1800 wget http://checkip.dyndns.org/ -O - -o /dev/null | cut -d: -f 2 | cut -d\< -f 1} 

For info on how to do this you should check out the .conkyrc thread.  You might also check out the conky help thread.

Last edited by fhsm (2009-04-30 21:38:51)

Offline

#3 2009-04-30 21:30:01

Yogi
#! Member
From: France
Registered: 2009-03-25
Posts: 58

Re: Help with conky script

Hi,

Here is part of my .conkyrc, which lets my external IP displayed (at least the label), then an if statement which displays some network items whenever a network device is on.
when no device is found, a reminder is shown.
You'll notice that when a wired AND a  wireless connexions are detected, both parts will show.

${color2}external IP :${alignr}${color}${texeci 3600 wget http://checkip.dyndns.org -O - -o /dev/null | cut -d : -f 2 | cut -d \< -f 1}
${if_existing /proc/net/route ra0}${color2}wlan : ${alignr}${color}${addr ra0}
${color2}ESSID: ${color}${alignr}${wireless_essid ra0}
${alignr}${color2}${downspeedgraph ra0 16,145 444444 AAAAFF}
${alignr}${color2}Down ${color}${downspeed ra0} ${color grey}ko/s${color}  ${color}${totaldown ra0}
${alignr}${upspeedgraph ra0 16,145 582D10 E08000}
${alignr}Up ${color}${upspeed ra0} ${color grey}ko/s${color} ${totalup ra0}${else}${alignr}No Wlan${endif}
${if_existing /proc/net/route eth0}${color2}${alignr}lan :${color}${addr eth0}
${alignr}${color2}${downspeedgraph eth0 16,145 582D10 E08000}
${alignr}${color1}Down ${color}${downspeed eth0} ${color grey}ko/s${color}  ${color}${totaldown eth0}
${alignr}${upspeedgraph eth0 16,145 582D10 E08000}
${alignr}${color1}Up ${color}${color}${upspeed eth0} ${color grey}ko/s${color}  ${color}${totalup eth0}${else}${alignr}No wire${endif}

Asus EeePC 901A (16Gb SSD) - Waldorf
old Toshiba laptop(Celeron 1,5GHz/20Go/512Mo) - Statler

Offline

Board footer

Powered by FluxBB

Copyright © 2012 CrunchBang Linux.
Proudly powered by Debian. Hosted by Linode.
Debian is a registered trademark of Software in the Public Interest, Inc.

Debian Logo