You are not logged in.

#1 2009-09-11 12:50:17

bozack
Member
From: Denmark
Registered: 2008-07-10
Posts: 45
Website

Problem with if-else in conky

Hi,

I've made a section in my .conkyrc to check for the type of the network connection, and then to show the corresponding information:

${font SVBasicManual:size=10}NETWORKING::$font${color 00043d}${hr 2}
${if_existing /proc/net/route eth0}
${color lightgrey}IP (eth0): $color${addr eth0}
${color lightgrey} Down:$color ${downspeed eth0} kb/s${color lightgrey} ${offset 70}Up:$color ${upspeed eth0} kb/s
${color 091124}${downspeedgraph eth0 32,150 lightgrey 00043d} $alignr${color 091124}${upspeedgraph eth0 32,150 lightgrey 00043d}
${else}
${if_existing /proc/net/route wlan0}
${color lightgrey}IP (wlan0): $color${addr wlan0}
${color lightgrey} Down:$color ${downspeed wlan0} kb/s${color lightgrey} ${offset 60}Up:$color ${upspeed wlan0} kb/s
${color 091124}${downspeedgraph wlan0 32,150 091124 00043d} $alignr${color 091124}${upspeedgraph wlan0 32,150 091124 00043d}
${color lightgrey}Wireless link quality: $color${wireless_link_qual wlan0} ${wireless_link_bar wlan0}
${color lightgrey}Wireless ESSID: $color${wireless_essid wlan0}
${else}
${color lightgrey}Not connected to any network!
${endif}

My problem is that when I'm connected via eth0, conky shows the correct network information, but then it stops showin anything else: All the code after the part above is simply not used in the conky window... It works as it should when no networks are available and when connected via wlan0.

Can anyone see what the problem is?

Offline

#2 2009-09-11 12:56:50

brisbin33
Member
From: boston, ma
Registered: 2008-07-24
Posts: 1,796
Website

Re: Problem with if-else in conky

try using $endif and $else as opposed to ${endif} and ${else}.

Offline

#3 2009-09-11 13:02:09

bozack
Member
From: Denmark
Registered: 2008-07-10
Posts: 45
Website

Re: Problem with if-else in conky

brisbin33 wrote:

try using $endif and $else as opposed to ${endif} and ${else}.

Unfortunately that didn't do the trick (and since the commands should do the same with and without the {}'s, that's no surprise) sad No change in the behavior of conky there..

Offline

#4 2009-09-11 13:57:35

Boris Bolgradov
Member
From: Bulgaria
Registered: 2008-07-27
Posts: 185

Re: Problem with if-else in conky

I think the first if_existing is not closed by endif. Shouldn't it be like this?:

${font SVBasicManual:size=10}NETWORKING::$font${color 00043d}${hr 2}
${if_existing /proc/net/route eth0}
${color lightgrey}IP (eth0): $color${addr eth0}
${color lightgrey} Down:$color ${downspeed eth0} kb/s${color lightgrey} ${offset 70}Up:$color ${upspeed eth0} kb/s
${color 091124}${downspeedgraph eth0 32,150 lightgrey 00043d} $alignr${color 091124}${upspeedgraph eth0 32,150 lightgrey 00043d}
${else}
${if_existing /proc/net/route wlan0}
${color lightgrey}IP (wlan0): $color${addr wlan0}
${color lightgrey} Down:$color ${downspeed wlan0} kb/s${color lightgrey} ${offset 60}Up:$color ${upspeed wlan0} kb/s
${color 091124}${downspeedgraph wlan0 32,150 091124 00043d} $alignr${color 091124}${upspeedgraph wlan0 32,150 091124 00043d}
${color lightgrey}Wireless link quality: $color${wireless_link_qual wlan0} ${wireless_link_bar wlan0}
${color lightgrey}Wireless ESSID: $color${wireless_essid wlan0}
${else}
${color lightgrey}Not connected to any network!
${endif}
${endif}

Last edited by Boris Bolgradov (2009-09-11 13:58:01)

Offline

#5 2009-09-12 11:52:55

bozack
Member
From: Denmark
Registered: 2008-07-10
Posts: 45
Website

Re: Problem with if-else in conky

Boris Bolgradov wrote:

I think the first if_existing is not closed by endif....

I think you're right! big_smile thanks!

But now I have a new problem... It behaves weird: Only a tiny part of my conky actually shows up:

conkyweird.png

My whole .conkyrc is as follows:

# 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 Bitstream Vera Sans Mono:size=7

# Text alpha when using Xft
xftalpha 0.8

# Update interval in seconds
update_interval 1

# Print text to stdout?
out_to_console no

# Number of samples to average over
cpu_avg_samples 2
net_avg_samples 2

# Create own window instead of using desktop (required in nautilus)
own_window yes

# Other own_window options
own_window_type normal
own_window_transparent yes
own_window_colour hotpink
own_window_hints undecorated,below,skip_taskbar,skip_pager,sticky

# Shows the maximum value in scaled graphs
show_graph_scale yes

# Shows the time range covered by a graph 
show_graph_range no

# Draw borders around graphs? 
draw_graph_borders yes 

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

# Minimum and maximum size of text area
#minimum_size 280 5
maximum_width 310

# Draw shades?
draw_shades no

# Draw outlines?
draw_outline no

# Draw borders around text
draw_borders no

# Stippled borders?
stippled_borders 0

# border margins
border_margin 0

# border width
border_width 0

# Default colors and border colors
default_color 424de5
default_shade_color 0b0b0b
default_outline_color white

# 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
gap_y 0
gap_x 10

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

# Subtract file system buffers from used memory?
no_buffers yes

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

# Total number of times for Conky to update before quitting (0 makes Conky run forever)
total_run_times 0

# Size of the standard text buffer
text_buffer_size 1024



TEXT

${color 00043d}${font KidsFromSnowHill:size=36}N$font    ${font SVBasicManual-Bold:size=9}$sysname $kernel on $nodename$font$color
#${font Devilinside:size=26}N${font}     $sysname $kernel on $nodename
#${font OpenLogos:size=26}Z${font}     $sysname $kernel on $nodename
#${font GiantsOfTheSea:size=16}T${font}     $sysname $kernel on $nodename
#${color lightgrey}Desktop: $color$desktop_name ($desktop/$desktop_number)

${font SVBasicManual:size=10}SYSTEM::$font${color 00043d}${hr 2}
#${color 00043d}$stippled_hr
${color lightgrey}Uptime:$color $uptime ${color lightgrey}- Load:$color $loadavg
#${color lightgrey}Pacman updates:$color${texeci 10800 python /home/bozack/.pacman-conky.py}
${color lightgrey}Pacman updates: $color${if_match ${texeci 1800 pacman -Qu | wc -l} == 0}System is up-to-date ${else}${if_match ${texeci 1800 pacman -Qu | wc -l} > 0}New packages (${texeci 10800 pacman -Qu | wc -l})${else}Read error ${endif}${endif}
${color lightgrey}Battery: $color${battery BAT0} ${alignr}${battery_bar 6,210 BAT0}

