You are not logged in.

#1 2008-08-04 08:14:29

hunterthomson
Member
Registered: 2008-06-22
Posts: 794
Website

Conky if-then decision structure (SOLVED)

I am trying to set up a few if-then decision structure in my .conkyrc file but I can seem to get the syntax right. Do you know what it is or what I am doing wrong. (I have tryed like every varyable I can think of....

$if_mounted_/media/disk
/media/disk $alignc ${fs_used /media/disk} / ${fs_size /media/disk} $alignr ${fs_free_perc /media/disk}%
${fs_bar /media/disk}
$endif_mounted_/media/disk

Last edited by hunterthomson (2008-08-05 02:26:59)


OpenBSD-current Thinkpad X230, i7-3520M, 16GB CL9 Kingston, Samsung 830 256GB
Contributor: linux-grsec

Offline

#2 2008-08-04 09:17:05

zyghom
Member
From: Poland/Tanzania
Registered: 2006-05-11
Posts: 430
Website

Re: Conky if-then decision structure (SOLVED)

${if_mounted /hda2}${color1} /        hda7  ${color1}${fs_bar 5,35 /}$alignr${color3}${fs_free /}$else${color1} /        hda2  ${color1}${fs_bar 5,35 /} $alignr${color3}${fs_free /}$endif

or:

${if_existing  /sys/class/power_supply/BAT1/charge_now} $alignc${color8}${execi 10 /scripts/linux/conky/check-battery.pl} $else $alignc${color7}ACPI NOT WORKING$endif

or:

${color2}${if_existing  /var/run/firewall } ${color3} $else $alignc${color7}FW NOT WORKING$endif

Last edited by zyghom (2008-08-04 09:18:39)


Zygfryd Homonto

Offline

#3 2008-08-04 22:47:47

hunterthomson
Member
Registered: 2008-06-22
Posts: 794
Website

Re: Conky if-then decision structure (SOLVED)

Thank You big_smile

Now when I mount a USB or SD card Conky will show all the stats for it and if it is unmounted the graf and stuff will go away smile

Here is a copy of my .conkyrc file:

background yes
use_xft yes
xftfont HandelGotD:size=8
xftalpha 0.1
update_interval 0.5
total_run_times 0
own_window yes
own_window_type normal
own_window_transparent yes
own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager
double_buffer yes
minimum_size 200 5
maximum_width 200
draw_shades no
draw_outline no
draw_borders no
draw_graph_borders no
default_color gray
default_shade_color black
default_outline_color white
alignment top_left
gap_x 8
gap_y 8
no_buffers yes
uppercase no
cpu_avg_samples 2
net_avg_samples 1
override_utf8_locale no
use_spacer yes

TEXT
$sysname $kernel $alignr $machine
Intel Core 2 Duo $alignr ${freq_g cpu0}Ghz
TIME NOW: $alignr ${time %H:%M:%S}
Laptop-Mode $alignr Mode${laptop_mode}
Battery $alignr ${battery_percent}%
$alignr
${cpugraph cpu0 16,200 ffffff ffffff}
CPU:1  ${cpu cpu1}% ${cpubar cpu1}
CPU:2  ${cpu cpu2}% ${cpubar cpu2}

Disk i/o ${diskiograph 16,200}
Network [eth0] $alignr (${addr eth0})
GateWay IP $alignr (${gw_ip})
Down Speed
${downspeedgraph eth0}
Up Speed
${upspeedgraph eth0 16,200}

Network [wlan0] $alignr (${addr wlan0})
MODE ${wireless_mode wlan0} $alignr Mb/s${wireless_bitrate wlan0}
Link Quality $alignr ${wireless_link_qual_perc wlan0}%
ESSID $alignr (${wireless_essid wlan0})
AP's MAC address $alignr (${wireless_ap wlan0})

MEM $alignc $mem / $memmax $alignr $memperc%
$membar
Swap ${swap}/${swapmax} $alignr $swapperc%
${swapbar}
/home $alignc ${fs_used /home} / ${fs_size /home} $alignr ${fs_free_perc /home}%
${fs_bar /home}
/ $alignc ${fs_used /} / ${fs_size /} $alignr ${fs_free_perc /}%
${fs_bar /}
${if_mounted /media/disk} Disk $alignc ${fs_used /media/disk} / ${fs_size /media/disk} $alignr ${fs_free_perc /media/disk}%$else$endif
${if_mounted /media/disk} ${fs_bar /media/disk}$else$endif
${if_mounted /media/disk-1} Disk1 $alignc ${fs_used /media/disk-1} / ${fs_size /media/disk-1} $alignr ${fs_free_perc /media/disk-1}%$else$endif
${if_mounted /media/disk-1} ${fs_bar /media/disk-1}$else$endif
${if_mounted /media/disk-2} Disk2 $alignc ${fs_used /media/disk-2} / ${fs_size /media/disk-2} $alignr ${fs_free_perc /media/disk-2}%$else$endif
${if_mounted /media/disk-2} ${fs_bar /media/disk-2}$else$endif

Last edited by hunterthomson (2008-08-04 22:48:48)


OpenBSD-current Thinkpad X230, i7-3520M, 16GB CL9 Kingston, Samsung 830 256GB
Contributor: linux-grsec

Offline

#4 2008-08-04 23:32:43

sand_man
Member
From: Australia
Registered: 2008-06-10
Posts: 2,164

Re: Conky if-then decision structure (SOLVED)

You know there is no such thing as an "if loop" right? wink


neutral

Offline

#5 2008-08-05 00:32:12

hunterthomson
Member
Registered: 2008-06-22
Posts: 794
Website

Re: Conky if-then decision structure (SOLVED)

sand_man wrote:

You know there is no such thing as an "if loop" right? wink

What is it cald then? Just a loop?


OpenBSD-current Thinkpad X230, i7-3520M, 16GB CL9 Kingston, Samsung 830 256GB
Contributor: linux-grsec

Offline

#6 2008-08-05 00:54:14

kclive18
Member
From: Columbus, Ohio, USA
Registered: 2008-05-08
Posts: 219

Re: Conky if-then decision structure (SOLVED)

It's an if-then decision structure, NOT a loop, as it only performs a task once and only once.  for and while structures are loops that iterate tasks over and over.

Conky is pretty neat, I may try it sometime since my XFCE desktop is pretty clean:

screenshot3zs3.th.png

Last edited by kclive18 (2008-08-05 00:55:51)


My Rigs:
- Mid-2007 iMac 20", Intel 2GHz Core 2 Duo, 2x1GB DDR2-800, 250GB SATA HDD, and...MIGHTY MOUSE!!! tongue, OSX 10.5 Leopard, ATI Radeon 2400XT 128MB
- HP zv6203cl, AMD Athlon 64 3200 S939, 2x512MB DDR400, 80GB 4200rpm HDD, ATI Radeon Xpress 200M 128MB, Arch i686 cool
- 1986 Gibson SG Junior Cherry Red, Ibanez 15W amp, DigiTech RP250 modeling processor

Offline

#7 2008-08-05 01:10:38

hunterthomson
Member
Registered: 2008-06-22
Posts: 794
Website

Re: Conky if-then decision structure (SOLVED)

Well that makes sents...
here is a pic of my OpenBox desktop.... Vary clean cool

I hope you can stop those "Crackers" form cracking your Gibson and Stealing a copy your Da Vinci Virus Code tongue
Looks like it will be hard though. Codeing in 3D wow now that is a skill tongue

openbox1nk5.th.jpg

Last edited by hunterthomson (2008-08-05 01:25:43)


OpenBSD-current Thinkpad X230, i7-3520M, 16GB CL9 Kingston, Samsung 830 256GB
Contributor: linux-grsec

Offline

#8 2008-08-06 00:50:47

hunterthomson
Member
Registered: 2008-06-22
Posts: 794
Website

Re: Conky if-then decision structure (SOLVED)

OK now I have taken this really far.... Check this out cool

background yes
use_xft yes
xftfont HandelGotD:size=8
xftalpha 0.1
update_interval 0.5
total_run_times 0
own_window yes
own_window_type normal
own_window_transparent yes
own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager
double_buffer yes
minimum_size 200 5
maximum_width 200
draw_shades no
draw_outline no
draw_borders no
draw_graph_borders no
default_color gray
default_shade_color black
default_outline_color white
alignment top_left
gap_x 8
gap_y 8
no_buffers yes
uppercase no
cpu_avg_samples 2
net_avg_samples 1
override_utf8_locale no
use_spacer yes

TEXT
${alignc}${time %I:%M:%S %p}
$sysname $kernel $alignr $machine
Intel Core 2 Duo T5550 $alignr ${freq_g cpu0}Ghz
Laptop-Mode $alignr Mode${laptop_mode}
Battery $alignr ${battery_percent}%
${cpugraph cpu0 16,200}
CPU:1  ${cpu cpu1}% ${cpubar cpu1}
CPU:2  ${cpu cpu2}% ${cpubar cpu2}

${if_up eth0}Ethernet Up${else}Ethernet Down $endif
${if_up eth0}GateWay IP $alignr(${gw_ip})${else}GateWay IP [eth0]$alignr (Not-Associated)$endif
${if_up eth0}Public IP $alignr (${addr eth0})${else}Public IP [eth0]$alignr (Not-Associated)$endif
Down Speed
${if_up wlan0}${downspeedgraph wlan0}$else${downspeedgraph eth0}$endif
Up Speed
${if_up wlan0}${upspeedgraph wlan0}$else${upspeedgraph eth0}endif
${if_up wlan0}Wireless Up${else}Wireless Down $endif
wlan0 Mode-${wireless_mode wlan0} $alignr Mb/s${wireless_bitrate wlan0}
${if_up wlan0}Link Quality $alignr ${wireless_link_qual_perc wlan0}%${else}Link Quality $alignr (Not-Associated)$endif
${if_up wlan0}ESSID $alignr (${wireless_essid wlan0})${else}ESSID $alignr (Not-Associated)$endif
AP's MAC address $alignr (${wireless_ap wlan0})
${if_up wlan0}Gateway IP $alignr (${gw_ip})${else}Gateway IP $alignr (Not-Associated)$endif
${if_up wlan0}Public IP $alignr (${addr wlan0})${else}Public IP $alignr (Not-Associated)$endif

Disk i/o
${diskiograph 16,200}
MEM $alignc $mem / $memmax $alignr $memperc%
$membar
Swap ${swap}/${swapmax} $alignr $swapperc%
${swapbar}
/home $alignc ${fs_used /home} / ${fs_size /home} $alignr ${fs_free_perc /home}%
${fs_bar /home}
/ $alignc ${fs_used /} / ${fs_size /} $alignr ${fs_free_perc /}%
${fs_bar /}
${if_mounted /media/disk} USB/SD $alignc ${fs_used /media/disk} / ${fs_size /media/disk} $alignr ${fs_free_perc /media/disk}%$else$endif
${if_mounted /media/disk}${fs_bar /media/disk}$else$endif
${if_mounted /media/disk-1} USB/SD $alignc ${fs_used /media/disk-1} / ${fs_size /media/disk-1} $alignr ${fs_free_perc /media/disk-1}%$else$endif
${if_mounted /media/disk-1}${fs_bar /media/disk-1}$else$endif
${if_mounted /media/disk-2} USB/SD $alignc ${fs_used /media/disk-2} / ${fs_size /media/disk-2} $alignr ${fs_free_perc /media/disk-2}%$else$endif
${if_mounted /media/disk-2}${fs_bar /media/disk-2}$else$endif

Last edited by hunterthomson (2008-08-06 01:11:17)


OpenBSD-current Thinkpad X230, i7-3520M, 16GB CL9 Kingston, Samsung 830 256GB
Contributor: linux-grsec

Offline

#9 2009-10-30 11:37:56

toketin
Member
From: Belluno (Italy)
Registered: 2007-04-17
Posts: 317

Re: Conky if-then decision structure (SOLVED)

Halo, this is my netbook desktop i've configured correctly my conky in order to have wlan0, ppp0, or eth0 informations of connection but conky, when i don't use wifi connection, displays a strange [] near the totaldown, you can see better in the screenshot:
screenconk.th.png

and this is my conkyrc:

#avoid flicker
double_buffer yes

#own window to run simultanious 2 or more conkys
own_window  yes
own_window_transparent no
own_window_type normal
own_window_hints undecorate,sticky,skip_taskbar,skip_pager 

#borders
draw_borders no
border_margin 3

#shades
draw_shades no

#position
gap_x 0
gap_y 4
alignment top_left

#behaviour
update_interval 1

#colour
default_color  8f8f8f
#default_shade_color 000000
own_window_colour 262729

#font
use_xft yes
xftfont sans:size=7

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

#to prevent window from moving
use_spacer none
minimum_size 1024 0

#mpd
#mpd_host localhost
#mpd_port 6600

TEXT
Kernel: ${color e0e0e0}$kernel${color}  Uptime: ${color e0e0e0}${uptime_short}${color}  |  Cpu: ${color e0e0e0}${cpu}%${color}  Ram: ${color e0e0e0}${memperc}%${color}  Swap: ${color e0e0e0}${swapperc}%${color}  |  Root: ${color e0e0e0}${fs_free_perc /}%${color}   Home: ${color e0e0e0}${fs_free_perc /home}%${color}   |  ${if_existing /proc/net/route wlan0}   Up: ${color e0e0e0}${upspeedf wlan0} kb/s - ${totalup wlan0}${color}  Down: ${color e0e0e0}${downspeedf wlan0} kb/s - ${totaldown wlan0}${color}${else}${if_existing /proc/net/route ppp0}Up: ${color e0e0e0}${upspeedf ppp0} kb/s - ${totalup ppp0}${color}  Down: ${color e0e0e0}${downspeedf ppp0} kb/s - ${totaldown ppp0}${color}${else}${if_existing /proc/net/route eth0}Up: ${color e0e0e0}${upspeedf eth0} kb/s - ${totalup eth0}${color}  Down: ${color e0e0e0}${downspeedf eth0} kb/s - ${totaldown eth0}${color}${else}Nessuna Connessione${color}${endif}${alignc}

can anyone tell me why it displays this strange symbol? Thanks

Offline

#10 2009-10-30 11:41:00

toketin
Member
From: Belluno (Italy)
Registered: 2007-04-17
Posts: 317

Re: Conky if-then decision structure (SOLVED)

i've also added three $endif at the end of text but nothing, now with three endif it displays always the [] while with the configuration above (only one $endif) if i'm connected through wifi it doens't display the symbol in the other case yes!

Offline

#11 2009-12-11 02:28:50

hunterthomson
Member
Registered: 2008-06-22
Posts: 794
Website

Re: Conky if-then decision structure (SOLVED)

Well you asked this a long time ago. But I am board.

I don't have conky installed so I can't test this. I am using KDEmod now so I have to use SuperKambra.

---------

I think you needed to add an ${endif} after the first ${else}

note: you can use the backslash to escape the new like caritor

So it would go like this:

If 1=x ;
    print x
    
    else
        if 1=y ;
            print y
        endif
    
    else
        if 1=z ;
            print z
        endif

endif

---------
New code:

#avoid flicker
double_buffer yes

#own window to run simultanious 2 or more conkys
own_window  yes
own_window_transparent no
own_window_type normal
own_window_hints undecorate,sticky,skip_taskbar,skip_pager 

#borders
draw_borders no
border_margin 3

#shades
draw_shades no

#position
gap_x 0
gap_y 4
alignment top_left

#behaviour
update_interval 1

#colour
default_color  8f8f8f
#default_shade_color 000000
own_window_colour 262729

#font
use_xft yes
xftfont sans:size=7

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

#to prevent window from moving
use_spacer none
minimum_size 1024 0

#mpd
#mpd_host localhost
#mpd_port 6600

TEXT
Kernel: ${color e0e0e0}$kernel${color} \
 Uptime: ${color e0e0e0}${uptime_short}${color}  \
|  Cpu: ${color e0e0e0}${cpu}%${color}  \
Ram: ${color e0e0e0}${memperc}%${color}  \
Swap: ${color e0e0e0}${swapperc}%${color}  \
|  Root: ${color e0e0e0}${fs_free_perc /}%${color}   \
Home: ${color e0e0e0}${fs_free_perc /home}%${color}   \
\
|  ${if_existing /proc/net/route wlan0}   Up: ${color e0e0e0}${upspeedf wlan0} kb/s - ${totalup wlan0}${color}  \
Down: ${color e0e0e0}${downspeedf wlan0} kb/s - ${totaldown wlan0}${color}\
\
${else}\
\
${if_existing /proc/net/route ppp0}Up: \
${color e0e0e0}${upspeedf ppp0} kb/s - ${totalup ppp0}${color}  \
Down: ${color e0e0e0}${downspeedf ppp0} \
kb/s - ${totaldown ppp0}${color}\
\
${endif}${else}\
\
${if_existing /proc/net/route eth0}\
Up: ${color e0e0e0}${upspeedf eth0} kb/s - ${totalup eth0}${color}  \
Down: ${color e0e0e0}${downspeedf eth0} kb/s - ${totaldown eth0}${color}${else}Nessuna Connessione${color}\
\
${endif}\
\
${endif}

Last edited by hunterthomson (2009-12-11 02:30:02)


OpenBSD-current Thinkpad X230, i7-3520M, 16GB CL9 Kingston, Samsung 830 256GB
Contributor: linux-grsec

Offline

Board footer

Powered by FluxBB