LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices



Reply
 
Search this Thread
Old 11-27-2010, 07:57 AM   #1
PClOStinspace
Member
 
Registered: Jun 2008
Location: Bracknell, UK
Distribution: Ubuntu 13.10 Saucy
Posts: 137

Rep: Reputation: 15
Question How do I display external IP address in Conky?


I am putting together a Conky config file by a sort of 'smash and grab' approach borrowing things from various configs I've seen around the web that do stuff I like. I have reached a stumbling block as I want to display my external IP, I have used
Code:
${addrs eth0}
to display the IP on my LAN and guessed I would just need to substitute 'eth0' with something else to get the external IP?? I have tried the mac address of my primary router to no avail, this just displays '0.0.0.0'

My current config looks like:-
Code:
# set to yes if you want Conky to be forked in the background
background yes

#font
use_xft yes
xftfont bauhaus:pixelsize=10

# Text alpha when using Xft
xftalpha 0.5

# Update interval in seconds
update_interval 0.5

# 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

# If own_window is yes, you may use type normal, desktop or override
own_window_type normal

# Use pseudo transparency with own_window?
own_window_transparent yes

# If own_window is yes, these window manager hints may be used
own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager

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

# Minimum size of text area
minimum_size 200 100

# Maximum width
maximum_width 500

# Draw shades?
draw_shades no

# Draw outlines?
draw_outline no

# Draw borders around text
draw_borders no

# Draw borders around graphs
draw_graph_borders no

# Stippled borders?
# stippled_borders 8

# border margins
# border_margin 2

# border width
# border_width 1

# Default colors and also border colors
default_color grey
default_shade_color black
default_outline_color grey

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

# Gap between borders of screen and text
# same thing as passing -x at command line
gap_x 0
gap_y 23

# Subtract file system buffers from used memory?
no_buffers yes

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

# number of cpu samples to average
# set to 1 to disable averaging
cpu_avg_samples 2

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

TEXT
${font Sans:size=14:weight=bold}${color grey}${time %A} - ${time %e} ${time %B} ${time %G} - ${time %H:%M}${alignr}
${font Sans:size=9:weight=bold}${color grey}Machine$color ${color grey}$nodename ${alignr}
${font Sans:size=9:weight=bold}${color grey}Uptime $color$uptime${alignr}
${font Sans:size=9:weight=bold}${color grey}Kernel$color  ${color grey}$kernel ${alignr}
$stippled_hr
# CPU
${color grey}${font Sans:size=9:weight=bold}CPU: ${color white}${cpu cpu0}% ${color grey}${font Sans:size=9:weight=bold}${alignr}FREQ: ${color white}${freq_g 1}Ghz$alignr ${color grey}
${color yellow}$alignc${cpugraph cpu1 20,400}${color grey}${font Sans:size=8:weight=bold}
$stippled_hr
 % cpu    $alignr name           ${color white}
${top cpu 1}  $alignr${top name 1}
${top cpu 2}  $alignr${top name 2}
${top cpu 3}  $alignr${top name 3}
${top cpu 4}  $alignr${top name 4}
${top cpu 5}  $alignr${top name 5}
${top cpu 6}  $alignr${top name 6}
${top cpu 7}  $alignr${top name 7}
${top cpu 8}  $alignr${top name 8}${color grey} 
$stippled_hr
# GPU
${font Sans:size=12:weight=bold}${color grey}GPU Temp: ${color white} ${execi 60 nvidia-settings -query GPUCoreTemp | perl -ne 'print $1 if /GPUCoreTemp.*?: (\d+)./;'} °C   ${color grey} Freq: ${color white} ${nvidia gpufreq}Khz${color grey}${font Sans:size=8:weight=bold}
$stippled_hr
#RAM
#${font Sans:size=8:weight=bold}${color grey}MEMORY${hr 2}$color${font Sans:size=8:weight=bold}
${font Sans:size=8:weight=bold}${color grey}RAM: ${color white}$memperc%${alignr}${color grey}USED: ${color white}$mem/$memmax
${color yellow} ${membar}${color grey}
$stippled_hr
 % mem    $alignr name           ${color white}
