Page 1 of 34 12311 ... LastLast
Results 1 to 10 of 334

Thread: Conky Lua & Cairo Troubleshooting

  1. #1
    Join Date
    Feb 2009
    Location
    UK
    Beans
    129
    Distro
    Ubuntu

    Conky Lua & Cairo Troubleshooting

    Hi guys...It seems as though there are several of you out there having trouble getting started with Conky's Cairo bindings for Lua. In case you don't know what I'm on about, Cairo bindings for Lua mean that you can draw nifty things directly to the Conky window, like this:
    2009-09-27--1254084788_1024x600_scrot.png
    The first thing you'll need to do to get this up and running is to get a copy of Conky 1.7.2, either from source, or from a PPA. If you compile from source, ensure that you enable Cairo and Lua (and you may as well enable imlib2 while you're there). If you download the .deb, make sure you choose the "all" version.

    I have made some scripts already that you can try out; you can download them from Conky Hardcore. I've also written a blog post over on the Conky Blog to get you started writing your own.

    If you have any more trouble, please post here, with your script, and the output of
    Code:
    conky -v
    - Samsung R519 Silver - Dual-Boot Windows 7/Ubuntu 9.10 -
    - The Official Conky Blog - Follow conkynews on Twitter -
    - My Launchpad PPA -
    - My blog: My Little Desktop -

  2. #2
    Join Date
    May 2008
    Beans
    Hidden!

    Re: Conky Lua & Cairo Troubleshooting

    Quote Originally Posted by londonali1010 View Post
    Hi guys...It seems as though there are several of you out there having trouble getting started with Conky's Cairo bindings for Lua. In case you don't know what I'm on about, Cairo bindings for Lua mean that you can draw nifty things directly to the Conky window, like this:
    2009-09-27--1254084788_1024x600_scrot.png
    The first thing you'll need to do to get this up and running is to get a copy of Conky 1.7.2, either from source, or from a PPA. If you compile from source, ensure that you enable Cairo and Lua (and you may as well enable imlib2 while you're there). If you download the .deb, make sure you choose the "all" version.

    I have made some scripts already that you can try out; you can download them from Conky Hardcore. I've also written a blog post over on the Conky Blog to get you started writing your own.

    If you have any more trouble, please post here, with your script, and the output of
    Code:
    conky -v
    I'm going to end up upgrading from Hardy to Jaunty or Karmic just to get Conky 1.7.2! It looks like the tolua++ it what's giving me the problem. Conky wont compile without tolua++ and I can't get tolua++ installed.

    The PPA linked above tells me there's a dependency that cannot be met. I imagine that's because there's no .deb for Hardy.

    After seeing your rings script, my CPU, MEM and DRIVE bars are looking uglier by the day!

  3. #3
    Join Date
    Apr 2006
    Location
    Wales
    Beans
    Hidden!
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: Conky Lua & Cairo Troubleshooting

    Hi Ali, a couple of things have crossed my mind about the display of the rings, is there an easy way to get the rings to work anti-clockwise and is it possible to make them ovals?

  4. #4
    Join Date
    Jan 2007
    Beans
    Hidden!

    Re: Conky Lua & Cairo Troubleshooting

    OK. So I'm doing "parachute drop" here.

    Heres 3 helepers LUA script to make Clock ( at the moment ).
    It needs to be unpacked and copied to "/usr/share/lua51" to work properly.

    Then theres clock script:
    Code:
    -- Conky Lua Cairo clock
    --
    do
    	require 'ubuntuforums-conky-main'
    	require 'ubuntuforums-conky-cairo'
    
    	function conky_draw_clock(radius,thick,alpha)
    		if (radius == 0) or (thick == 0) then return end
    		cr, w, h = conky_cairo_window_hook()
    		if ((radius+thick)*2 > w) then radius = (w/2)-thick; end
    		if ((radius+thick)*2 > h) then radius = (h/2)-thick; end
    		local x, y = radius+thick, radius+thick
    		cairo_set_line_width(cr, thick)
    		cairo_set_source_rgba(cr, conky_cairo_rgb2rgba(0xFFFFFF,1))
    		cairo_arc(cr, x, y, radius, 0/180*math.pi, 360/180*math.pi)
    		cairo_stroke(cr)
    		cairo_set_line_width(cr, thick/2)
    		for pins = 0, 330, 30 do
    			cairo_move_to(cr, conky_main_pointATcircle(x,y,pins,radius*0.95))
    			cairo_line_to(cr, conky_main_pointATcircle(x,y,pins,radius*0.85))
    		end
    		cairo_stroke(cr)
    		cairo_set_line_width(cr, thick)
    		cairo_set_source_rgba(cr, conky_cairo_rgb2rgba(0xFFFFFF,0.5))
    		cairo_arc(cr, x, y, thick, 0, 2*math.pi)
    		cairo_stroke(cr)
    		
    		local h_alpha, m_alpha, s_alpha = conky_main_time2angle()
    		
    		cairo_set_line_width(cr, thick*1.5)
    		cairo_set_source_rgba(cr, conky_cairo_rgb2rgba(0x606060,0.5))
    		cairo_move_to(cr, conky_main_pointATcircle(x,y,h_alpha,thick*2))
    		cairo_line_to(cr, conky_main_pointATcircle(x,y,h_alpha,radius*0.5))
    		cairo_stroke(cr)
    		
    		cairo_set_line_width(cr, thick*0.8)
    		cairo_set_source_rgba(cr, conky_cairo_rgb2rgba(0xFFFFFF,0.5))
    		cairo_move_to(cr, conky_main_pointATcircle(x,y,m_alpha,thick*2.5))
    		cairo_line_to(cr, conky_main_pointATcircle(x,y,m_alpha,radius*0.8))
    		cairo_stroke(cr)
    		
    		cairo_set_line_width(cr, thick*0.2)
    		cairo_set_source_rgba(cr, conky_cairo_rgb2rgba(0xff0000,1))
    		cairo_move_to(cr, conky_main_pointATcircle(x,y,s_alpha,thick*4))
    		cairo_line_to(cr, conky_main_pointATcircle(x,y,s_alpha,radius*0.9))
    		cairo_stroke(cr)
    	end
    end

    and theres corresponding conkyrc:
    Code:
    background no
    use_xft yes
    xftfont Bitstream Vera Sans Mono:size=13.5
    xftalpha 0.8
    update_interval 1.0
    total_run_times 0
    own_window yes
    own_window_type override
    own_window_transparent yes
    own_window_colour hotpink
    #own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager
    double_buffer yes
    minimum_size 200 200
    maximum_width 500
    draw_shades no
    draw_outline no
    draw_borders no
    draw_graph_borders yes
    stippled_borders 0
    border_inner_margin 16
    border_width 1
    default_color white
    default_shade_color black
    default_outline_color black
    alignment top_left
    gap_x 100
    gap_y 500
    no_buffers yes
    uppercase no
    cpu_avg_samples 2
    net_avg_samples 2
    override_utf8_locale yes
    use_spacer right
    max_port_monitor_connections 80
    max_specials 256
    max_user_text 256
    #text_buffer_size 16384
    imlib_cache_size 16777216
    color0 ffffff
    lua_load ~/.conky/lua/analog-clock.lua
    lua_draw_hook_post conky_draw_clock 200 10
    
    TEXT
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    ${execp ps u -p $(pidof conky) |awk '/conky/ {sub(".*-","",$NF); print $NF,"${goto 80}CPU:",$3"%","${goto 190}MEM:",$4"%"}'}
    PS: test9 is the Conky with Cairo-Clock
    Attached Images Attached Images
    Attached Files Attached Files
    Linux Debian Sid (Minted) x86_64/3.12.10, Conky 2.0_pre, Xorg 7.7/1.15.0, KDE 4.11.5, Lenovo T61, Intel X3100, HITACHI HTS722010K9SA00 100GB, WDC_WD5000BEVT 500GB
    Linux user No.: 483055 | My Conky Pitstop corner | One4All project

  5. #5
    Join Date
    Feb 2009
    Location
    UK
    Beans
    129
    Distro
    Ubuntu

    Re: Conky Lua & Cairo Troubleshooting

    Quote Originally Posted by mobilediesel View Post
    I'm going to end up upgrading from Hardy to Jaunty or Karmic just to get Conky 1.7.2! It looks like the tolua++ it what's giving me the problem. Conky wont compile without tolua++ and I can't get tolua++ installed.

    The PPA linked above tells me there's a dependency that cannot be met. I imagine that's because there's no .deb for Hardy.

    After seeing your rings script, my CPU, MEM and DRIVE bars are looking uglier by the day!
    How come you haven't upgraded already?! Just kidding, that's your decision!

    You can probably write a script in Python to use Cairo, rather than Lua/Cairo, and then use ${exec} to run it, but it would be harder...

    Quote Originally Posted by BornTwisted View Post
    Hi Ali, a couple of things have crossed my mind about the display of the rings, is there an easy way to get the rings to work anti-clockwise and is it possible to make them ovals?
    Probably!
    There's a cairo_arc_negative() function, which is the same as the cairo_arc function, just counterclockwise. I'm not sure about drawing an oval/ellipse...
    - Samsung R519 Silver - Dual-Boot Windows 7/Ubuntu 9.10 -
    - The Official Conky Blog - Follow conkynews on Twitter -
    - My Launchpad PPA -
    - My blog: My Little Desktop -

  6. #6
    Join Date
    Jan 2007
    Beans
    Hidden!

    Re: Conky Lua & Cairo Troubleshooting

    "cairo_curve_to" draws Bezier - it might be usable, but we need some mathematical function to compute needed Bezier subpoints to draw oval/elipse with.
    Linux Debian Sid (Minted) x86_64/3.12.10, Conky 2.0_pre, Xorg 7.7/1.15.0, KDE 4.11.5, Lenovo T61, Intel X3100, HITACHI HTS722010K9SA00 100GB, WDC_WD5000BEVT 500GB
    Linux user No.: 483055 | My Conky Pitstop corner | One4All project

  7. #7
    Join Date
    Feb 2009
    Location
    UK
    Beans
    129
    Distro
    Ubuntu

    Re: Conky Lua & Cairo Troubleshooting

    Okay, then, use this, from the Cairo documentation:

    The arc is circular in user space. To achieve an elliptical arc, you can scale the current transformation matrix by different amounts in the X and Y directions. For example, to draw an ellipse in the box given by x, y, width, height:

    Code:
    cairo_save (cr);
    cairo_translate (cr, x + width / 2., y + height / 2.);
    cairo_scale (cr, width / 2., height / 2.);
    cairo_arc (cr, 0., 0., 1., 0., 2 * M_PI);
    cairo_restore (cr);
    - Samsung R519 Silver - Dual-Boot Windows 7/Ubuntu 9.10 -
    - The Official Conky Blog - Follow conkynews on Twitter -
    - My Launchpad PPA -
    - My blog: My Little Desktop -

  8. #8
    Join Date
    Apr 2006
    Location
    Wales
    Beans
    Hidden!
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: Conky Lua & Cairo Troubleshooting

    Quote Originally Posted by londonali1010 View Post
    There's a cairo_arc_negative() function, which is the same as the cairo_arc function, just counterclockwise.
    Thanks Ali, not sure if i did it correctly but it's working And no errors showing in the terminal.

    Changed cairo_arc to cairo_arc_negative in the -- Draw background ring and -- Draw indicator ring sections (working from your rings.lua script).

    EDIT:
    D'oh, just noticed that the background alpha doesn't show if i only edit those two parts.
    Last edited by BornTwisted; October 2nd, 2009 at 11:22 PM.

  9. #9
    Join Date
    May 2008
    Beans
    Hidden!

    Re: Conky Lua & Cairo Troubleshooting

    Quote Originally Posted by londonali1010 View Post
    How come you haven't upgraded already?! Just kidding, that's your decision!
    Only because it's the "Long Term Support" version. I'm really re-thinking the need for that since there's newer versions of most software in the newer versions of Ubuntu.
    You can probably write a script in Python to use Cairo, rather than Lua/Cairo, and then use ${exec} to run it, but it would be harder...
    I have been looking at Python tutorials already. I even found one aimed at cairo with Python. http://www.tortall.net/mu/wiki/CairoTutorial

    I like to think I'm good with Bash scripting but it's not great for anything beyond simple text manipulation.

  10. #10
    Join Date
    Mar 2009
    Beans
    2

    Re: Conky Lua & Cairo Troubleshooting

    ok i hav started playing around with lua scripts....one question from my side....how do i place the graphical object within the conky window.......in other words if i write a lua script for clock or rings wat parameter determines the position of the clock or rings within the conky window?

Page 1 of 34 12311 ... LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •