[SOLVED] How do I display external IP address in Conky?
Linux - SoftwareThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
Click here to see the post LQ members have rated as the most helpful post in this thread.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.