${top_mem mem 1}  $alignr${top_mem name 1}
${top_mem mem 2}  $alignr${top_mem name 2}
${top_mem mem 3}  $alignr${top_mem name 3}
${top_mem mem 4}  $alignr${top_mem name 4}
${top_mem mem 5}  $alignr${top_mem name 5}${color grey} 
$stippled_hr
${font Sans:size=8:weight=bold}${color grey}SWAP: ${color white}$swapperc%${alignr}${color grey}USED: ${color white}$swap/$swapmax
${color yellow} ${swapbar}${color grey} 
$stippled_hr
#RHYTHMBOX
${color grey}Playing: 
${color white}${exec /usr/bin/rhythmbox-client --print-playing}${color grey}
$stippled_hr
#NETWORK ${hr 2}
#wlan0
${if_existing /proc/net/route wlan0}
${voffset -6}${font PizzaDude Bullets:size=14}O${font}   Up: ${upspeed wlan0} kb/s ${alignr}${upspeedgraph wlan0 8,60 BEBEBE BEBEBE}
${voffset 4}${font PizzaDude Bullets:size=14}U${font}   Down: ${downspeed wlan0} kb/s ${alignr}${downspeedgraph wlan0 8,60 BEBEBE BEBEBE}
${voffset 4}${font PizzaDude Bullets:size=14}N${font}   Upload: ${alignr}${totalup wlan0}
${voffset 4}${font PizzaDude Bullets:size=14}T${font}   Download: ${alignr}${totaldown wlan0}
${voffset 4}${font PizzaDude Bullets:size=14}Z${font}   Signal: ${wireless_link_qual wlan0}% ${alignr}${wireless_link_bar 8,60 wlan0}
${voffset 4}${font PizzaDude Bullets:size=14}a${font}   Local Ip: ${alignr}${addr wlan0}
#eth0
${else}${if_existing /proc/net/route eth0}
${addrs eth0}

${voffset -6}${font PizzaDude Bullets:size=14}O${font Sans:size=9:weight=bold}   Up: ${upspeed eth0} kb/s ${alignr}${upspeedgraph eth0 12,240 789E2D A7CC5C}
${voffset 4}${font PizzaDude Bullets:size=14}U${font Sans:size=9:weight=bold}   Down: ${downspeed eth0} kb/s ${alignr}${downspeedgraph eth0 12,240 789E2D A7CC5C}
${voffset 4}${font PizzaDude Bullets:size=14}N${font Sans:size=9:weight=bold}   Upload: ${alignr}${totalup eth0}
${voffset 4}${font PizzaDude Bullets:size=14}T${font Sans:size=9:weight=bold}   Download: ${alignr}${totaldown eth0}
${voffset 4}${font PizzaDude Bullets:size=14}a${font Sans:size=9:weight=bold}   Local Ip: ${alignr}${addr eth0}
#eth1
${endif}${else}${if_existing /proc/net/route eth1}
${voffset -6}${font PizzaDude Bullets:size=14}O${font}   Up: ${upspeed eth1} kb/s ${alignr}${upspeedgraph eth1 8,60 789E2D A7CC5C}
${voffset 4}${font PizzaDude Bullets:size=14}U${font}   Down: ${downspeed eth1} kb/s ${alignr}${downspeedgraph eth1 8,60 789E2D A7CC5C}
${voffset 4}${font PizzaDude Bullets:size=14}N${font}   Upload: ${alignr}${totalup eth1}
${voffset 4}${font PizzaDude Bullets:size=14}T${font}   Download: ${alignr}${totaldown eth1}
${voffset 4}${font PizzaDude Bullets:size=14}a${font}   Local Ip: ${alignr}${addr eth1}
${endif}${else}
I've attached a screenshot, the config above is for the conky on my right hand monitor (there are some tiny differences in each!!)

Any help is much appreciated.

Thanks.
Attached Images
File Type: jpg Screenshot.jpg (239.2 KB, 6 views)
 
Old 11-27-2010, 08:16 AM   #2
Hangdog42
LQ Veteran
 
Registered: Feb 2003
Location: Maryland
Distribution: Slackware
Posts: 7,791
Blog Entries: 1

Rep: Reputation: 414Reputation: 414Reputation: 414Reputation: 414Reputation: 414
I don't think that Conky has the native ability to grab an external IP address, but you can do it via a script. I found this somewhere out on the great internets (saved under the name conkyIP):

Code:
#!/bin/bash
# eigene öffentliche ip anzeigen

wget http://checkip.dyndns.org/ -q -O - |
grep -Eo '\<[[:digit:]]{1,3}(\.[[:digit:]]{1,3}){3}\>'
and call it from my .conkyrc using this:

Code:
Public IP: ${color 1b4aee}${execi 10800 ~/.conkycolors/bin/conkyIp}
Obviously you'll need to adjust the name and path to taste.
 
