Skip to main content

Thread: if_match issue with conky


i'm running conky2-desklet derived version of conky, looks great, have 1 more thing i'd do, display charging icon. .conkyrc file runs fine terminal, , no errors, following line 'doesn't work.'

code:
${if_match "${battery_short}" != "d"}${image ~/conky/charging.png -p 209,491}${else}${image ~/conky/discharging.png -p 209,491}$endif
the image shows charging 1 (whether laptop's plugged in or not). ideas i'm doing wrong? (i'm noob) i've been working on way long, , google-fu appears have failed me. in case i'll include whole file, , lua file, in case it's in there.

.conkyrc
code:
# conky settings #background no update_interval 1   cpu_avg_samples 2 net_avg_samples 2   override_utf8_locale yes   double_buffer yes no_buffers yes   text_buffer_size 2048 #imlib_cache_size 0   temperature_unit celsius   # window specifications # own_window_class conky own_window yes own_window_type normal own_window_transparent yes own_window_hints undecorate,sticky,skip_taskbar,skip_pager,below   border_inner_margin 0 border_outer_margin 0   minimum_size 350 550 maximum_width 550   alignment tr gap_x -20 gap_y 185   # graphics settings # draw_shades no draw_outline no draw_borders no draw_graph_borders no   # text settings # use_xft yes override_utf8_locale yes xftfont pf tempesta five:bold:size=6 xftalpha 0.8 uppercase no   temperature_unit celsius   default_color 333333 color0 fb88eb color1 363636 color2 1994d1 color3 1994d1    # lua load  ##${voffset 700} lua_load ~/conky/rings-v1.2.1.lua lua_draw_hook_pre ring_stats   text ${font pf tempesta five:bold:size=6}${voffset 34}${goto 96}${color1}cpu ${alignr 145}${color1}${cpu}% / ${color1}${acpitemp}°c ${font pf tempesta five:bold:size=6}${goto 79}${color1}ram ${alignr 145}${color1}${memperc}% / ${color1}${memmax} ${font pf tempesta five:bold:size=6}${goto 63}${color1}gpu ${alignr 145}${color1}${nvidia gpufreq} / ${color1}540 mhz ${font pf tempesta five:bold:size=6}${goto 48}uptime${color1}${alignr 145}${uptime_short} ${font xirod:size=10}${color0}${voffset 3}${offset 20}system   ${font xirod:size=8}${color0}${voffset 80}${goto 184}network ${font pf tempesta five:bold:size=6}${goto 146}${color1}up${goto 195}${color1}${totalup eth1} / ${color1}${upspeed eth1} ${font pf tempesta five:bold:size=6}${goto 146}${voffset 0}down${goto 205}${color1}${totaldown eth1} / ${color1}${downspeed eth1}   ${font pf tempesta five:bold:size=6}${goto 107}${voffset 4}rot${color1}${alignr 135}${fs_used_perc /}% / ${color1}${fs_size /} ${font pf tempesta five:bold:size=6}${goto 95}home${alignr 135}${color1}${fs_used_perc /home}% / ${color1}${fs_size /home} ${font pf tempesta five:bold:size=6}${goto 86}usb${alignr 135}${color1}${fs_used_perc /media/usb0}% / ${color1}${fs_size /media/usb0} ${font xirod:size=8}${color0}${goto 56}${voffset 16}hard drive   ${font xirod:size=8}${goto 186}${voffset 66}${color0}${time %d} ${ fcolor0}${time %a}   ${font xirod:size=8}${color0}${goto 168}${voffset 12}${color1}${battery_percent bat0}% ${font xirod:size=8}${color0}${goto 106}${voffset 10}battery   ${if_match "${battery_short}" != "d"}${image ~/conky/charging.png -p 209,491}${else}${image ~/conky/discharging.png -p 209,491}${endif}
and lua file:
code:
--[[ring meters londonali1010 (2009)   script draws percentage meters rings. customisable; options described in script.   important: if using 'cpu' function, cause segmentation fault if tries draw ring straight away. if statement near end of script uses delay make sure doesn't happen. calculates length of delay number of updates since conky started. generally, value of 5s long enough, if update conky every 1s, use update_num > 5 in if statement (the default). if update conky every 2s, should change update_num > 3; conversely if update conky every 0.5s, should use update_num > 10. also, if change conky, best use "killall conky; conky" update it, otherwise update_num not reset , error.   call script in conky, use following (assuming save script ~/scripts/rings.lua):     lua_load ~/scripts/rings-v1.2.1.lua     lua_draw_hook_pre ring_stats      changelog: + v1.2.1 -- fixed minor bug caused script crash if conky_parse() returns nil value (20.10.2009) + v1.2 -- added option ending angle of rings (07.10.2009) + v1.1 -- added options starting angle of rings, , added "max" variable, allow variables output numerical value rather percentage (29.09.2009) + v1.0 -- original release (28.09.2009) ]]   settings_table = {       {         name='cpu',         arg='cpu0',         max=100,         bg_colour=0x363636,         bg_alpha=1.0,         fg_colour=0xfb88eb,         fg_alpha=0.8,         x=215, y=108,         radius=70,         thickness=20,         start_angle=0,         end_angle=270     },     {         name='memperc',         arg='',         max=100,         bg_colour=0x363636,         bg_alpha=0.6,         fg_colour=0xfb88eb,         fg_alpha=0.8,         x=215, y=108,         radius=50,         thickness=15,         start_angle=0,         end_angle=270     },         {         name='nvidia',         arg='gpufreq',         max=540,         bg_colour=0x363636,         bg_alpha=0.4,         fg_colour=0xfb88eb,         fg_alpha=0.8,         x=215, y=108,         radius=35,         thickness=10,         start_angle=0,         end_angle=270     },     {         name='fs_used_perc',         arg='/',         max=100,         bg_colour=0x363636,         bg_alpha=1.0,         fg_colour=0xfb88eb,         fg_alpha=0.8,         x=220, y=328,         radius=40,         thickness=15,         start_angle=0,         end_angle=270     },     {         name='fs_used_perc',         arg='/home',         max=100,         bg_colour=0x363636,         bg_alpha=0.6,         fg_colour=0xfb88eb,         fg_alpha=0.8,         x=220, y=328,         radius=25,         thickness=10,         start_angle=0,         end_angle=270     },     {         name='fs_used_perc',         arg='/media/usb0',         max=100,         bg_colour=0x363636,         bg_alpha=0.4,         fg_colour=0xfb88eb,         fg_alpha=0.8,         x=220, y=328,         radius=15,         thickness=5,         start_angle=0,         end_angle=270     },     {         name='upspeedf',         arg='eth1',         max=1000,         bg_colour=0x363636,         bg_alpha=1.0,         fg_colour=0xfb88eb,         fg_alpha=0.8,         x=140, y=224,         radius=30,         thickness=12,         start_angle=180,         end_angle=450     },     {         name='downspeedf',         arg='eth1',         max=100,         bg_colour=0x363636,         bg_alpha=0.6,         fg_colour=0xfb88eb,         fg_alpha=0.8,         x=140, y=224,         radius=18,         thickness=8,         start_angle=180,         end_angle=450     },     {         name='time',         arg='%s',         max=60,         bg_colour=0x363636,         bg_alpha=1.0,         fg_colour=0xfb88eb,         fg_alpha=0.8,         x=152, y=418,         radius=30,         thickness=12,         start_angle=0,         end_angle=360     },      {         name='time',         arg='%m',         max=60,         bg_colour=0x363636,         bg_alpha=0.6,         fg_colour=0xfb88eb,         fg_alpha=0.8,         x=152, y=418,         radius=18,         thickness=8,         start_angle=0,         end_angle=360     },     {         name='time',         arg='%i',         max=12,         bg_colour=0x363636,         bg_alpha=0.4,         fg_colour=0xfb88eb,         fg_alpha=0.8,         x=152, y=418,         radius=10,         thickness=4,         start_angle=0,         end_angle=360     },        {         name='battery_percent',         arg='bat0',         max=100,         bg_colour=0x363636,         bg_alpha=0.6,         fg_colour=0xfb88eb,         fg_alpha=0.8,         x=220, y=502,         radius=18,         thickness=10,         start_angle=0,         end_angle=270     }, }   -- use these settings define origin , extent of clock.   clock_r=36   -- "clock_x" , "clock_y" coordinates of centre of clock, in pixels, top left of conky window.   clock_x=152 clock_y=418   show_seconds=true   require 'cairo'   function rgb_to_r_g_b(colour,alpha)     return ((colour / 0x10000) % 0x100) / 255., ((colour / 0x100) % 0x100) / 255., (colour % 0x100) / 255., alpha end   function draw_ring(cr,t,pt)     local w,h=conky_window.width,conky_window.height          local xc,yc,ring_r,ring_w,sa,ea=pt['x'],pt['y'],pt['radius'],pt['thickness'],pt['start_angle'],pt['end_angle']     local bgc, bga, fgc, fga=pt['bg_colour'], pt['bg_alpha'], pt['fg_colour'], pt['fg_alpha']       local angle_0=sa*(2*math.pi/360)-math.pi/2     local angle_f=ea*(2*math.pi/360)-math.pi/2     local t_arc=t*(angle_f-angle_0)       -- draw background ring       cairo_arc(cr,xc,yc,ring_r,angle_0,angle_f)     cairo_set_source_rgba(cr,rgb_to_r_g_b(bgc,bga))     cairo_set_line_width(cr,ring_w)     cairo_stroke(cr)          -- draw indicator ring       cairo_arc(cr,xc,yc,ring_r,angle_0,angle_0+t_arc)     cairo_set_source_rgba(cr,rgb_to_r_g_b(fgc,fga))     cairo_stroke(cr)         end   function draw_clock_hands(cr,xc,yc)     local secs,mins,hours,secs_arc,mins_arc,hours_arc     local xh,yh,xm,ym,xs,ys          secs=os.date("%s")         mins=os.date("%m")     hours=os.date("%i")              secs_arc=(2*math.pi/60)*secs     mins_arc=(2*math.pi/60)*mins+secs_arc/60     hours_arc=(2*math.pi/12)*hours+mins_arc/12              -- draw hour hand          xh=xc+0.62*clock_r*math.sin(hours_arc)     yh=yc-0.62*clock_r*math.cos(hours_arc)     cairo_move_to(cr,xc,yc)     cairo_line_to(cr,xh,yh)          cairo_set_line_cap(cr,cairo_line_cap_square)     cairo_set_line_width(cr,1)     cairo_set_source_rgba(cr,0.804,0.149,0.380,1.0)     cairo_stroke(cr)          -- draw minute hand          xm=xc+clock_r*math.sin(mins_arc)     ym=yc-clock_r*math.cos(mins_arc)     cairo_move_to(cr,xc,yc)     cairo_line_to(cr,xm,ym)          cairo_set_line_width(cr,1)     cairo_stroke(cr)          -- draw seconds hand          if show_seconds         xs=xc+clock_r*math.sin(secs_arc)         ys=yc-clock_r*math.cos(secs_arc)         cairo_move_to(cr,xc,yc)         cairo_line_to(cr,xs,ys)              cairo_set_line_width(cr,1)         cairo_stroke(cr)     end end   function conky_ring_stats()     local function setup_rings(cr,pt)         local str=''         local value=0                  str=string.format('${%s %s}',pt['name'],pt['arg'])         str=conky_parse(str)                  value=tonumber(str)         if value == nil value = 0 end         pct=value/pt['max']                  draw_ring(cr,pct,pt)     end       if conky_window==nil return end     local cs=cairo_xlib_surface_create(conky_window.display,conky_window.drawable,conky_window.visual, conky_window.width,conky_window.height)          local cr=cairo_create(cs)              local updates=conky_parse('${updates}')     update_num=tonumber(updates)          if update_num>5         in pairs(settings_table)             setup_rings(cr,settings_table[i])         end     end         -- check conky has been running @ least 5s       if conky_window==nil return end     local cs=cairo_xlib_surface_create(conky_window.display,conky_window.drawable,conky_window.visual, conky_window.width,conky_window.height)          local cr=cairo_create(cs)              local updates=conky_parse('${updates}')     update_num=tonumber(updates)          if update_num>5         in pairs(settings_table)             setup_rings(cr,settings_table[i])          end     end     draw_clock_hands(cr,clock_x,clock_y) end
in case helps here's i've done far. i'd love ring in centre of 'battery' section change state, depending on whether i'm charging or not.
http://imageshack.us/photo/my-images/201/magneta.png/

bunch!

i suggest putting in line just
code:
${battery_short}
to test actual output $battery_short is.
may not changing.

man conky....
battery_short (num)
battery status , remaining percentage capacity of acpi or apm battery. acpi battery number can given argument (default bat0). mode display short status, means c displayed instead of charging, d discharging, f full, n not present, e empty , u unknown.
p.s. wealth of knowledge here...
post .conkyrc files w/ screenshots


Forum The Ubuntu Forum Community Ubuntu Official Flavours Support General Help if_match issue with conky


Ubuntu

Comments

Popular posts from this blog

Some mp4 files not displaying correctly (CS6)

Thread: Samba is not authenticating with LDAP