WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: conky  (Read 7422 times)

ali

  • Guest
conky
« on: May 17, 2011, 03:21:26 PM »
can anyone please make a conky 1.8.1 extension?
the conkies in the repos are stripped down,
i want conky that supports xft, and lua with cairo bindings

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14851
Re: conky
« Reply #1 on: May 18, 2011, 12:07:50 AM »
..and I guess you'd like an extension for tolua also  ;)

ali

  • Guest
Re: conky
« Reply #2 on: May 18, 2011, 01:44:46 AM »
i'm not quite sure what tolua is

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14851
Re: conky
« Reply #3 on: May 18, 2011, 02:43:46 AM »
..something to do with lua bindings for cairo.

We'll also need a shared lua lib, which doesn't appear to be in any of the extensions.

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14851
Re: conky
« Reply #4 on: May 18, 2011, 08:00:31 AM »
I've got conky to compile with lua bindings - just waiting to see what the lua extension maintainer would like to do about the shared lib.

ali

  • Guest
Re: conky
« Reply #5 on: May 18, 2011, 05:28:55 PM »
i tried compiling it but was missing the libraries
i'd be great if it worked

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14851
Re: conky
« Reply #6 on: May 18, 2011, 11:30:07 PM »
It seems to be working now - I'll post it after some more testing.

ali

  • Guest
Re: conky
« Reply #7 on: May 19, 2011, 12:46:34 AM »
try this

the conky config:
Code: [Select]
background no
override_utf8_locale no

use_xft yes
xftfont cure:size=8
text_buffer_size 2048
update_interval 1.0
total_run_times 0

own_window yes
own_window_transparent yes
own_window_type override
own_window_colour 191919
own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager
double_buffer yes

minimum_size 530 150
maximum_width 530

draw_shades no
draw_outline no
draw_borders no
draw_graph_borders yes

default_color 888
default_shade_color fed053
default_outline_color 7f8f9f

alignment tr
gap_x 30
gap_y 40

no_buffers yes
uppercase no
cpu_avg_samples 2
override_utf8_locale no

color1 fff

border_inner_margin 4
border_outer_margin 1

own_window_argb_visual no
own_window_argb_value 200

lua_load ~/.conky/rings.lua
lua_draw_hook_pre main

TEXT
${voffset 20}${goto 130}$hr
${voffset 16}${font Ambitsek:size=18}${goto 24}${color1}${time %H.%M}${color}$font
${goto 45}${time %a %d %b}
${voffset 23}${goto 130}$hr
${voffset -85}${goto 175}CPU $freq_g GHz
${voffset 6}${goto 153}${top cpu 1} ${color1}${top name 1}${color}
${goto 153}${top cpu 2} ${color1}${top name 2}${color}
${goto 153}${top cpu 3} ${color1}${top name 3}${color}
${voffset 4}${goto 175}${loadavg}
${voffset -63}${goto 305}MEM ${memfree}/$memmax
${voffset 3}${goto 280}${top_mem mem 1} ${color1}${top_mem name 1}${color}
${goto 280}${top_mem mem 2} ${color1}${top_mem name 2}${color}
${goto 280}${top_mem mem 3} ${color1}${top_mem name 3}${color}
${voffset 3}${goto 305}$cached - $buffers
${voffset -60}${goto 430}ROOT
${goto 415}${color1}${fs_size /}${color}
${goto 410}${color1}${fs_used /}${color}
${goto 410}${color1}${fs_used_perc /} %${color}
${voffset -30}${goto 475}${color1}${fs_used_perc /media/Sunny} %${color}
${goto 465}${color1}${fs_used /media/Sunny}${color}
${goto 465}${color1}${fs_size /media/Sunny}${color}
${goto 455}DATA

the rings.lua
Code: [Select]
--[[
Ring Meters by londonali1010 (2009)
 
This script draws percentage meters as rings. It is fully customisable; all options are described in the script.
 
To call this script in Conky, use the following (assuming that you save this script to ~/scripts/rings.lua):
    lua_load ~/scripts/rings-v1.2.1.lua
    lua_draw_hook_pre ring_stats
 
]]
 
--conky_background_color = 0x151515
--conky_background_alpha = 0.1

corner_r=30
main_bg_colour=0x181818
main_bg_alpha=0.9
 
ring_background_color = 0xe0e0e0
ring_background_alpha = 0.1
ring_foreground_color = 0xcecece
ring_foreground_alpha = 1