1 members found this post helpful.
Old 11-27-2010, 12:58 PM   #3
PClOStinspace
Member
 
Registered: Jun 2008
Location: Bracknell, UK
Distribution: Ubuntu 13.10 Saucy
Posts: 137

Original Poster
Rep: Reputation: 15
Thanks Hangdog, that was spot on. Config now looks like:-
Code:
# set to yes if you want Conky to be forked in the background
background yes

#font
use_xft yes
xftfont bauhaus:pixelsize=10

# Text alpha when using Xft
xftalpha 0.5

# Update interval in seconds
update_interval 0.5

# 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

# If own_window is yes, you may use type normal, desktop or override
own_window_type normal

# Use pseudo transparency with own_window?
own_window_transparent yes

# If own_window is yes, these window manager hints may be used
own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager

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

# Minimum size of text area
minimum_size 200 100

# Maximum width
maximum_width 300

# Draw shades?
draw_shades no

# Draw outlines?
draw_outline no

# Draw borders around text
draw_borders no

# Draw borders around graphs
draw_graph_borders no

# Stippled borders?
# stippled_borders 8

# border margins
# border_margin 2

# border width
# border_width 1

# Default colors and also border colors
default_color grey
default_shade_color black
default_outline_color grey

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

# Gap between borders of screen and text
# same thing as passing -x at command line
gap_x 0
gap_y 23

# Subtract file system buffers from used memory?
no_buffers yes

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

# number of cpu samples to average
# set to 1 to disable averaging
cpu_avg_samples 2

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

TEXT
${font Sans:size=10:weight=bold}${color grey}${time %A} - ${time %e} ${time %B} ${time %G} - ${time %H:%M}${alignr}
${font Sans:size=9:weight=bold}${color grey}Machine$color ${color grey}$nodename ${alignr}
${font Sans:size=9:weight=bold}${color grey}Uptime $color$uptime${alignr}
${font Sans:size=9:weight=bold}${color grey}Kernel$color  ${color grey}$kernel ${alignr}
$stippled_hr
# CPU
${color grey}${font Sans:size=9:weight=bold}CPU: ${color white}${cpu cpu0}% ${color grey}${font Sans:size=9:weight=bold}${alignr}FREQ: ${color white}${freq_g 1}Ghz$alignr ${color grey}
${color yellow}$alignc${cpugraph cpu1 20,300}${color grey}${font Sans:size=8:weight=bold}
$stippled_hr
 % cpu    $alignr name           ${color white}
${top cpu 1}  $alignr${top name 1}
${top cpu 2}  $alignr${top name 2}
${top cpu 3}  $alignr${top name 3}
${top cpu 4}  $alignr${top name 4}
${top cpu 5}  $alignr${top name 5}${color grey} 
$stippled_hr
# GPU
${font Sans:size=12:weight=bold}${color grey}GPU Temp: ${color white} ${execi 60 nvidia-settings -query GPUCoreTemp | perl -ne 'print $1 if /GPUCoreTemp.*?: (\d+)./;'} °C   ${color grey} Freq: ${color white} ${nvidia gpufreq}Khz${color grey}${font Sans:size=8:weight=bold}
$stippled_hr
#RAM
#${font Sans:size=8:weight=bold}${color grey}MEMORY${hr 2}$color${font Sans:size=8:weight=bold}
${font Sans:size=8:weight=bold}${color grey}RAM: ${color white}$memperc%${alignr}${color grey}USED: ${color white}$mem/$memmax
${color yellow} ${membar}${color grey}
$stippled_hr
 % mem    $alignr name           ${color white}