#${color lightgrey}CPU Usage:${color #424de5} ${cpu}% ${alignr}${cpubar 6,210 cpu 00043d}
${color lightgrey}CPU Usage:${color #424de5} ${cpu}% ${cpubar cpu 00043d}
${color 091124}${cpugraph 091124 00043d}

${color lightgrey}RAM Usage:$color $mem/$memmax - $memperc% ${alignr}${membar 6,110}
${color lightgrey}Swap Usage:$color $swap/$swapmax - $swapperc% ${alignr}${swapbar 6,110}
#${color lightgrey}Processes:$color $processes  ${color grey}Running:$color $running_processes


${font SVBasicManual:size=10}TEMPERATURES::$font${color 00043d}${hr 2}
#${color lightgrey}System temperatures:
${color lightgrey} GPU (Nvidia GeForce ): $color${hwmon 0 temp 1}°C   
${color lightgrey} CPU (Intel Core2Duo P9600): Core0 $color${hwmon 1 temp 1}°C ${color lightgrey} Core1 $color${hwmon 2 temp 1}°C


${font SVBasicManual:size=10}STORAGE::$font${color 00043d}${hr 2}
${color lightgrey}File systems:
${color lightgrey} / $color${fs_used /}/${fs_size /} ${alignr}${fs_bar 6,170 /}
${color lightgrey} data $color${fs_used /mnt/data}/${fs_size /mnt/data} ${alignr}${fs_bar 6,170 /mnt/data}
${color lightgrey} vista $color${fs_used /mnt/vista}/${fs_size /mnt/vista} ${alignr}${fs_bar 6,170 /mnt/vista}
${color lightgrey} xp $color${fs_used /mnt/xp}/${fs_size /mnt/xp} ${alignr}${fs_bar 6,170 /mnt/xp}

${color lightgrey}Disk read: $color$diskio_read ${color lightgrey}- Disk write: $color$diskio_write
${color 091124}${diskiograph sda 091124 00043d}$color

${font SVBasicManual:size=10}NETWORKING::$font${color 00043d}${hr 2}
${if_existing /proc/net/route eth0}
${color lightgrey}IP (eth0): $color${addr eth0}
${color lightgrey} Down:$color ${downspeed eth0} kb/s${color lightgrey} ${offset 70}Up:$color ${upspeed eth0} kb/s
${color 091124}${downspeedgraph eth0 32,150 lightgrey 00043d} $alignr${color 091124}${upspeedgraph eth0 32,150 lightgrey 00043d}
$else${if_existing /proc/net/route wlan0}
${color lightgrey}IP (wlan0): $color${addr wlan0}
${color lightgrey} Down:$color ${downspeed wlan0} kb/s${color lightgrey} ${offset 60}Up:$color ${upspeed wlan0} kb/s
${color 091124}${downspeedgraph wlan0 32,150 091124 00043d} $alignr${color 091124}${upspeedgraph wlan0 32,150 091124 00043d}
${color lightgrey}Wireless link quality: $color${wireless_link_qual wlan0} ${wireless_link_bar wlan0}
${color lightgrey}Wireless ESSID: $color${wireless_essid wlan0}
$else${color lightgrey}Not connected to any network!
$endif
$endif
${if_xmms2_connected}

${font SVBasicManual:size=10}MUSIC::$font${color 00043d}${hr 2}
${color lightgrey}XMMS $xmms2_status
$color$xmms2_elapsed/$xmms2_duration $xmms2_bar
$color$xmms2_smart
${endif}

${font SVBasicManual:size=10}PROCESSES::$font${color 00043d}${hr 2}
${color lightgrey}Name                   PID   CPU%   MEM%
$color ${top name 1}     ${top pid 1} ${top cpu 1} ${top mem 1}
 ${top name 2}     ${top pid 2} ${top cpu 2} ${top mem 2}
 ${top name 3}     ${top pid 3} ${top cpu 3} ${top mem 3}
${color lightgrey}Mem usage
$color ${top_mem name 1}     ${top_mem pid 1} ${top_mem cpu 1} ${top_mem mem 1}
 ${top_mem name 2}     ${top_mem pid 2} ${top_mem cpu 2} ${top_mem mem 2}
 ${top_mem name 3}     ${top_mem pid 3} ${top_mem cpu 3} ${top_mem mem 3}

Can anyone see the problem? sad

EDIT 1: It does this for all three types of network connections, so I don't think it has something to do with the things above...
EDIT 2: Changed the .conkyrc-code above to a cleaned-up version.
EDIT 3: Added a ${endif} as suggested in post #9.

Last edited by bozack (2009-09-12 21:01:39)

Offline

#6 2009-09-12 16:18:18

cobra2
Member
From: deep in Dixie with Arch64
Registered: 2009-09-10
Posts: 27

Re: Problem with if-else in conky

I had that problem with conky before. Try increaseing the 'text_buffer_size'. It worked for me.

text_buffer_size 1024


Hardware is like a parachute.... works best when open.

Offline

#7 2009-09-12 17:37:34

brisbin33
Member
From: boston, ma
Registered: 2008-07-24
Posts: 1,796
Website

Re: Problem with if-else in conky

this may not be the issue but you've got some repeated / conflicting options in your preamble (own_window_type, etc).  could cause conky to act funny, then again maybe he just uses the last defined value... i dunno.  either way i'd clean it up smile.

Offline

#8 2009-09-12 20:41:26

bozack
Member
From: Denmark
Registered: 2008-07-10
Posts: 45
Website

Re: Problem with if-else in conky

Thanks for the answers.

cobra2 wrote:

Try increaseing the 'text_buffer_size'...

That didn't change anything unfortunately sad...


brisbin33 wrote:

this may not be the issue but you've got some repeated / conflicting options in your preamble (own_window_type, etc).  could cause conky to act funny, then again maybe he just uses the last defined value... i dunno.  either way i'd clean it up smile.

Still having the problem after a clean-up.


So, I still haven't found the solution to my problem... I've edited my .conkyrc code above to be the new cleaned-up code (just to be nice to people) wink

Offline

#9 2009-09-12 20:53:36

Boris Bolgradov
Member
From: Bulgaria
Registered: 2008-07-27
Posts: 185

Re: Problem with if-else in conky

Try to add one more ${endif} at the end of line 110:

${color lightgrey}Pacman updates: ....... ${endif}${endif}

See if that works smile

though, I don't see how this can fix it... anyway...

Last edited by Boris Bolgradov (2009-09-12 20:57:29)

Offline

#10 2009-09-12 21:00:03

bozack
Member
From: Denmark
Registered: 2008-07-10
Posts: 45
Website

Re: Problem with if-else in conky

Boris Bolgradov wrote:

Try to add one more ${endif} at the end of line 110

Hmm you're right, it was actually missing - but unfortunately you were also right in the fact that it wasn't the fix of the problem.. sad

Offline

#11 2009-09-12 21:04:03

Boris Bolgradov
Member
From: Bulgaria
Registered: 2008-07-27
Posts: 185

Re: Problem with if-else in conky

Did you try without compiz? Or try to remove the battery line and try again?

edit: Also try to uncomment "minimum_size 280 5" and change 5 to 500 or similar? This will force conky's height to 500px at least.

Last edited by Boris Bolgradov (2009-09-12 21:08:24)

Offline

#12 2009-09-13 11:37:31

bozack
Member
From: Denmark
Registered: 2008-07-10
Posts: 45
Website

Re: Problem with if-else in conky

Boris Bolgradov wrote:

... try to remove the battery line ... 
... try to uncomment "minimum_size 280 5" and change 5 to 500 or similar ...

I already tried those two before I started the forum thread - since the problem was actually with the height, it might work to force it to get higher - but there was no change. And since the problem kind of shows up just where the battery line was, I also tried to comment this line, but that wasn't the solution either.


But over the night, the problem miraculously disappeared, and I haven't changed anything.. hmm If it happens again, I'll try without compiz.. Lets just hope it's over big_smile

Thanks for the help anyway smile I'll revive the thread if the problem shows up again roll

Offline

Board footer

Powered by FluxBB