settings_table = {
    {
        name='time',
        arg='%S',
        max=60,
        bg_colour=ring_background_color,
        bg_alpha=ring_background_alpha,
        fg_colour=ring_foreground_color,
        fg_alpha=ring_foreground_alpha,
        x=70, y=75,
        radius=55,
        thickness=4,
        start_angle=-58,
        end_angle=58
    },
    {
        name='time',
        arg='%I.%M',
        max=12,
        bg_colour=ring_background_color,
        bg_alpha=ring_background_alpha,
        fg_colour=ring_foreground_color,
        fg_alpha=ring_foreground_alpha,
        x=70, y=75,
        radius=55,
        thickness=12,
        start_angle=-178,
        end_angle=-62
    },
    {
        name='time',
        arg='%M.%S',
        max=60,
        bg_colour=ring_background_color,
        bg_alpha=ring_background_alpha,
        fg_colour=ring_foreground_color,
        fg_alpha=ring_foreground_alpha,
        x=70, y=75,
        radius=55,
        thickness=8,
        start_angle=62,
        end_angle=178
    },
    {
        name='cpu',
        arg='cpu4',
        max=100,
        bg_colour=ring_background_color,
        bg_alpha=ring_background_alpha,
        fg_colour=ring_foreground_color,
        fg_alpha=ring_foreground_alpha,
        x=170, y=75,
        radius=23,
        thickness=3,
        start_angle=-180,
        end_angle=0
    },
    {
        name='cpu',
        arg='cpu3',
        max=100,
        bg_colour=ring_background_color,
        bg_alpha=ring_background_alpha,
        fg_colour=ring_foreground_color,
        fg_alpha=ring_foreground_alpha,
        x=170, y=75,
        radius=26,
        thickness=3,
        start_angle=-180,
        end_angle=0
    },
    {
        name='cpu',
        arg='cpu2',
        max=100,
        bg_colour=ring_background_color,
        bg_alpha=ring_background_alpha,
        fg_colour=ring_foreground_color,
        fg_alpha=ring_foreground_alpha,
        x=170, y=75,
        radius=29,
        thickness=3,
        start_angle=-180,
        end_angle=0
    },
    {
        name='cpu',
        arg='cpu1',
        max=100,
        bg_colour=ring_background_color,
        bg_alpha=ring_background_alpha,
        fg_colour=ring_foreground_color,
        fg_alpha=ring_foreground_alpha,
        x=170, y=75,
        radius=32,
        thickness=3,
        start_angle=-180,
        end_angle=0
    },
    {
        name='memperc',
        arg='',
        max=100,
        bg_colour=ring_background_color,
        bg_alpha=ring_background_alpha,
        fg_colour=ring_foreground_color,
        fg_alpha=ring_foreground_alpha,
        x=300, y=75,
        radius=25,
        thickness=6,
        start_angle=-180,
        end_angle=-0
    },
    {
        name='fs_used_perc',
        arg='/media/Sunny',
        max=100,
        bg_colour=ring_background_color,
        bg_alpha=ring_background_alpha,
        fg_colour=ring_foreground_color,
        fg_alpha=ring_foreground_alpha,
        g_alpha=ring_foreground_alpha,
        x=480, y=75,
        radius=24,
        thickness=5,
        start_angle=80,
        end_angle=180
    },
    {
        name='fs_used_perc',
        arg='/',
        max=100,
        bg_colour=ring_background_color,
        bg_alpha=ring_background_alpha,
        fg_colour=ring_foreground_color,
        fg_alpha=ring_foreground_alpha,
        g_alpha=ring_foreground_alpha,
        x=427, y=75,
        radius=24,
        thickness=5,
        start_angle=-100,
        end_angle=0
    },
}
 
require 'cairo'
 
local function rgb_to_r_g_b(colour,alpha)
    return ((colour / 0x10000) % 0x100) / 255., ((colour / 0x100) % 0x100) / 255., (colour % 0x100) / 255., alpha
end
 
local 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
 
local 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 then value = 0 end
        pct=value/pt['max']
 
        draw_ring(cr,pct,pt)
    end
 
    if conky_window==nil then 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>1 then
        for i in pairs(settings_table) do
            setup_rings(cr,settings_table[i])
        end
    end
    cairo_destroy(cr)
end

--[[ This is a script made for draw a transaprent background for conky ]]

local function conky_draw_bg()
    if conky_window==nil then return end
    local w=conky_window.width
    local h=conky_window.height
    local cs=cairo_xlib_surface_create(conky_window.display, conky_window.drawable, conky_window.visual, w, h)
    cr=cairo_create(cs)
 
    cairo_move_to(cr,corner_r,0)
    cairo_line_to(cr,w-corner_r,0)
    cairo_curve_to(cr,w,0,w,0,w,corner_r)
    cairo_line_to(cr,w,h-corner_r)
    cairo_curve_to(cr,w,h,w,h,w-corner_r,h)
    cairo_line_to(cr,corner_r,h)
    cairo_curve_to(cr,0,h,0,h,0,h-corner_r)
    cairo_line_to(cr,0,corner_r)
    cairo_curve_to(cr,0,0,0,0,corner_r,0)
    cairo_close_path(cr)
 
    cairo_set_source_rgba(cr,rgb_to_r_g_b(main_bg_colour,main_bg_alpha))
    cairo_fill(cr)
    cairo_destroy(cr)
end

function conky_main()
    conky_draw_bg()
    conky_ring_stats()
end

it should look something like this


Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14851
Re: conky
« Reply #8 on: May 19, 2011, 02:43:21 AM »
posted

Note:

1. I had to remove references in your configs to /media/sunny and 4 cpus  :P
2. Your config will only work with Xorg-7.5 and not Xvesa

ali

  • Guest
Re: conky
« Reply #9 on: May 19, 2011, 06:46:51 AM »
great job :)

http://i.imgur.com/tisoL.png

thank you

Offline robc

  • Sr. Member
  • ****
  • Posts: 447
Re: conky
« Reply #10 on: June 17, 2011, 12:10:06 AM »
Thanks for the script. I added it to my conky, plus I submitted conkyforecast to the repo.
« Last Edit: June 17, 2011, 12:12:54 AM by robc »
"Never give up! Never surrender!" - Commander Peter Quincy Taggart

"Make it so." - Captain Picard