${top_mem mem 1}  $alignr${top_mem name 1}
${top_mem mem 2}  $alignr${top_mem name 2}
${top_mem mem 3}  $alignr${top_mem name 3}
${top_mem mem 4}  $alignr${top_mem name 4}
${top_mem mem 5}  $alignr${top_mem name 5}${color grey} 
$stippled_hr
${font Sans:size=8:weight=bold}${color grey}SWAP: ${color white}$swapperc%${alignr}${color grey}USED: ${color white}$swap/$swapmax
${color yellow} ${swapbar}${color grey} 
$stippled_hr
#RHYTHMBOX
${color grey}Now playing in Rhythmbox: 
Artist: ${color white}$alignr${exec /usr/bin/rhythmbox-client --print-playing-format=%ta}
${color grey}Track: ${color white}$alignr${exec /usr/bin/rhythmbox-client --print-playing-format=%tt}
${color grey}Album: ${color white}$alignr${exec /usr/bin/rhythmbox-client --print-playing-format=%at}
${color grey}Track time: ${color white}${exec /usr/bin/rhythmbox-client --print-playing-format=%td} $alignr ${color grey}Elapsed time: ${color white}${exec /usr/bin/rhythmbox-client --print-playing-format=%te}${color grey}
$stippled_hr
#NETWORK ${hr 2}
#wlan0
${if_existing /proc/net/route wlan0}
${voffset -6}${font PizzaDude Bullets:size=14}O${font}   Up: ${upspeed wlan0} kb/s ${alignr}${upspeedgraph wlan0 8,60 BEBEBE BEBEBE}
${voffset 4}${font PizzaDude Bullets:size=14}U${font}   Down: ${downspeed wlan0} kb/s ${alignr}${downspeedgraph wlan0 8,60 BEBEBE BEBEBE}
${voffset 4}${font PizzaDude Bullets:size=14}N${font}   Upload: ${alignr}${totalup wlan0}
${voffset 4}${font PizzaDude Bullets:size=14}T${font}   Download: ${alignr}${totaldown wlan0}
${voffset 4}${font PizzaDude Bullets:size=14}Z${font}   Signal: ${wireless_link_qual wlan0}% ${alignr}${wireless_link_bar 8,60 wlan0}
${voffset 4}${font PizzaDude Bullets:size=14}a${font}   Local Ip: ${alignr}${addr wlan0}
#eth0
${else}${if_existing /proc/net/route eth0}
${voffset -6}${font PizzaDude Bullets:size=14}O${font Sans:size=9:weight=bold}   Up: ${upspeed eth0} kb/s ${alignr}${upspeedgraph eth0 12,150 789E2D A7CC5C}
${voffset 4}${font PizzaDude Bullets:size=14}U${font Sans:size=9:weight=bold}   Down: ${downspeed eth0} kb/s ${alignr}${downspeedgraph eth0 12,150 789E2D A7CC5C}
${voffset 4}${font PizzaDude Bullets:size=14}N${font Sans:size=9:weight=bold}   Upload: ${alignr}${totalup eth0}
${voffset 4}${font PizzaDude Bullets:size=14}T${font Sans:size=9:weight=bold}   Download: ${alignr}${totaldown eth0}
${voffset 4}${font PizzaDude Bullets:size=14}a${font Sans:size=9:weight=bold}   Local IP: ${alignr}${addr eth0}
${voffset 4}${font PizzaDude Bullets:size=14}a${font Sans:size=9:weight=bold}   External IP: ${alignr}${execi 10800 ~/Scripts/conkyextip}
#eth1
${endif}${else}${if_existing /proc/net/route eth1}
${voffset -6}${font PizzaDude Bullets:size=14}O${font}   Up: ${upspeed eth1} kb/s ${alignr}${upspeedgraph eth1 8,60 789E2D A7CC5C}
${voffset 4}${font PizzaDude Bullets:size=14}U${font}   Down: ${downspeed eth1} kb/s ${alignr}${downspeedgraph eth1 8,60 789E2D A7CC5C}
${voffset 4}${font PizzaDude Bullets:size=14}N${font}   Upload: ${alignr}${totalup eth1}
${voffset 4}${font PizzaDude Bullets:size=14}T${font}   Download: ${alignr}${totaldown eth1}
${voffset 4}${font PizzaDude Bullets:size=14}a${font}   Local Ip: ${alignr}${addr eth1}
${endif}${else}
${font PizzaDude Bullets:size=14}4${font}   Network Unavailable
${endif}
And works like a charm.
Attached Images
File Type: jpg Screenshot.jpg (224.5 KB, 6 views)

Last edited by PClOStinspace; 11-27-2010 at 07:08 PM.
 
  


Reply

Tags
conky


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
conky question: passing conky-variable to shell-script zlin50 Linux - Software 2 12-29-2012 07:47 PM
LXer: Conky Colors Makes Your Conky Beautiful In Seconds (Version 3.20 Released) LXer Syndicated Linux News 0 08-01-2010 12:21 PM
conky display isssue on Gnome desktop when initiated at startup sd|| Linux - Software 3 11-06-2009 06:21 PM
Incoming connections won't display in conky Decalore Slackware 8 09-12-2008 11:37 AM
Conky on Suse 10.0 - *** buffer overflow detected *** conky terminated Slidex Linux - Software 1 03-17-2006 12:50 PM


All times are GMT -5. The time now is 11:49 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration