Topic: [SOLVED] Conky Conditional Statement

Is there a way to make a conky config that will check to see it your wlan card is on/off. When it is on, it should show some set of information that you choose. When it is off, none of that information should be shown.

I like to see:
Link Quality
SSID
Up
Down
Upload
Download
IP Address

I know that conky has if-elseif-endif statements, but I assume that those go through the config once, and then don't go through it again.

I guess that it could be done with an external script as well, but I am no programmer, so I am not sure about that.

Thoughts?

Michael

Last edited by michaelramm (2008-12-08 22:21:08)

The 1-Man IT Department | Ubuntu User #16666 | Linux User #451972
My Social Nets: Identi.ca | twitter | friendfeed
Crunchbangin' and Loving Every Minute of IT!

Re: [SOLVED] Conky Conditional Statement

I guess I should qualify what I was looking for.

Here is my Network section of conkyrc:

NETWORK ${hr 2}
${if_existing /proc/net/route eth0}
${alignc}Wired
     Up: ${upspeed eth0} kb/s ${alignr}${upspeedgraph eth0 8,60 789E2D A7CC5C}
     Down: ${downspeed eth0} kb/s ${alignr}${downspeedgraph eth0 8,60 789E2D A7CC5C}
     Upload: ${alignr}${totalup eth0} 
     Download: ${alignr}${totaldown eth0}
     Local IP: ${alignr}${addr eth0}
${else}
${if_existing /proc/net/route eth1}
${alignc}Wireless
     Signal: ${wireless_link_qual eth1}% ${alignr}${wireless_link_bar 8,60 eth1}
     Attached to:${alignr}${wireless_essid eth1}
     Up: ${upspeed eth1} kb/s ${alignr}${upspeedgraph eth1 8,60 789E2D A7CC5C}
     Down: ${downspeed eth1} kb/s ${alignr}${downspeedgraph eth1 8,60 789E2D A7CC5C}
     Upload: ${alignr}${totalup eth1}
     Download: ${alignr}${totaldown eth1}
     Local IP: ${alignr}${addr eth1}
${endif}

But when I 'Enable Wireless', the Wireless section does not refresh in conky to add it to my screen.

I was looking for more of a realtime monitor of my wireless stats.

Michael

[SOLVED]
I took out the else that is bolded above, and it is rocking along just how I want it to. Wireless section goes away when I turn off wireless and it reappears when I turn it on!

Thanks,
Michael

Last edited by michaelramm (2008-12-08 22:19:53)

The 1-Man IT Department | Ubuntu User #16666 | Linux User #451972
My Social Nets: Identi.ca | twitter | friendfeed
Crunchbangin' and Loving Every Minute of IT!

Re: [SOLVED] Conky Conditional Statement

I've been recently added conditional statement in conky and have some problems..

When I run my comp, in conky I don't see upspeedgraph and all belllow that.
When I restart conky, everything is just fine, but first time no.

If I drop if-else-endif statements, works well.

I make conditional statements becaouse Mobile internet on USB, to avoid mess without cond. statements.

So, I like idea, but it's annoying to restart conky every time I start comp.

Any help?

Here's mine .conkyrc

# set to yes if you want Conky to be forked in the background
background yes

# Use Xft?
use_xft yes

# Xft font when Xft is enabled
#xftfont Trebuchet MS:size=10
xftfont Sans:size=8

# Text alpha when using Xft
xftalpha 1

# Update interval in seconds
update_interval 1.0

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

own_window yes
own_window_transparent yes
#own_window_type override
own_window_type desktop
#own_window_type normal #use this if you want a nice shadow to appear around conky

# 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 200

# Maximum width
maximum_width 200

# Draw shades?
draw_shades yes

# 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 white
default_shade_color black
default_outline_color white

# 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 12
gap_y 24

# 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 required XFT
override_utf8_locale yes

##############################################
##############################################

TEXT
${font Arial Black:size=24}$alignc${time %H:%M}${font Sans:size=4}

${font Arial:size=9:style=italic}$alignc${time %A, %d. %B %Y}

${font Sans:size=8}${color #aaff55}Uptime:$alignr${color #ffffff}$uptime${color #aaff55}

Kernel:${font Sans:size=7}$alignr$kernel${font Sans:size=8}

CPU:$alignr${cpu cpu1}%  ${cpubar 6,100}${font Sans:size=3}

${font Sans:size=8}RAM:$alignr$memperc%  ${membar 6,100}
${font Sans:size=7}$alignr$mem  /  $memeasyfree

${font Sans:size=8:bold}APP${alignr}MEM${font Sans:size=4}
$hr
${font Sans:size=8}${top_mem name 1} ${alignr}${top_mem mem_res 1}
${top_mem name 2} $alignr${top_mem mem_res 2}
${top_mem name 3} $alignr${top_mem mem_res 3}
${top_mem name 4} $alignr${top_mem mem_res 4}
${top_mem name 5} $alignr${top_mem mem_res 5}
${top_mem name 6} $alignr${top_mem mem_res 6}
${top_mem name 7} $alignr${top_mem mem_res 7}
${top_mem name 8} $alignr${top_mem mem_res 8}

${font Arial Black:size=10}HDD${font Sans:size=3}
$hr

${font Sans:size=8}Root:${alignr}${fs_used_perc /}%  ${fs_bar 6,100 /}
${font Sans:size=7}$alignr${fs_used /} / ${fs_free /}

${font Sans:size=8}Home:${alignr}${fs_used_perc /home}%  ${fs_bar 6,100 /home}
${font Sans:size=7}$alignr${fs_used /home} / ${fs_free /home}

${font Arial Black:size=10}NETWORK${font Sans:size=3}
$hr
${if_existing /proc/net/route eth1}
${font sans-serif:normal:size=8}WLAN: ${alignr}${wireless_essid eth1}
IP address:${font Sans:size=7}${alignr}${addr eth1}${font Sans:size=8}
Bitrate:${font Sans:size=7}${alignr}${wireless_bitrate eth1}${font Sans:size=8}
Signal:${alignr}${wireless_link_qual_perc eth1}%  ${wireless_link_bar 6,100 eth1}
${downspeedgraph eth1}
DLS:${downspeed eth1} ${alignr}download: ${totaldown eth1}
${upspeedgraph eth1}
ULS:${upspeed eth1} ${alignr}upload: ${totalup eth1}
${endif}
${if_existing /proc/net/route ppp0}
${font sans-serif:normal:size=8}T-Mobile
IP address: ${alignr}${addr ppp0}
DLS:${downspeed ppp0} ${alignr}download: ${totaldown ppp0}
ULS:${upspeed ppp0} ${alignr}upload: ${totalup ppp0}
${endif}

Re: [SOLVED] Conky Conditional Statement

IgorP wrote:

I've been recently added conditional statement in conky and have some problems..

When I run my comp, in conky I don't see upspeedgraph and all belllow that.
When I restart conky, everything is just fine, but first time no.

If I drop if-else-endif statements, works well.

I make conditional statements becaouse Mobile internet on USB, to avoid mess without cond. statements.

So, I like idea, but it's annoying to restart conky every time I start comp.

Any help?

Here's mine .conkyrc

have you tried increasing the sleep time in your autostart.sh file (mines set at 2 seconds) just to let your network stuff startup properly, otherwise try starting it for the first time starting from the terminal, see if it gives you any errors

- - - - - - - - Wiki Pages - - - - - - -
#! install guide           *autostart programs, modify the menu & keybindings
configuring Conky       *installing scripts

Re: [SOLVED] Conky Conditional Statement

I know it says "SOLVED", but here's my conkyrc (the relevant bit) that essentially does the same:

${if_existing /proc/net/route wlan0}${font sans-serif:bold:size=8}WiFi  ${font sans-serif:normal:size=8} $alignr ${addr wlan0}
Inbound $alignr ${downspeed wlan0} kb/s
${downspeedgraph wlan0}
Outbound $alignr ${upspeed wlan0} kb/s
${upspeedgraph wlan0}${endif}
Ex-KDE user.
Collects old PC's (Coz he can't afford new ones =P)
Crunchbang @ Distrowatch
My Blog (updated infrequently, and on the #! Planet too.)

Re: [SOLVED] Conky Conditional Statement

Thanks for answers, but I figured way out.

Next lines works for me the way I want:

${if_up eth1}
${font sans-serif:normal:size=8}WLAN: ${alignr}${wireless_essid eth1}
IP address:${font Sans:size=7}${alignr}${addr eth1}${font Sans:size=8}
Bitrate:${font Sans:size=7}${alignr}${wireless_bitrate eth1}${font Sans:size=8}
Signal:${alignr}${wireless_link_qual_perc eth1}%  ${wireless_link_bar 6,100 eth1}
${downspeedgraph eth1}
DLS:${downspeed eth1} ${alignr}download: ${totaldown eth1}
${upspeedgraph eth1}
ULS:${upspeed eth1} ${alignr}upload: ${totalup eth1}
${else}${font Sans:size=8}No wireless network${endif}
${if_up ppp0}
${font sans-serif:normal:size=8}T-Mobile
IP address: ${alignr}${addr ppp0}
DLS:${downspeed ppp0} ${alignr}download: ${totaldown ppp0}
ULS:${upspeed ppp0} ${alignr}upload: ${totalup ppp0}
${endif}

Thank you, anyway! smile

Regards!

Last edited by IgorP (2009-10-06 18:52:56)

Re: [SOLVED] Conky Conditional Statement

if_existing /proc/net/route interfacename