SEARCH

Enter your search query in the box above ^, or use the forum search tool.

You are not logged in.

#7451 2014-05-06 22:59:41

mrpeachy
20% cooler
From: The Everfree Forest
Registered: 2009-11-08
Posts: 3,460

Re: Conky v1.9 Thread

re amixer, it doesnt work for me
it tells me that i have a mono setup at 88%

Simple mixer control 'Master',0
  Capabilities: pvolume pvolume-joined pswitch pswitch-joined
  Playback channels: Mono
  Limits: Playback 0 - 42
  Mono: Playback 37 [88%] [-7.50dB] [on]

my sound applet tells me it is 68% and this corresponds to what i get with the command

alsamixer

i wonder where they are getting those different numbers!

edit - although it doesnt always match up, changed volume in applet... applet says 38 alsamixer says 31
amixer says 60  hmm

Last edited by mrpeachy (2014-05-06 23:01:53)

Offline

Help fund CrunchBang, donate to the project!

#7452 2014-05-07 00:47:01

dk75
#! Junkie
Registered: 2012-06-14
Posts: 250

Re: Conky v1.9 Thread

It's PulseAudio thing.
There's master volume, "to rule them all", and there're volumes for every Pulse streams, and there're volumes for every ALSA device, and there's ALSA master mixer (obsolete with PulseAudio).

Please, pick whatever you like.


Debian Sid (Minted) x86_64/3.12-10, Conky 2.0_pre, Xorg 7.7/1.15.0, KDE 4.11.5, Intel X3100
Lenovo T61, HITACHI HTS722010K9SA00 100GB, WDC_WD5000BEVT 500GB
Linux user No.: 483055 | Conky Pitstop

Offline

#7453 2014-05-07 08:17:59

Potatohead007
New Member
Registered: 2014-05-07
Posts: 2

Re: Conky v1.9 Thread

Hello, my first post smile
My conky has a problem. When i run my script(nothing wrong with it, i ran it in Ubuntu 12.04 no problem - am now on Ubuntu 14.04) it duplicates itself, i.e when it refreshes, the old data does not dissappear, thus making me end up with a black blur, effectively. I attached the URL of a picture to show. Any help? I am using conky 1.9.http://ctrlv.in/328494

Last edited by Potatohead007 (2014-05-07 08:19:05)

Offline

#7454 2014-05-08 00:16:14

dk75
#! Junkie
Registered: 2012-06-14
Posts: 250

Re: Conky v1.9 Thread

It's new way as compositor in GNOME works.
If you would post your config, it would be more apparent than this scaled picture on which nothing is visible.


Debian Sid (Minted) x86_64/3.12-10, Conky 2.0_pre, Xorg 7.7/1.15.0, KDE 4.11.5, Intel X3100
Lenovo T61, HITACHI HTS722010K9SA00 100GB, WDC_WD5000BEVT 500GB
Linux user No.: 483055 | Conky Pitstop

Offline

#7455 2014-05-08 01:52:26

Marenbraga
Member
Registered: 2013-11-14
Posts: 40

Re: Conky v1.9 Thread

chepioq wrote:

Thank Marenbraga for your bar-text-bar.

I update my conky with that and it's look better: http://pix.toile-libre.org/upload/img/1398576228.jpg


background no
font 6x10
use_xft yes
xftfont MgOpen Modata L:size=7:bold
update_interval 1
total_run_times 0
own_window yes
own_window_type normal
own_window_transparent yes
own_window_argb_visual yes
own_window_hints undecorate,skip_taskbar,skip_pager,below
double_buffer yes
draw_shades no
draw_outline no
draw_borders no
draw_graph_borders yes
#stippled_borders 8
#border_inner_margin 4
#border_width 1
default_color white
default_shade_color black
default_outline_color black
alignment top_right
gap_x 12
gap_y 250
no_buffers yes
uppercase no
cpu_avg_samples 2
net_avg_samples 2
override_utf8_locale yes
use_spacer right
text_buffer_size 1024

color7 00FF00
color8 FF8000
color9 FF0000

TEXT
${font Waltograph UI:size=12:bold} ${alignc} ${color cf1c00}${execi 1800 lsb_release -irs} ${execi 1800 lsb_release -d | awk '{print $5,$6}' | tr -d "[()]"}

${font} ${alignc} ${color #cd5555}Kernel : ${color #11B3F8}${execi 1800 uname -r}
${alignc}${color #cd5555}Démarrage : ${color #11B3F8}${execi 1800 systemd-analyze time | awk '{print $13}'}
#${alignc}${color #cd5555}Système de fichiers ouvert depuis: ${color #11B3F8}$uptime
${color cf1c00}${alignc}${membar 0,170} ${color #11B3F8}CPU ${color cf1c00}${membar 0,170}
${alignc}${color #cd5555}Processeur : ${color #11B3F8}${execi 1800 grep -i -m 1 'Model name' /proc/cpuinfo |sed  's/^.*: //'| sed -e 's/([^()]*)//g' }
${alignc}${color #cd5555}Pilote : ${color #11B3F8}${execi 1800 cpupower frequency-info |grep pilote | awk '{print $3}'}
${color #cd5555}Fréquence CPU 1 : ${color #11B3F8}${freq 1} MHz ${goto 200}${color #cd5555}Fréquence CPU 2 : ${color #11B3F8}${freq 2} MHz
${color #cd5555}Fréquence CPU 3 : ${color #11B3F8}${freq 3} MHz ${goto 200}${color #cd5555}Fréquence CPU 4 : ${color #11B3F8}${freq 4} MHz
${color #0000ff}${cpugraph cpu1 20,181 00ff00 ff0004 -t} ${color #0000ff}${cpugraph cpu2 20,181 00ff00 ff0004 -t}
${color #0000ff}${cpugraph cpu3 20,181 00ff00 ff0004 -t} ${color #0000ff}${cpugraph cpu4 20,181 00ff00 ff0004 -t}
${color #cd5555}Utilisation Core 1 :          ${color #11B3F8}${cpu cpu1}%${goto 200}${color #cd5555}Utilisation Core 2 :          ${color #11B3F8}${cpu cpu2}%
${color #cd5555}Utilisation Core 3 :          ${color #11B3F8}${cpu cpu3}%${goto 200}${color #cd5555}Utilisation Core 4 :          ${color #11B3F8}${cpu cpu4}%
${color #cd5555}Température Core 1 :    ${execpi 6 sensors | awk '/Core 0/ {gsub(/\+/,"",$3); gsub(/\..+/,"",$3); print $3}' | xargs /home/dominique/.conkyrc/colorizeCPU.sh}°C${goto 200}${color #cd5555}Température Core 2 :    ${color #11B3F8}${execpi 6 sensors | awk '/Core 1/ {gsub(/\+/,"",$3); gsub(/\..+/,"",$3); print $3}' | xargs /home/dominique/.conkyrc/colorizeCPU.sh}°C
${color cf1c00}${alignc}${membar 0,170} ${color #11B3F8}GPU ${color cf1c00}${membar 0,170}
${alignc}${color #cd5555}Carte Graphique :  ${color #11B3F8}${execi 1800 nvidia-settings -q gpus |grep '0] (' | cut -d '(' -f 2,2 | sed -e 's/.\{1\}$//'}
${alignc}${color #cd5555}Pilote NVidia : ${color #11B3F8}${execi 1800 nvidia-settings -q NvidiaDriverVersion | grep gpu |  awk '{print $4}'}
${alignc}${color #cd5555}Température GPU :     ${color #11B3F8}${execpi 6 nvidia-settings -q all | grep GPUCoreTemp | grep gpu:0 | awk '{print $4}' | cut -c 1-2 | xargs /home/dominique/.conkyrc/colorizeGpu.sh}°C 
${color cf1c00}${alignc}${membar 0,170} ${color #11B3F8}DD ${color cf1c00}${membar 0,170}
${alignc}${color #cd5555} Disque dur : ${color #11B3F8} Samsung SSD 840 PRO 256 Go
${alignc}${color #cd5555}Accès disque
${color #cd5555}${goto 70}Lecture : ${color #11B3F8}${diskio_read} ${color #cd5555}${goto 250}Ecriture : ${color #11B3F8}${diskio_write} 
${diskiograph_read 20,181 00ff00 ff0000 -t} ${diskiograph_write 20,181 00ff00 ff0000 -t}
${color cf1c00}${alignc}${membar 0,170} ${color #11B3F8}RAM ${color cf1c00}${membar 0,170}
${color #cd5555}Utilisation RAM ${color #176e88}${alignc}             Totale              Utilisée          Pourcentage
${alignc} ${color #11B3F8}${goto 120}$memmax${goto 195}$mem${goto 290}$memperc%
${color #0000ff}${memgraph 20,364 00ff00 ff0004 -t}
${color #cd5555}Utilisation Swap :   ${color #11B3F8} $swap/$swapmax - $swapperc% ${color #00f5ff} ${swapbar 8,165}
${color cf1c00}${alignc}${membar 0,160} ${color #11B3F8}RESEAU ${color cf1c00}${membar 0,160}
${color #cd5555}Internet :
${color #176e88}Reception:${color #ff4500} ${downspeedf p5p1} k/s${goto 200}${color #11B3F8}Envoi: ${color #ff4500}${upspeedf p5p1} k/s
${color #176e88}Total :       ${color #ff4500} ${totaldown p5p1}${goto 200}${color #11B3F8}Total:${color #ff4500} ${totalup p5p1}
${color #0000ff}${downspeedgraph p5p1 20,181 00ff00 ff0004 -t} ${color #22ccff}${upspeedgraph p5p1 20,181 00ff00 ff0004 -t}
${color cf1c00}${alignc}${membar 0,130} ${color #11B3F8}SYSTEME DE FICHIERS ${color cf1c00}${membar 0,120}
${color #cd5555}Système ${color #11B3F8} ${fs_used /} / ${fs_size /} : ${goto 160}${color #00f5ff}${fs_bar 6,208 /}
${color #cd5555}Home      ${color #11B3F8} ${fs_used /home} / ${fs_size /home} : ${goto 160}${color #00f5ff}${fs_bar 6,208 /home}
${color cf1c00}${alignc}${membar 0,170} ${color #11B3F8}TOP ${color cf1c00}${membar 0,170}
${color #cd5555}${alignc}Processus : ${color #11B3F8}$processes       ${color #11B3F8}En cours: ${color #ff4500}$running_processes
${color #176e88}En cours :       ${alignc}       PID      ${goto 180}CPU%      MEM%
${color #ff4500} ${top name 1}  ${alignc}  ${top pid 1}      ${goto 180}${top cpu 1}      ${top mem 1}
${color #11B3F8} ${top name 2}  ${alignc}  ${top pid 2}      ${goto 180}${top cpu 2}      ${top mem 2}
${color #11B3F8} ${top name 3}  ${alignc}  ${top pid 3}      ${goto 180}${top cpu 3}      ${top mem 3}
${color #176e88}En mémoire :
${color #ff4500} ${top_mem name 1} ${alignc}   ${top_mem pid 1}      ${goto 180}${top_mem cpu 1}      ${top_mem mem 1}
${color #11B3F8} ${top_mem name 2} ${alignc}   ${top_mem pid 2}      ${goto 180}${top_mem cpu 2}      ${top_mem mem 2}
${color #11B3F8} ${top_mem name 3} ${alignc}   ${top_mem pid 3}      ${goto 180}${top_mem cpu 3}      ${top_mem mem 3}

Wow ... barely entered the community and I am already contributing!
COOL!!!!!

Offline

#7456 2014-05-08 12:20:26

Potatohead007
New Member
Registered: 2014-05-07
Posts: 2

Re: Conky v1.9 Thread

dk75 wrote:

It's new way as compositor in GNOME works.
If you would post your config, it would be more apparent than this scaled picture on which nothing is visible.

Sorry tongue here it is:

#==============================================================================
#                                 conkyrc_grey
#
#  author  : SLK
#  version : v2011011601
#  license : Distributed under the terms of GNU GPL version 2 or later
#
#==============================================================================

background yes
update_interval 1

cpu_avg_samples 2
net_avg_samples 2
temperature_unit celsius

double_buffer yes
no_buffers yes
text_buffer_size 2048

gap_x 10
gap_y 30
minimum_size 190 450
maximum_width 190
own_window yes
own_window_type override
own_window_transparent yes
own_window_hints undecorate,sticky,skip_taskbar,skip_pager,below
border_inner_margin 0
border_outer_margin 0
alignment tr

draw_shades no
draw_outline no
draw_borders no
draw_graph_borders no

override_utf8_locale yes
use_xft yes
xftfont caviar dreams:size=8
xftalpha 0.5
uppercase no

default_color 222222
color1 333333
color2 444444
color3 555555
color4 666666

lua_load ~/.conky/conky-grey/conky_grey.lua
lua_draw_hook_post main

TEXT
${voffset 35}
${goto 95}${color4}${font ubuntu:size=22}${time %e}${color1}${offset -50}${font ubuntu:size=10}${time %A}
${goto 85}${color2}${voffset -2}${font ubuntu:size=9}${time %b}${voffset -2} ${color3}${font ubuntu:size=12}${time %Y}${font}

${voffset 80}
${goto 90}${font Ubuntu:size=7,weight:bold}${color}CPU
${goto 90}${font Ubuntu:size=7,weight:normal}${color1}${top name 1}${alignr}${top cpu 1}%
${goto 90}${font Ubuntu:size=7,weight:normal}${color2}${top name 2}${alignr}${top cpu 2}%
${goto 90}${font Ubuntu:size=7,weight:normal}${color3}${top name 3}${alignr}${top cpu 3}%
${goto 90}${cpugraph 10,100 666666 666666}
${goto 90}${voffset -10}${font Ubuntu:size=7,weight:normal}${color}${threads} process 

${voffset 20}
${goto 90}${font Ubuntu:size=7,weight:bold}${color}MEM
${goto 90}${font Ubuntu:size=7,weight:normal}${color1}${top_mem name 1}${alignr}${top_mem mem 1}%
${goto 90}${font Ubuntu:size=7,weight:normal}${color2}${top_mem name 2}${alignr}${top_mem mem 2}%
${goto 90}${font Ubuntu:size=7,weight:normal}${color3}${top_mem name 3}${alignr}${top_mem mem 3}%

${voffset 15}
${goto 90}${font Ubuntu:size=7,weight:bold}${color}DISKS

${goto 90}${diskiograph 30,100 666666 666666}${voffset -30}
${goto 90}${font Ubuntu:size=7,weight:normal}${color}used: ${fs_used /home} /home
${goto 90}${font Ubuntu:size=7,weight:normal}${color}used: ${fs_used /} /

Lua file:

--==============================================================================
--                                 conky_grey.lua
--
--  author  : SLK
--  version : v2011062101
--  license : Distributed under the terms of GNU GPL version 2 or later
--
--==============================================================================

require 'cairo'

--------------------------------------------------------------------------------
--                                                                    clock DATA
-- HOURS
clock_h = {
    {
    name='time',                   arg='%H',                    max_value=12,
    x=110,                         y=80,
    graph_radius=53,
    graph_thickness=3,
    graph_unit_angle=30,           graph_unit_thickness=30,
    graph_bg_colour=0x111111,      graph_bg_alpha=0.0,
    graph_fg_colour=0x111111,      graph_fg_alpha=0.3,
    txt_radius=34,
    txt_weight=1,                  txt_size=10.0,
    txt_fg_colour=0x111111,        txt_fg_alpha=0.6,
    graduation_radius=53,
    graduation_thickness=6,        graduation_mark_thickness=2,
    graduation_unit_angle=30,
    graduation_fg_colour=0x111111, graduation_fg_alpha=0.3,
    },
}
-- MINUTES
clock_m = {
    {
    name='time',                   arg='%M',                    max_value=60,
    x=110,                         y=80,
    graph_radius=57,
    graph_thickness=2,
    graph_unit_angle=6,            graph_unit_thickness=6,
    graph_bg_colour=0x111111,      graph_bg_alpha=0.1,
    graph_fg_colour=0x111111,      graph_fg_alpha=0.3,
    txt_radius=70,
    txt_weight=0,                  txt_size=9.0,
    txt_fg_colour=0x111111,        txt_fg_alpha=0.6,
    graduation_radius=57,
    graduation_thickness=0,        graduation_mark_thickness=2,
    graduation_unit_angle=30,
    graduation_fg_colour=0x111111, graduation_fg_alpha=0.3,
    },
}
-- SECONDS
clock_s = {
    {
    name='time',                   arg='%S',                    max_value=60,
    x=110,                         y=80,
    graph_radius=50,
    graph_thickness=2,
    graph_unit_angle=6,            graph_unit_thickness=2,
    graph_bg_colour=0x111111,      graph_bg_alpha=0.0,
    graph_fg_colour=0x111111,      graph_fg_alpha=0.2,
    txt_radius=40,
    txt_weight=0,                  txt_size=12.0,
    txt_fg_colour=0x111111,        txt_fg_alpha=0.3,
    graduation_radius=0,
    graduation_thickness=0,        graduation_mark_thickness=0,
    graduation_unit_angle=0,
    graduation_fg_colour=0x111111, graduation_fg_alpha=0.0,
    },
}

--------------------------------------------------------------------------------
--                                                                    gauge DATA
gauge = {
{
    name='cpu',                    arg='cpu0',                  max_value=100,
    x=85,                          y=200,
    graph_radius=24,
    graph_thickness=5,
    graph_start_angle=180,
    graph_unit_angle=2.7,          graph_unit_thickness=2.7,
    graph_bg_colour=0x111111,      graph_bg_alpha=0.1,
    graph_fg_colour=0x111111,      graph_fg_alpha=0.5,
    hand_fg_colour=0xEF5A29,       hand_fg_alpha=0.0,
    txt_radius=34,
    txt_weight=0,                  txt_size=8.0,
    txt_fg_colour=0x111111,        txt_fg_alpha=0.3,
    graduation_radius=28,
    graduation_thickness=0,        graduation_mark_thickness=1,
    graduation_unit_angle=27,
    graduation_fg_colour=0x111111, graduation_fg_alpha=0.3,
    caption='',
    caption_weight=1,              caption_size=8.0,
    caption_fg_colour=0x111111,    caption_fg_alpha=0.3,
},
{
    name='cpu',                    arg='cpu1',                  max_value=100,
    x=85,                          y=200,
    graph_radius=18,
    graph_thickness=5,
    graph_start_angle=180,
    graph_unit_angle=2.7,          graph_unit_thickness=2.7,
    graph_bg_colour=0x111111,      graph_bg_alpha=0.1,
    graph_fg_colour=0x111111,      graph_fg_alpha=0.5,
    hand_fg_colour=0xEF5A29,       hand_fg_alpha=0.0,
    txt_radius=10,
    txt_weight=0,                  txt_size=8.0,
    txt_fg_colour=0x111111,        txt_fg_alpha=0.3,
    graduation_radius=28,
    graduation_thickness=0,        graduation_mark_thickness=1,
    graduation_unit_angle=27,
    graduation_fg_colour=0x111111, graduation_fg_alpha=0.3,
    caption='',
    caption_weight=1,              caption_size=8.0,
    caption_fg_colour=0x111111,    caption_fg_alpha=0.3,
},
{
    name='memperc',                arg='',                      max_value=100,
    x=85,                          y=300,
    graph_radius=24,
    graph_thickness=5,
    graph_start_angle=180,
    graph_unit_angle=2.7,          graph_unit_thickness=2.7,
    graph_bg_colour=0x111111,      graph_bg_alpha=0.1,
    graph_fg_colour=0x111111,      graph_fg_alpha=0.5,
    hand_fg_colour=0xEF5A29,       hand_fg_alpha=0.0,
    txt_radius=10,
    txt_weight=0,                  txt_size=8.0,
    txt_fg_colour=0x111111,        txt_fg_alpha=0.3,
    graduation_radius=23,
    graduation_thickness=8,        graduation_mark_thickness=2,
    graduation_unit_angle=27,
    graduation_fg_colour=0x111111, graduation_fg_alpha=0.5,
    caption='',
    caption_weight=1,              caption_size=8.0,
    caption_fg_colour=0x111111,    caption_fg_alpha=0.3,
},
{
    name='fs_used_perc',           arg='/',                     max_value=100,
    x=85,                          y=380,
    graph_radius=24,
    graph_thickness=5,
    graph_start_angle=180,
    graph_unit_angle=2.7,          graph_unit_thickness=2.7,
    graph_bg_colour=0x111111,      graph_bg_alpha=0.1,
    graph_fg_colour=0x111111,      graph_fg_alpha=0.5,
    hand_fg_colour=0xEF5A29,       hand_fg_alpha=0.0,
    txt_radius=34,
    txt_weight=0,                  txt_size=8.0,
    txt_fg_colour=0x111111,        txt_fg_alpha=0.5,
    graduation_radius=28,
    graduation_thickness=0,        graduation_mark_thickness=1,
    graduation_unit_angle=27,
    graduation_fg_colour=0x111111, graduation_fg_alpha=0.3,
    caption='/',
    caption_weight=1,              caption_size=8.0,
    caption_fg_colour=0x111111,    caption_fg_alpha=0.5,
},
{
    name='fs_used_perc',           arg='/home/',                max_value=100,
    x=85,                          y=380,
    graph_radius=18,
    graph_thickness=5,
    graph_start_angle=180,
    graph_unit_angle=2.7,          graph_unit_thickness=2.7,
    graph_bg_colour=0x111111,      graph_bg_alpha=0.1,
    graph_fg_colour=0x111111,      graph_fg_alpha=0.5,
    hand_fg_colour=0xEF5A29,       hand_fg_alpha=0.0,
    txt_radius=10,
    txt_weight=0,                  txt_size=8.0,
    txt_fg_colour=0x111111,        txt_fg_alpha=0.5,
    graduation_radius=28,
    graduation_thickness=0,        graduation_mark_thickness=1,
    graduation_unit_angle=27,
    graduation_fg_colour=0x111111, graduation_fg_alpha=0.3,
    caption='/home',
    caption_weight=1,              caption_size=8.0,
    caption_fg_colour=0x111111,    caption_fg_alpha=0.5,
},
}

-------------------------------------------------------------------------------
--                                                                 rgb_to_r_g_b
-- converts color in hexa to decimal
--
function rgb_to_r_g_b(colour, alpha)
    return ((colour / 0x10000) % 0x100) / 255., ((colour / 0x100) % 0x100) / 255., (colour % 0x100) / 255., alpha
end

-------------------------------------------------------------------------------
--                                                            angle_to_position
-- convert degree to rad and rotate (0 degree is top/north)
--
function angle_to_position(start_angle, current_angle)
    local pos = current_angle + start_angle
    return ( ( pos * (2 * math.pi / 360) ) - (math.pi / 2) )
end

-------------------------------------------------------------------------------
--                                                              draw_clock_ring
-- displays clock
--
function draw_clock_ring(display, data, value)
    local max_value = data['max_value']
    local x, y = data['x'], data['y']
    local graph_radius = data['graph_radius']
    local graph_thickness, graph_unit_thickness = data['graph_thickness'], data['graph_unit_thickness']
    local graph_unit_angle = data['graph_unit_angle']
    local graph_bg_colour, graph_bg_alpha = data['graph_bg_colour'], data['graph_bg_alpha']
    local graph_fg_colour, graph_fg_alpha = data['graph_fg_colour'], data['graph_fg_alpha']

    -- background ring
    cairo_arc(display, x, y, graph_radius, 0, 2 * math.pi)
    cairo_set_source_rgba(display, rgb_to_r_g_b(graph_bg_colour, graph_bg_alpha))
    cairo_set_line_width(display, graph_thickness)
    cairo_stroke(display)

    -- arc of value
    local val = (value % max_value)
    local i = 1
    while i <= val do
        cairo_arc(display, x, y, graph_radius,(  ((graph_unit_angle * i) - graph_unit_thickness)*(2*math.pi/360)  )-(math.pi/2),((graph_unit_angle * i) * (2*math.pi/360))-(math.pi/2))
        cairo_set_source_rgba(display,rgb_to_r_g_b(graph_fg_colour,graph_fg_alpha))
        cairo_stroke(display)
        i = i + 1
    end
    local angle = (graph_unit_angle * i) - graph_unit_thickness

    -- graduations marks
    local graduation_radius = data['graduation_radius']
    local graduation_thickness, graduation_mark_thickness = data['graduation_thickness'], data['graduation_mark_thickness']
    local graduation_unit_angle = data['graduation_unit_angle']
    local graduation_fg_colour, graduation_fg_alpha = data['graduation_fg_colour'], data['graduation_fg_alpha']
    if graduation_radius > 0 and graduation_thickness > 0 and graduation_unit_angle > 0 then
        local nb_graduation = 360 / graduation_unit_angle
        local i = 1
        while i <= nb_graduation do
            cairo_set_line_width(display, graduation_thickness)
            cairo_arc(display, x, y, graduation_radius, (((graduation_unit_angle * i)-(graduation_mark_thickness/2))*(2*math.pi/360))-(math.pi/2),(((graduation_unit_angle * i)+(graduation_mark_thickness/2))*(2*math.pi/360))-(math.pi/2))
            cairo_set_source_rgba(display,rgb_to_r_g_b(graduation_fg_colour,graduation_fg_alpha))
            cairo_stroke(display)
            cairo_set_line_width(display, graph_thickness)
            i = i + 1
        end
    end

    -- text
    local txt_radius = data['txt_radius']
    local txt_weight, txt_size = data['txt_weight'], data['txt_size']
    local txt_fg_colour, txt_fg_alpha = data['txt_fg_colour'], data['txt_fg_alpha']
    local movex = txt_radius * (math.cos((angle * 2 * math.pi / 360)-(math.pi/2)))
    local movey = txt_radius * (math.sin((angle * 2 * math.pi / 360)-(math.pi/2)))
    cairo_select_font_face (display, "ubuntu", CAIRO_FONT_SLANT_NORMAL, txt_weight);
    cairo_set_font_size (display, txt_size);
    cairo_set_source_rgba (display, rgb_to_r_g_b(txt_fg_colour, txt_fg_alpha));
    cairo_move_to (display, x + movex - (txt_size / 2), y + movey + 3);
    cairo_show_text (display, value);
    cairo_stroke (display);
end

-------------------------------------------------------------------------------
--                                                              draw_gauge_ring
-- displays gauges
--
function draw_gauge_ring(display, data, value)
    local max_value = data['max_value']
    local x, y = data['x'], data['y']
    local graph_radius = data['graph_radius']
    local graph_thickness, graph_unit_thickness = data['graph_thickness'], data['graph_unit_thickness']
    local graph_start_angle = data['graph_start_angle']
    local graph_unit_angle = data['graph_unit_angle']
    local graph_bg_colour, graph_bg_alpha = data['graph_bg_colour'], data['graph_bg_alpha']
    local graph_fg_colour, graph_fg_alpha = data['graph_fg_colour'], data['graph_fg_alpha']
    local hand_fg_colour, hand_fg_alpha = data['hand_fg_colour'], data['hand_fg_alpha']
    local graph_end_angle = (max_value * graph_unit_angle) % 360

    -- background ring
    cairo_arc(display, x, y, graph_radius, angle_to_position(graph_start_angle, 0), angle_to_position(graph_start_angle, graph_end_angle))
    cairo_set_source_rgba(display, rgb_to_r_g_b(graph_bg_colour, graph_bg_alpha))
    cairo_set_line_width(display, graph_thickness)
    cairo_stroke(display)

    -- arc of value
    local val = value % (max_value + 1)
    local start_arc = 0
    local stop_arc = 0
    local i = 1
    while i <= val do
        start_arc = (graph_unit_angle * i) - graph_unit_thickness
        stop_arc = (graph_unit_angle * i)
        cairo_arc(display, x, y, graph_radius, angle_to_position(graph_start_angle, start_arc), angle_to_position(graph_start_angle, stop_arc))
        cairo_set_source_rgba(display, rgb_to_r_g_b(graph_fg_colour, graph_fg_alpha))
        cairo_stroke(display)
        i = i + 1
    end
    local angle = start_arc

    -- hand
    start_arc = (graph_unit_angle * val) - (graph_unit_thickness * 2)
    stop_arc = (graph_unit_angle * val)
    cairo_arc(display, x, y, graph_radius, angle_to_position(graph_start_angle, start_arc), angle_to_position(graph_start_angle, stop_arc))
    cairo_set_source_rgba(display, rgb_to_r_g_b(hand_fg_colour, hand_fg_alpha))
    cairo_stroke(display)

    -- graduations marks
    local graduation_radius = data['graduation_radius']
    local graduation_thickness, graduation_mark_thickness = data['graduation_thickness'], data['graduation_mark_thickness']
    local graduation_unit_angle = data['graduation_unit_angle']
    local graduation_fg_colour, graduation_fg_alpha = data['graduation_fg_colour'], data['graduation_fg_alpha']
    if graduation_radius > 0 and graduation_thickness > 0 and graduation_unit_angle > 0 then
        local nb_graduation = graph_end_angle / graduation_unit_angle
        local i = 0
        while i < nb_graduation do
            cairo_set_line_width(display, graduation_thickness)
            start_arc = (graduation_unit_angle * i) - (graduation_mark_thickness / 2)
            stop_arc = (graduation_unit_angle * i) + (graduation_mark_thickness / 2)
            cairo_arc(display, x, y, graduation_radius, angle_to_position(graph_start_angle, start_arc), angle_to_position(graph_start_angle, stop_arc))
            cairo_set_source_rgba(display,rgb_to_r_g_b(graduation_fg_colour,graduation_fg_alpha))
            cairo_stroke(display)
            cairo_set_line_width(display, graph_thickness)
            i = i + 1
        end
    end

    -- text
    local txt_radius = data['txt_radius']
    local txt_weight, txt_size = data['txt_weight'], data['txt_size']
    local txt_fg_colour, txt_fg_alpha = data['txt_fg_colour'], data['txt_fg_alpha']
    local movex = txt_radius * math.cos(angle_to_position(graph_start_angle, angle))
    local movey = txt_radius * math.sin(angle_to_position(graph_start_angle, angle))
    cairo_select_font_face (display, "ubuntu", CAIRO_FONT_SLANT_NORMAL, txt_weight)
    cairo_set_font_size (display, txt_size)
    cairo_set_source_rgba (display, rgb_to_r_g_b(txt_fg_colour, txt_fg_alpha))
    cairo_move_to (display, x + movex - (txt_size / 2), y + movey + 3)
    cairo_show_text (display, value)
    cairo_stroke (display)

    -- caption
    local caption = data['caption']
    local caption_weight, caption_size = data['caption_weight'], data['caption_size']
    local caption_fg_colour, caption_fg_alpha = data['caption_fg_colour'], data['caption_fg_alpha']
    local tox = graph_radius * (math.cos((graph_start_angle * 2 * math.pi / 360)-(math.pi/2)))
    local toy = graph_radius * (math.sin((graph_start_angle * 2 * math.pi / 360)-(math.pi/2)))
    cairo_select_font_face (display, "ubuntu", CAIRO_FONT_SLANT_NORMAL, caption_weight);
    cairo_set_font_size (display, caption_size)
    cairo_set_source_rgba (display, rgb_to_r_g_b(caption_fg_colour, caption_fg_alpha))
    cairo_move_to (display, x + tox + 5, y + toy + 1)
    -- bad hack but not enough time !
    if graph_start_angle < 105 then
        cairo_move_to (display, x + tox - 30, y + toy + 1)
    end
    cairo_show_text (display, caption)
    cairo_stroke (display)
end

-------------------------------------------------------------------------------
--                                                               go_clock_rings
-- loads data and displays clock
--
function go_clock_rings(display)
    local function load_clock_rings(display, data)
        local str, value = '', 0
        str = string.format('${%s %s}',data['name'], data['arg'])
        str = conky_parse(str)
        value = tonumber(str)
        draw_clock_ring(display, data, value)
    end
    
    for i in pairs(clock_h) do
        load_clock_rings(display, clock_h[i])
    end
    for i in pairs(clock_m) do
        load_clock_rings(display, clock_m[i])
    end
    for i in pairs(clock_s) do
        load_clock_rings(display, clock_s[i])
    end
end

-------------------------------------------------------------------------------
--                                                               go_gauge_rings
-- loads data and displays gauges
--
function go_gauge_rings(display)
    local function load_gauge_rings(display, data)
        local str, value = '', 0
        str = string.format('${%s %s}',data['name'], data['arg'])
        str = conky_parse(str)
        value = tonumber(str)
        draw_gauge_ring(display, data, value)
    end
    
    for i in pairs(gauge) do
        load_gauge_rings(display, gauge[i])
    end
end

-------------------------------------------------------------------------------
--                                                                         MAIN
function conky_main()
    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 display = cairo_create(cs)
    
    local updates = conky_parse('${updates}')
    update_num = tonumber(updates)
    
    if update_num > 5 then
        go_clock_rings(display)
        go_gauge_rings(display)
    end
    
    cairo_surface_destroy(cs)
    cairo_destroy(display)
end

Offline

#7457 2014-05-08 21:52:11

ansem_of_nexus
#! CrunchBanger
Registered: 2012-09-19
Posts: 234

Re: Conky v1.9 Thread

system_clock
2014_05_08_1399583194_1600x900_scrot.png
green
2014_05_08_1399583669_1600x900_scrot.png
game_display
2014_05_08_1399583784_1600x900_scrot.png

Here are the 3 conky I have completed while I was gone. I also have made a master function and scripts lua to be called as support called functions.lua
one of the main uses I built this for is to cut down on lines and quick calls for complex codes.
tables for cpu, mem, swap, and network.
conky_parse grouped and stringed for call once.
conky_controller I made to stop conkys from taxing a system that is struggling after a minute
roman_numeral function that will convert any number up to 199,999
several gauges and graph types

the functions.lua has been my main work for the last little while. it is still a work in progress and probably always will be. also this lua is not just mine, right now I have some of mrpeachy's functions in it (all marked), and as I borrow / collect more it will grow. so if you know of any functions I should add, please let me know.

a link to all of these and my other work is in my sig as always but here is the function.lua

--this lua script for use in conky
require 'cairo'

--################################
--Conky Functions
--################################
function conky_functions()
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)
cr = cairo_create(cs)
local updates=tonumber(conky_parse('${updates}'))
if updates>5 then
--################################
-- Main Body
--################################

--################################
end-- if updates>5
cairo_destroy(cr)
cairo_surface_destroy(cs)
cr=nil
end-- end main function
--################################
function conky_usb_list()
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)
cr = cairo_create(cs)
local updates=tonumber(conky_parse('${updates}'))
if updates>5 then
--################################
for i = 1,10 do if (conky_mount(i,"fsys",8)) == "/dev/sda" then start=i end end
istart=start+1
for i = istart,(istart+5) do
m=i-start
if (conky_mount(i,"mount")) ~= "" then
usb(
--top left x
10
,--top left y
(10+(50*(m-1)))
,--mount point
(conky_mount(i,"mount"))
,--drive size
(conky_mount(i,"size"))
,--drive used
(conky_mount(i,"used"))
,--drive used percent
(conky_parse("${fs_used_perc "..(conky_mount(i,"mount")).."}"))
,--drive io
(conky_parse("${diskio "..(conky_mount(i,"fsys")).."}"))
)--end conky_usb
end
end--for
--################################
end-- if updates>5
cairo_destroy(cr)
cairo_surface_destroy(cs)
cr=nil
return ""
end-- end main function
--################################
function conky_controller()
local updates=tonumber(conky_parse('${updates}'))
if updates>5 then
--################################
table_length=60
cpu_avg=tonumber(conky_parse("${cpu}"))
if cpu_avg == nil then cpu_avg=0 end
if cpu_avg_table == nil then cpu_avg_table={} end
--cpu_average_table={}
for i = 1,table_length do
            if cpu_avg_table[i+1]==nil then cpu_avg_table[i+1]=0 end
cpu_avg_table[i]=cpu_avg_table[i+1]
            if i == table_length then
            cpu_avg_table[table_length]=cpu_avg
            end
end
alert={}
alert_level=1
for i = 1,table_length do
if cpu_avg_table[i] ~= 100 then alert[i]=nil else alert[i]=1 end
if alert[i] == nil then alert_level=0 end
end
if alert_level ~= 0 then
os.execute("conkywonky")
os.execute("conky-load --minimal")
end
--################################
end-- if updates>5
return ""
end-- end main function
--################################
--################################
--Functions
--################################
--################################
--buttons
--################################
function button_make(name,tlx,tly,width,height)
if buttons[""..(name).."_button"]==nil then buttons[""..(name).."_button"]=0 end
--calculate if click was inside box
if localx>=(tlx) and localx<=(tlx)+(width) and localy>=(tly) and localy<=(tly)+(height) and buttons[""..(name).."_button"]~=1 then
buttons[""..(name).."_button"]=1
elseif localx>=(tlx) and localx<=(tlx)+(width) and localy>=(tly) and localy<=(tly)+(height) and buttons[""..(name).."_button"]==1 then
buttons[""..(name).."_button"]=0 end
end--function
function button_count(name,tlx,tly,width,height,max_value)
if buttons[""..(name).."_count"]==nil then buttons[""..(name).."_count"]=1 end
if (max_value) == nil then max_value=1 end
--calculate if click was inside box
if localx>=(tlx) and localx<=(tlx)+(width) and localy>=(tly) and localy<=(tly)+(height) and buttons[""..(name).."_count"] ~= max_value then
buttons[""..(name).."_count"]=(buttons[""..(name).."_count"])+1
elseif localx>=(tlx) and localx<=(tlx)+(width) and localy>=(tly) and localy<=(tly)+(height) and buttons[""..(name).."_count"] == max_value then
buttons[""..(name).."_count"]=1 end
end--function
function button_draw(tlx,tly,width,height,color,fill,fill_color)
cairo_set_line_width (cr,2)
cairo_rectangle (cr,tlx,tly,width,height)
	if fill == 1 then
	cairo_set_source_rgba (cr,fill_color[1],fill_color[2],fill_color[3],fill_color[4])
	cairo_fill_preserve(cr)
	end
cairo_set_source_rgba (cr,color[1],color[2],color[3],color[4])
cairo_stroke (cr)
end--function
function button_status(name)
return buttons[""..(name).."_button"]
end--function
function button_count_status(name)
return buttons[""..(name).."_count"]
end--function
function button_override(name,value)
buttons[""..(name).."_button"]=(value)
end--function
function button_count_override(name,value)
buttons[""..(name).."_count"]=(value)
end--function
function kill_button(name,tlx,tly,process,pid,reset,reset_inpute)
button_make(""..name.."1",tlx,tly,40,20)
	if (button_status(""..name.."1")) == 1 then
	buttons[""..name.."_process"]=process
	buttons[""..name.."_pid"]=pid
	button_override(""..name.."1",2)
	end
if (button_status(""..name.."1")) == 0 then
button_draw(tlx,tly,40,20,{.5,.5,.5,1},1,{.25,.25,.25,.5})
cairo_move_to(cr,(tlx+1),(tly+15))
cairo_set_source_rgba(cr,.8,.8,.8,1)
cairo_select_font_face (cr,"mono",CAIRO_FONT_SLANT_NORMAL,CAIRO_FONT_WEIGHT_NORMAL)
cairo_set_font_size (cr,15)
cairo_show_text(cr,"kill")
cairo_stroke(cr)
else
	if (button_status(""..name.."1")) == 2 then
	cairo_set_line_width(cr,2)
	cairo_rectangle(cr,tlx,tly,265,50)
	cairo_set_source_rgba(cr,.5,.5,.5,1)
	cairo_fill_preserve(cr)
	cairo_set_source_rgba(cr,.25,.25,.25,1)
	cairo_stroke(cr)
	x={1,57}
	t={"Are you sure you want to kill",""..buttons[""..name.."_process"]..""..buttons[""..name.."_pid"]..""}
		for i = 1,2 do
		cairo_move_to(cr,(tlx+x[i]),(tly+(i*15)))
		cairo_set_source_rgba(cr,0,0,0,1)
		cairo_select_font_face (cr,"mono",CAIRO_FONT_SLANT_NORMAL,CAIRO_FONT_WEIGHT_NORMAL)
		cairo_set_font_size (cr,15)
		cairo_show_text(cr,t[i])
		cairo_stroke(cr)
		end
	button_make(""..name.."2",(tlx+20),(tly+30),40,20)
	cairo_move_to(cr,(tlx+21),(tly+45))
	cairo_set_source_rgba(cr,.8,.8,.8,1)
	cairo_select_font_face (cr,"mono",CAIRO_FONT_SLANT_NORMAL,CAIRO_FONT_WEIGHT_NORMAL)
	cairo_set_font_size (cr,15)
	cairo_show_text(cr,"kill")
	cairo_stroke(cr)
	button_make(""..name.."3",(tlx+200),(tly+30),50,20)
	cairo_move_to(cr,(tlx+202),(tly+45))
	cairo_set_source_rgba(cr,.8,.8,.8,1)
	cairo_select_font_face (cr,"mono",CAIRO_FONT_SLANT_NORMAL,CAIRO_FONT_WEIGHT_NORMAL)
	cairo_set_font_size (cr,15)
	cairo_show_text(cr,"Close")
	cairo_stroke(cr)
		if (button_status(""..name.."3")) == 1 then
		button_override(""..name.."3",0)
		button_override(""..name.."2",0)
		button_override(""..name.."1",0)
		end
		if (button_status(""..name.."2")) == 1 then
		os.execute("kill "..buttons[""..name.."_pid"].."")
		button_override(""..name.."1",0)
		button_override(""..name.."2",0)
		end--if (button_status(""..name.."2")) == 1 then
	end--if (button_status(""..name.."1")) == 2 then
end--if (button_status(""..name.."1")) == 0 then
end--function
--################################
--cairo
--################################
function firsts()
cairo_set_line_width(cr,2)
cairo_set_source_rgba(cr,1,1,1,1)
end
function arc(x,y,r,sd,ed,br,lw,bg)
if br == nil then br={1,1,1,1} end ; if lw == nil then lw=2 end
cairo_set_line_width(cr,lw)
cairo_arc(cr,x,y,r,(sd*(math.pi/180)),(ed*(math.pi/180)))
	if bg ~= nil then
	cairo_set_source_rgba(cr,bg[1],bg[2],bg[3],bg[4])
	cairo_fill_preserve(cr)
	end
cairo_set_source_rgba(cr,br[1],br[2],br[3],br[4])
cairo_stroke(cr)
end
function font(name,slant,face)
if name == nil then name="verdana" end
if name == "mono" then
	if slant == nil then slant=CAIRO_FONT_SLANT_NORMAL end
	if face == nil then face=CAIRO_FONT_WEIGHT_NORMAL end
	if size == nil then size=11 end
end
if name == "verdana" then
	if slant == nil then slant=CAIRO_FONT_SLANT_NORMAL end
	if face == nil then face=CAIRO_FONT_WEIGHT_NORMAL end
	if size == nil then size=11 end
end
if name == "dejavu serif" then
	if slant == nil then slant=CAIRO_FONT_SLANT_NORMAL end
	if face == nil then face=CAIRO_FONT_WEIGHT_NORMAL end
	if size == nil then size=13 end
end
cairo_select_font_face (cr,name,slant,face) ; cairo_set_font_size (cr,size)
end
function line(x1,y1,x2,y2,c,w)
if c == nil then c={1,1,1,1} end
if w == nil then w=2 end
cairo_set_line_width(cr,w)
cairo_move_to(cr,x1,y1)
cairo_line_to(cr,x2,y2)
cairo_set_source_rgba(cr,c[1],c[2],c[3],c[4])
cairo_stroke(cr)
end
function line_cap(cap)
if cap == "round" then cairo_set_line_cap(cr,CAIRO_LINE_CAP_ROUND) end
if cap == "mitter" then cairo_set_line_cap(cr,CAIRO_LINE_CAP_MITTER) end
end
function rectangle(tlx,tly,w,h,lw,lc,fc)
if lw ~= nil then cairo_set_line_width(cr,lw) end
cairo_rectangle(cr,tlx,tly,w,h)
if fc ~= nil then cairo_set_source_rgba(cr,fc[1],fc[2],fc[3],fc[4]) ; cairo_fill_preserve(cr) end
if lc ~= nil then cairo_set_source_rgba(cr,lc[1],lc[2],lc[3],lc[4]) end
cairo_stroke(cr)
end
function rounded_rectangle(tlx,tly,w,h,r,border,fill)
cairo_set_line_width(cr,2)
x={tlx,(tlx+w),(tlx+w),tlx} ; y={tly,tly,(tly+h),(tly+h)}
for i = 1,4 do cairo_arc(cr,x[i],y[i],r,((180+(90*(i-1)))*(math.pi/180)),((270+(90*(i-1)))*(math.pi/180))) end
cairo_close_path(cr)
	if fill ~= nil then
	cairo_set_source_rgba(cr,fill[1],fill[2],fill[3],fill[4])
	cairo_fill_preserve(cr)
	end
cairo_set_source_rgba(cr,border[1],border[2],border[3],border[4])
cairo_stroke(cr)
end
function text(x,y,t,s,c)
if s ~= nil then cairo_set_font_size (cr,s) end
if c ~= nil then cairo_set_source_rgba (cr,c[1],c[2],c[3],c[4]) else cairo_set_source_rgba (cr,.8,.8,.8,1) end
cairo_move_to (cr,x,y)
cairo_show_text (cr,t)
cairo_stroke (cr)
end
--################################
--convertion
--################################
function adeg(input)
return (input*(math.pi/180))
end
function colors(c)
if c == "black" then return {0,0,0,1} end
if c == "blue" then return {0,1,0,1} end
if c == "green" then return {0,0,1,1} end
if c == "red" then return {1,0,0,1} end
if c == "white" then  return {1,1,1,1} end
if c == "font_color" then return {.8,.8,.8,1} end
end
function color_rgba(r,g,b,a)
c={r,g,b} ; o={}
for i = 1,3 do o[i]=255/100*c[i]/1000 end ; if a ~= nil then o[4]=a end
return o
end
function conky_mount_usep(partition_number)
output=tonumber(conky_parse("${fs_used_perc "..(conky_mount(partition_number,"mount")).."}"))
return output
end--function
function count_down(y,mo,d,h,mi)
time_strings()
if y == nil then y=year end
if mo == nil then mo=month_number end
if d == nil then d=day_number end
if h == nil then h=hour24 end
if mi == nil then mi=60 end
if y ~= "text" then
s=60
y2o=y-year
mo2o=mo-month_number
d2o=d-day_number
h2o=h-hour24
mi2o=mi-minute
s2o=s-second
	if y2o < 0 then
	s2o=0 ; mi2o=0 ; h2o=0 ; d2o=0 ; mo2o=0 ; y2o=0 end
	if mo2o < 0 then if y2o <= 0 then
	s2o=0 ; mi2o=0 ; h2o=0 ; d2o=0 ; mo2o=0 ; y2o=0 end end
	if d2o < 0 then if mo2o <= 0 then if y2o <= 0 then
	s2o=0 ; mi2o=0 ; h2o=0 ; d2o=0 ; mo2o=0 ; y2o=0 end end end
	if h2o < 0 then if d2o <= 0 then if mo2o <= 0 then if y2o <= 0 then
	s2o=0 ; mi2o=0 ; h2o=0 ; d2o=0 ; mo2o=0 ; y2o=0 end end end end
	if mi2o < 0 then if h2o <= 0 then if d2o <= 0 then if mo2o <= 0 then if y2o <= 0 then
	s2o=0 ; mi2o=0 ; h2o=0 ; d2o=0 ; mo2o=0 ; y2o=0 end end end end end
	if s2o < 0 then if mi2o <= 0 then if h2o <= 0 then if d2o <= 0 then if mo2o <= 0 then if y2o <= 0 then
	s2o=0 ; mi2o=0 ; h2o=0 ; d2o=0 ; mo2o=0 ; y2o=0 end end end end end end
if y2o < 0 then y2o=0 end
if mo2o < 0 then mo2o=0 end
if d2o < 0 then d2o=0 end
if h2o < 0 then h2o=0 end
if mi2o < 0 then mi2o=0 end
if s2o < 0 then s2o=0 end
output=""..h2o..":"..mi2o..":"..s2o.."  "..mo2o.."/"..d2o.."/"..y2o..""
if output == "0:0:0  0/0/0" then output="past" end
else
output="h:mi:s  mo/d/y" end
return output
end
function roman_numeral(input,override)
--roman_numeral's limit is "199,999"
--test=""..roman_numberal(month_number).."/"..roman_numberal(day_number).."/"..roman_numberal(year_full).."  "..roman_numberal(hour24)..":"..roman_numberal(minute)..":"..roman_numberal(second)..""
if input == nil then input=0 end
number=input ; count=0 ; output=""
thousand="M"
five_hundred="D"
hundred="C"
fifty="L"
ten="X"
five="V"
one="I"
--thousand
for i = 1,100 do if number >= 1000 then number=number-1000 ; count=i end end
if count ~= 0 then for i = 1,count do output=""..output..""..thousand.."" end end
count=0
--hundred
for i = 1,9 do if number >= 100 then number=number-100 ; count=i end end
if count == 9 then
output=""..output..""..hundred..""..thousand..""
else
	if count >= 5 then
	output=""..output..""..five_hundred..""
	if count > 5 then for i = 1,(count-5) do output=""..output..""..hundred.."" end end
	else
		if count == 4 then output=""..output..""..hundred..""..five_hundred..""
		else
			if count ~= 0 then for i = 1,count do output=""..output..""..hundred.."" end end
		end--if count 4
	end-- if count 5
end--if count 9
count=0
--ten
for i = 1,9 do if number >= 10 then number=number-10 ; count=i end end
if count == 9 then
output=""..output..""..ten..""..hundred..""
else
	if count >= 5 then
	output=""..output..""..fifty..""
	if count > 5 then for i = 1,(count-5) do output=""..output..""..ten.."" end end
	else
		if count == 4 then output=""..output..""..ten..""..fifty..""
		else
			if count ~= 0 then for i = 1,count do output=""..output..""..ten.."" end end
		end--if count 4
	end-- if count 5
end--if count 9
count=0
--one
for i = 1,9 do if number >= 1 then number=number-1 ; count=i end end
if count == 9 then
output=""..output..""..one..""..ten..""
else
	if count >= 5 then
	output=""..output..""..five..""
	if count > 5 then for i = 1,(count-5) do output=""..output..""..one.."" end end
	else
		if count == 4 then output=""..output..""..one..""..five..""
		else
			if count ~= 0 then for i = 1,count do output=""..output..""..one.."" end end
		end--if count 4
	end-- if count 5
end--if count 9
count=0
if input == 0 then output="nulla" end
return output
end--function
--################################
--conky
--################################
function cpu_strings(cores)
if cores == nil then cores=1 end
cpu_avg=tonumber(conky_parse("${cpu cpu0}"))
if cpu_avg == nil then cpu_avg=0 end
cpu=cpu_avg
cpu_1=tonumber(conky_parse("${cpu cpu1}"))
if cpu_1 == nil then cpu_1=0 end
	if cores >= 2 then
	cpu_2=tonumber(conky_parse("${cpu cpu2}"))
	if cpu_2 == nil then cpu_2=0 end
	end
	if cores >= 3 then
	cpu_3=tonumber(conky_parse("${cpu cpu3}"))
	if cpu_3 == nil then cpu_3=0 end
	end
	if cores >= 4 then
	cpu_4=tonumber(conky_parse("${cpu cpu4}"))
	if cpu_4 == nil then cpu_4=0 end
	end
end--function
function eth0_strings()
eth0_down=tonumber(conky_parse("${downspeed eth0}"))
eth0_down_value=tonumber(conky_parse("${downspeedf eth0}"))
eth0_up=tonumber(conky_parse("${upspeed eth0}"))
eth0_up_value=tonumber(conky_parse("${upspeedf eth0}"))
ip_eth0=conky_parse("${addr eth0}")
end
function file_system_strings(boot)
home_perc=tonumber(conky_parse("${fs_used_perc /home}"))
	if home_perc == nil then home_perc=0 end
home_size=conky_parse("${fs_size /home}")
home_used=conky_parse("${fs_used /home}")
io=conky_parse("${diskio}")
system_perc=tonumber(conky_parse("${fs_used_perc /}"))
	if system_perc == nil then system_perc=0 end
system_size=conky_parse("${fs_size /}")
system_used=conky_parse("${fs_used /}")
--other partitions
	if boot == 1 then
	boot_perc=tonumber(conky_parse("${fs_used_perc /boot}"))
		if boot_perc == nil then boot_perc=0 end
	boot_size=conky_parse("${fs_size /boot}")
	boot_used=conky_parse("${fs_used /boot}")
	end
end--function
function hwmon(type,n)
o=conky_parse("${hwmon "..type.." "..n.."}") ; return o
end
function mem_strings()
mem_max=conky_parse("${memmax}")
mem_perc=tonumber(conky_parse("${memperc}"))
	if mem_perc == nil then mem_perc=0 end
mem_used=conky_parse("${mem}")
end
function net_strings()
down=conky_parse("${downspeed}")
down_value=conky_parse("${downspeedf}")
up=conky_parse("${upspeed}")
up_value=conky_parse("${upspeedf}")
ip=conky_parse("${addr}")
end
function swap_strings()
swap_perc=tonumber(conky_parse("${swapperc}"))
	if swap_perc == nil then swap_perc=0 end
swap_used=conky_parse("${swap}")
swap_max=conky_parse("${swapmax}")
end
function time_strings()
abbr_month=conky_parse("${time %b}")
ampm=conky_parse("${time %p}")
date_mm_dd_yy=conky_parse("${time %D}")
day=conky_parse("${time %a}")
day_number=tonumber(conky_parse("${time %d}"))
minute=tonumber(conky_parse("${time %M}"))
month_number=tonumber(conky_parse("${time %m}"))
hour12=tonumber(conky_parse("${time %I}"))
hour24=tonumber(conky_parse("${time %H}"))
second=tonumber(conky_parse("${time %S}"))
time_hms12=conky_parse("${time %r}")
time_hms24=conky_parse("${time %T}")
weekday_number=tonumber(conky_parse("${time %u}"))
year=tonumber(conky_parse("${time %y}"))
year_full=tonumber(conky_parse("${time %Y}"))
end
function top_strings(table_length)
top_name={}
top_cpu={}
top_pid={}
top_mem={}
top_time={}
for i = 1,table_length do
top_name[i]=conky_parse("${top name "..i.."}")
top_cpu[i]=conky_parse("${top cpu "..i.."}")
top_pid[i]=conky_parse("${top pid "..i.."}")
top_mem[i]=conky_parse("${top mem "..i.."}")
top_time[i]=conky_parse("${top time "..i.."}")
end
end--function
function top_mem_strings(table_length)
top_mem_name={}
top_mem_cpu={}
top_mem_pid={}
top_mem_mem={}
top_mem_time={}
for i = 1,table_length do
top_mem_name[i]=conky_parse("${top_mem name "..i.."}")
top_mem_cpu[i]=conky_parse("${top_mem cpu "..i.."}")
top_mem_pid[i]=conky_parse("${top_mem pid "..i.."}")
top_mem_mem[i]=conky_parse("${top_mem mem "..i.."}")
top_mem_time[i]=conky_parse("${top_mem time "..i.."}")
end
end--function
function wlan0_strings()
wlan0_down=tonumber(conky_parse("${downspeed wlan0}"))
wlan0_down_value=tonumber(conky_parse("${downspeedf wlan0}"))
wlan0_up=tonumber(conky_parse("${upspeed wlan0}"))
wlan0_up_value=tonumber(conky_parse("${upspeedf wlan0}"))
ip_wlan0=conky_parse("${addr wlan0}")
end
--################################
--gauges
--################################
function bar_meter(x,y,input)
--[[bar_meter(
--x,y,
20,20,
--input
cpu_avg
)]]
for i = 1,10 do
cairo_set_line_width(cr,2)
cairo_rectangle(cr,(x),((y+91)-((i-1)*10)),15,7)
level=(i-1)*10
if (input) > level then
cairo_set_source_rgba(cr,0,.75,0,1)
	if i >= 7 then
	cairo_set_source_rgba(cr,1,1,0,1)
	end
	if i >= 9 then
	cairo_set_source_rgba(cr,1,.3,.3,1)
	end
cairo_fill_preserve(cr)
end
cairo_set_source_rgba(cr,.2,.2,.2,1)
cairo_stroke(cr)
end
end--function end
function bar_meterh(x,y,input)
--[[bar_meterh(
--x,y,
20,20,
--input
cpu_avg)]]
for i = 1,10 do
cairo_set_line_width(cr,2)
cairo_rectangle(cr,((x)+((i-1)*10)),(y),7,15)
level=(i-1)*10
if (input) > level then
cairo_set_source_rgba(cr,0,.7,0,1)
	if i >= 7 then
	cairo_set_source_rgba(cr,1,1,0,1)
	end
	if i >= 9 then
	cairo_set_source_rgba(cr,1,.3,.3,1)
	end
cairo_fill_preserve(cr)
end
cairo_set_source_rgba(cr,.2,.2,.2,1)
cairo_stroke(cr)
end
end--function end
function computer_chip(tlx,tly,width,height,input,scale)
cairo_set_line_width(cr,2)
cairo_set_source_rgba(cr,.75,.75,.75,1)
offset=5
for i = 1,10 do
cairo_move_to(cr,tlx,(tly+((height/11)*i)))
cairo_line_to(cr,(tlx+offset),(tly+((height/11)*i)))
cairo_stroke(cr)
cairo_move_to(cr,(tlx+width+offset),(tly+((height/11)*i)))
cairo_line_to(cr,(tlx+width+(offset*2)),(tly+((height/11)*i)))
cairo_stroke(cr)
end
cairo_rectangle(cr,(tlx+offset),tly,width,height)
cairo_set_source_rgba(cr,.1,.1,.1,1)
cairo_fill_preserve(cr)
cairo_set_source_rgba(cr,.2,.2,.2,1)
cairo_stroke(cr)
if (input) < 0 then input=0 end
level=(height-6)/scale
cairo_rectangle(cr,(tlx+(offset*2)),(tly+(height-3)-(level*input)),(width-(offset*2)),(level*input))
cairo_set_source_rgba(cr,0,.5,0,1)
cairo_fill(cr)
end
function gauge1(gx,gy,gl,input,scale,color1,color2,color3)
--[[gauge1(
--gx,gy,gl,
20,20,100,
--input,scale,
50,100,
--color1,color2,color3
{.5,.5,.5,1},{0,0,0,1},{1,1,1,1})]]
cairo_move_to(cr,gx,gy) ; cairo_line_to(cr,(gx+gl),gy)
cairo_set_line_cap(cr,CAIRO_LINE_CAP_ROUND)
cairo_set_line_width(cr,10)
cairo_set_source_rgba(cr,color1[1],color1[2],color1[3],color1[4])
cairo_stroke_preserve(cr)
cairo_set_line_width(cr,6)
cairo_set_source_rgba(cr,color2[1],color2[2],color2[3],color2[4])
cairo_stroke(cr)
cairo_move_to(cr,gx,gy) ; cairo_line_to(cr,(gx+(gl/100*input)),gy)
cairo_set_line_cap(cr,CAIRO_LINE_CAP_ROUND)
cairo_set_line_width(cr,2)
cairo_set_source_rgba(cr,color3[1],color3[2],color3[3],color3[4])
cairo_stroke(cr)
end--end of gauge 1
function needle_gauge(position_x,position_y,input,label)
--[[needle_gauge(
--position_x,position_y,
55,60,
--input,label
cpu_avg,"test")]]
d_math=(math.pi/180)
d_start=0
d_end=360*d_math
d_line_width=2
d_font="verdana"
d_font_size=11
d_font_slant=CAIRO_FONT_SLANT_NORMAL
d_font_face=CAIRO_FONT_WEIGHT_NORMAL
d_font_color_red=.8
d_font_color_green=.8
d_font_color_blue=.8
d_font_color_alpha=1
br_line=3
br_red=.5
br_green=.5
br_blue=.5
br_alpha=1
fill_red=.7
fill_green=.7
fill_blue=.7
fill_alpha=1
br_fill_red=.2
br_fill_green=.2
br_fill_blue=.2
br_fill_alpha=1
i_red=0
i_green=0
i_blue=0
i_alpha=1
i_fill_red=0.3
i_fill_green=0.3
i_fill_blue=0.3
i_fill_alpha=1
m_red=0.1
m_green=0.1
m_blue=0.1
m_alpha=1
a_red=.75
a_green=0
a_blue=0
a_alpha=1
br_radius=40
br_start=15*d_math
br_end=165*d_math
i_radius0=6
i_radius=30
i_radius2=35
i_radius3=25
m_offset=10*d_math
m_start=175*d_math
m_end=m_start+m_offset
m_start2=220*d_math
m_end2=m_start2+m_offset
m_start3=265*d_math
m_end3=m_start3+m_offset
m_start4=310*d_math
m_end4=m_start4+m_offset
m_start5=355*d_math
m_end5=m_start5+m_offset
max_value=100
i_start=180*d_math
i_end_rad=360*d_math
i_math=i_end_rad-i_start
i_math2=i_math/max_value
i_math3=(input)*i_math2
i_point=i_start+i_math3
i_start0=i_point+(80*d_math)
i_end0=i_point-(80*d_math)
a_radius=8
a_x=(position_x)-15
a_y=(position_y)+22
label_x=(position_x)-5
label_y=(position_y)+22
--cairo
cairo_set_line_width(cr,br_line)
cairo_arc(cr,(position_x),(position_y),br_radius,d_start,d_end)
cairo_set_source_rgba(cr,fill_red,fill_green,fill_blue,fill_alpha)
cairo_fill_preserve(cr)
cairo_set_source_rgba(cr,br_red,br_green,br_blue,br_alpha)
cairo_stroke(cr)
cairo_set_line_width(cr,d_line_width)
cairo_arc(cr,(position_x),(position_y),i_radius2,m_start,m_end)
cairo_arc_negative(cr,(position_x),(position_y),i_radius3,m_end,m_start)
cairo_set_source_rgba(cr,m_red,m_green,m_blue,m_alpha)
cairo_close_path(cr)
cairo_fill(cr)
cairo_set_line_width(cr,d_line_width)
cairo_arc(cr,(position_x),(position_y),i_radius2,m_start2,m_end2)
cairo_arc_negative(cr,(position_x),(position_y),i_radius3,m_end2,m_start2)
cairo_set_source_rgba(cr,m_red,m_green,m_blue,m_alpha)
cairo_close_path(cr)
cairo_fill(cr)
cairo_set_line_width(cr,d_line_width)
cairo_arc(cr,(position_x),(position_y),i_radius2,m_start3,m_end3)
cairo_arc_negative(cr,(position_x),(position_y),i_radius3,m_end3,m_start3)
cairo_set_source_rgba(cr,m_red,m_green,m_blue,m_alpha)
cairo_close_path(cr)
cairo_fill(cr)
cairo_set_line_width(cr,d_line_width)
cairo_arc(cr,(position_x),(position_y),i_radius2,m_start4,m_end4)
cairo_arc_negative(cr,(position_x),(position_y),i_radius3,m_end4,m_start4)
cairo_set_source_rgba(cr,m_red,m_green,m_blue,m_alpha)
cairo_close_path(cr)
cairo_fill(cr)
cairo_set_line_width(cr,d_line_width)
cairo_arc(cr,(position_x),(position_y),i_radius2,m_start5,m_end5)
cairo_arc_negative(cr,(position_x),(position_y),i_radius3,m_end5,m_start5)
cairo_set_source_rgba(cr,m_red,m_green,m_blue,m_alpha)
cairo_close_path(cr)
cairo_fill(cr)
cairo_set_line_width(cr,d_line_width)
cairo_arc(cr,(position_x),(position_y),i_radius2,m_end4,m_start5)
cairo_arc_negative(cr,(position_x),(position_y),i_radius3,m_start5,m_end4)
cairo_set_source_rgba(cr,a_red,a_green,a_blue,a_alpha)
cairo_close_path(cr)
cairo_fill(cr)
cairo_set_line_width(cr,d_line_width)
cairo_arc(cr,(position_x),(position_y),i_radius,i_point,i_point)
cairo_arc(cr,(position_x),(position_y),i_radius0,i_start0,i_end0)
cairo_set_source_rgba(cr,i_fill_red,i_fill_green,i_fill_blue,i_fill_alpha)
cairo_fill_preserve(cr)
cairo_set_source_rgba(cr,i_red,i_green,i_blue,i_alpha)
cairo_close_path(cr)
cairo_stroke(cr)
cairo_set_line_width(cr,br_line)
cairo_arc(cr,(position_x),(position_y),br_radius,br_start,br_end)
cairo_set_source_rgba(cr,br_fill_red,br_fill_green,br_fill_blue,br_fill_alpha)
cairo_fill_preserve(cr)
cairo_set_source_rgba(cr,br_red,br_green,br_blue,br_alpha)
cairo_stroke(cr)
cairo_set_line_width(cr,d_line_width)
cairo_arc(cr,a_x,a_y,a_radius,d_start,d_end)
if (input) < 75 then
cairo_set_source_rgba(cr,i_red,i_green,i_blue,i_alpha)
else
cairo_set_source_rgba(cr,a_red,a_green,a_blue,a_alpha)
end
cairo_fill_preserve(cr)
cairo_set_source_rgba(cr,br_red,br_green,br_blue,br_alpha)
cairo_stroke(cr)
cairo_select_font_face (cr,d_font,d_font_slant,d_font_face);
cairo_set_font_size (cr,d_font_size)
cairo_set_source_rgba (cr,d_font_color_red,d_font_color_green,d_font_color_blue,d_font_color_alpha)
cairo_move_to (cr,label_x,label_y)
cairo_show_text (cr,(label))
cairo_stroke(cr)
end
function themometer(x,y,temp,text)
if (temp) > 100 then temp_value=100 else temp_value=tonumber(temp) end
if (text) ~= 1 then text=0 end
cairo_set_line_width(cr,2)
cairo_arc(cr,(x),(y),7.5,(180*(math.pi/180)),(360*(math.pi/180)))
cairo_arc(cr,(x),((y)+100),10,(315*(math.pi/180)),(225*(math.pi/180)))
cairo_close_path(cr)
cairo_set_source_rgba(cr,1,1,1,1)
cairo_stroke(cr)
cairo_arc(cr,(x),(((y)+100)-temp_value),5,(180*(math.pi/180)),(360*(math.pi/180)))
cairo_arc_negative(cr,(x),((y)+100),7,(315*(math.pi/180)),(225*(math.pi/180)))
cairo_close_path(cr)
cairo_set_source_rgba(cr,1,.1,.1,1)
cairo_fill(cr)
cairo_arc(cr,(x),((y)+100),7.5,(0*(math.pi/180)),(360*(math.pi/180)))
cairo_close_path(cr)
cairo_set_source_rgba(cr,1,0,0,1)
cairo_fill(cr)
cairo_arc(cr,(x),(y),7.5,(180*(math.pi/180)),(360*(math.pi/180)))
cairo_arc(cr,(x),((y)+100),10,(315*(math.pi/180)),(225*(math.pi/180)))
cairo_close_path(cr)
cairo_set_source_rgba(cr,.75,.75,1,.25)
cairo_fill(cr)
	if (text) ==1 then
	t={0,25,50,75,100}
		for i = 1,5 do
		a=((y)+105)-(25*(i-1))
		cairo_move_to(cr,((x)+15),a)
		cairo_set_source_rgba(cr,.8,.8,.8,1)
		cairo_select_font_face (cr,"mono",CAIRO_FONT_SLANT_NORMAL,CAIRO_FONT_WEIGHT_NORMAL)
		cairo_set_font_size (cr,11)
		cairo_show_text(cr,t[i])
		cairo_stroke(cr)
		end
	end--if
end--themometer
function transition_arc(x,y,outer,inner,sd,ed,value,scale,bg,br,ic,alert_level,ac)
if (value) == nil then value=0 end
cairo_set_line_width(cr,2)
cairo_arc(cr,x,y,(outer),((sd)*(math.pi/180)),((ed)*(math.pi/180)))
cairo_arc_negative(cr,x,y,(inner),((ed)*(math.pi/180)),((sd)*(math.pi/180)))
cairo_close_path(cr)
cairo_set_source_rgba(cr,bg[1],bg[2],bg[3],bg[4])
cairo_fill(cr)
i_end=(((ed)-(sd))/(scale))*(value)
for i=1,i_end do
position1=((sd)*(math.pi/180))+((i-2)*(math.pi/180))
position2=((sd)*(math.pi/180))+(i*(math.pi/180))
alpha=(1/i_end)*i
cairo_arc(cr,x,y,(outer),position1,position2)
cairo_arc_negative(cr,x,y,(inner),position2,position1)
cairo_close_path(cr)
	if (value) > (alert_level) then
	cairo_set_source_rgba(cr,(ac[1]),(ac[2]),(ac[3]),alpha)
	else
	cairo_set_source_rgba(cr,(ic[1]),(ic[2]),(ic[3]),alpha)
	end
cairo_fill(cr)
end--for end
cairo_arc(cr,x,y,(outer),((sd)*(math.pi/180)),((ed)*(math.pi/180)))
cairo_arc_negative(cr,x,y,(inner),((ed)*(math.pi/180)),((sd)*(math.pi/180)))
cairo_close_path(cr)
cairo_set_source_rgba(cr,br[1],br[2],br[3],br[4])
cairo_stroke(cr)
end--function end
function transition_arc_reverse(x,y,outer,inner,sd,ed,value,scale,bg,br,ic,alert_level,ac)
if (value) == nil then value=0 end
cairo_set_line_width(cr,2)
cairo_arc(cr,x,y,(outer),((sd)*(math.pi/180)),((ed)*(math.pi/180)))
cairo_arc_negative(cr,x,y,(inner),((ed)*(math.pi/180)),((sd)*(math.pi/180)))
cairo_close_path(cr)
cairo_set_source_rgba(cr,bg[1],bg[2],bg[3],bg[4])
cairo_fill(cr)
i_end=((sd-ed)/(scale))*(value)
for i=1,i_end do
position1=((ed)*(math.pi/180))-((i+1)*(math.pi/180))
position2=((ed)*(math.pi/180))-(i*(math.pi/180))
alpha=(1/i_end)*i
cairo_arc(cr,x,y,(outer),position1,position2)
cairo_arc_negative(cr,x,y,(inner),position2,position1)
cairo_close_path(cr)
	if (value) > (alert_level) then
	cairo_set_source_rgba(cr,(ac[1]),(ac[2]),(ac[3]),alpha)
	else
	cairo_set_source_rgba(cr,(ic[1]),(ic[2]),(ic[3]),alpha)
	end
cairo_fill(cr)
end--for end
cairo_arc(cr,x,y,(outer),((sd)*(math.pi/180)),((ed)*(math.pi/180)))
cairo_arc_negative(cr,x,y,(inner),((ed)*(math.pi/180)),((sd)*(math.pi/180)))
cairo_close_path(cr)
cairo_set_source_rgba(cr,br[1],br[2],br[3],br[4])
cairo_stroke(cr)
end--function end
function transition_bar(x,y,l,h,scale,input,ic,br,bg)
cairo_set_line_width(cr,2)
cairo_arc(cr,x,y,(h/2),(90*(math.pi/180)),(270*(math.pi/180)))
cairo_arc(cr,(x+l),y,(h/2),(270*(math.pi/180)),(90*(math.pi/180)))
cairo_close_path(cr)
	if bg ~= nil then
	cairo_set_source_rgba(cr,bg[1],bg[2],bg[3],bg[4])
	else
	cairo_set_source_rgba(cr,.25,.25,.25,.5)
	end
cairo_fill(cr)
i_end=l/100*input
for i = 1,i_end do
cairo_arc(cr,x,y,(h/2),(90*(math.pi/180)),(270*(math.pi/180)))
cairo_arc(cr,(x+i),y,(h/2),(270*(math.pi/180)),(90*(math.pi/180)))
cairo_close_path(cr)
	if ic ~= nil then
	cairo_set_source_rgba(cr,ic[1],ic[2],ic[3],(ic[4]/i_end*i))
	else
	cairo_set_source_rgba(cr,.5,.5,1,(.75/i_end*i))
	end
cairo_stroke(cr)
end
cairo_set_line_width(cr,2)
cairo_arc(cr,x,y,(h/2),(90*(math.pi/180)),(270*(math.pi/180)))
cairo_arc(cr,(x+l),y,(h/2),(270*(math.pi/180)),(90*(math.pi/180)))
cairo_close_path(cr)
	if br ~= nil then
	cairo_set_source_rgba(cr,br[1],br[2],br[3],br[4])
	else
	cairo_set_source_rgba(cr,.75,.75,.75,1)
	end
cairo_stroke(cr)
end
--################################
--graphs
--################################
function bar_graph(tlx,tly,w,h,scale,data,bbrc,bbgc,brc,bgc)
--[[bar_graph(
tlx,tly,w,h,
scale,data,
bbrc,
bbgc,
brc,
bgc
)]]
if bgc ~= nil then
cairo_set_line_width(cr,2)
cairo_rectangle(cr,tlx,tly,w,h)
cairo_set_source_rgba(cr,bgc[1],bgc[2],bgc[3],bgc[4])
cairo_fill(cr)
end
for i = 1,#data do
xi=w/(#data*2+1)
yi=h/scale*data[i]
cairo_rectangle(cr,((tlx+xi)+(xi*((i-1)*2))),(tly+h),xi,-yi)
cairo_set_source_rgba(cr,bbg[1],bbg[2],bbg[3],bbg[4])
cairo_fill_preserve(cr)
cairo_set_source_rgba(cr,bbr[1],bbr[2],bbr[3],bbr[4])
cairo_stroke(cr)
end
if brc ~= nil then
cairo_rectangle(cr,tlx,tly,w,h)
cairo_set_source_rgba(cr,brc[1],brc[2],brc[3],brc[4])
cairo_stroke(cr)
end
end--function
function bar_graphH(tlx,tly,w,size,scale,table_data,bbgc,bbrc,brc,bgc)
--[[tlx=20 ; tly=20
w=100 ; size=4
scale=100
table_data={}
for i = 1,tonumber(conky_mount(1,"total")) do table_data[i]=conky_mount_usep(i) end
bbgc={0,0,0,1}
bbrc={0,1,0,1}
bar_graphH(tlx,tly,w,size,scale,table_data,bbgc,bbrc)]]
if bgc ~= nil then
cairo_set_line_width(cr,2)
cairo_rectangle(cr,tlx,tly,w,(size*2*#table_data+size))
cairo_set_source_rgba(cr,bgc[1],bgc[2],bgc[3],bgc[4])
cairo_fill(cr)
end--if
for i = 1,#table_data do
cairo_set_line_width(cr,2)
cairo_rectangle(cr,tlx,((tly+size)+(size*((i-1)*2))),(w/scale*table_data[i]),size)
cairo_set_source_rgba(cr,bbgc[1],bbgc[2],bbgc[3],bbgc[4])
cairo_fill_preserve(cr)
cairo_set_source_rgba(cr,bbrc[1],bbrc[2],bbrc[3],bbrc[4])
cairo_stroke(cr)
end--for
if brc ~= nil then
cairo_set_line_width(cr,2)
cairo_rectangle(cr,tlx,tly,w,(size*2*#table_data+size))
cairo_set_source_rgba(cr,brc[1],brc[2],brc[3],brc[4])
cairo_stroke(cr)
end--if
end--function
function graph(tlx,tly,w,h,lw,lc,table_length,data,scale,fc)
--[[cpu_table(table_length)
graph(
--tlx,tly,w,h,
20,20,150,60,
--lw,lc,
2,{1,1,1,1},
--table_length,data,scale,
10,cpu_avg_table,100
--outline,fc
)]]
cairo_set_source_rgba(cr,.1,.1,.1,1)
cairo_rectangle(cr,tlx,tly,w,h)
cairo_fill(cr)
cairo_set_line_width(cr,lw)
cairo_move_to(cr,(tlx+w),(tly+h))
for i = 1,#data do cairo_line_to(cr,((tlx+w)-(w/(table_length+1)*i)),((tly+h)-(h/scale*data[i]))) end
cairo_line_to(cr,tlx,(tly+h))
if fc ~= nil then cairo_set_source_rgba(cr,fc[1],fc[2],fc[3],fc[4]) ; cairo_fill_preserve(cr) end
cairo_set_source_rgba(cr,lc[1],lc[2],lc[3],lc[4])
cairo_stroke(cr)
cairo_set_line_width(cr,2)
cairo_set_source_rgba(cr,.5,.5,.5,1)
for i = 1,4 do cairo_move_to(cr,tlx,(tly+(h/5*i))) ; cairo_line_to(cr,(tlx+(w/(table_length+1))),(tly+(h/5*i))) ; cairo_stroke(cr) end
cairo_set_line_width(cr,4)
cairo_set_source_rgba(cr,.5,.5,.5,1)
cairo_rectangle(cr,(tlx-2),(tly-2),(w+2),(h+2))
cairo_stroke(cr)
end
function graph_background(tlx,tly,w,h,scale,interval,lc,brc,bgc)
if bgc ~= nil then
cairo_rectangle(cr,tlx,tly,w,h)
cairo_set_source_rgba(cr,bgc[1],bgc[2],bgc[3],bgc[4])
cairo_fill(cr)
end
for i = 1,(scale/interval) do
cairo_move_to(cr,tlx,((tly+h)-((h/scale)*(interval*i))))
cairo_line_to(cr,(tlx+w),((tly+h)-((h/scale)*(interval*i))))
cairo_set_source_rgba(cr,lc[1],lc[2],lc[3],lc[4])
cairo_stroke(cr)
end
if brc ~= nil then
cairo_rectangle(cr,tlx,tly,w,h)
cairo_set_source_rgba(cr,brc[1],brc[2],brc[3],brc[4])
cairo_stroke(cr)
end
end
function graph_line(tlx,tly,w,h,lw,lc,table_length,data,scale,fc,outline)
if lw == nil then lw=2 end ; if lc == nil then lc={1,1,1,1} end
if data == nil then print("Error:","data=nil") end
if outline == 1 then
cairo_set_line_width(cr,2)
cairo_set_source_rgba(cr,1,1,1,1)
cairo_rectangle(cr,tlx,tly,w,h)
cairo_stroke(cr)
end
cairo_set_line_width(cr,lw)
cairo_move_to(cr,(tlx+w),(tly+h))
for i = 1,#data do cairo_line_to(cr,((tlx+w)-(w/(table_length+1)*i)),((tly+h)-(h/scale*data[i]))) end
cairo_line_to(cr,tlx,(tly+h))
if fc ~= nil then cairo_set_source_rgba(cr,fc[1],fc[2],fc[3],fc[4]) ; cairo_fill_preserve(cr) end
cairo_set_source_rgba(cr,lc[1],lc[2],lc[3],lc[4])
cairo_stroke(cr)
end
function scope(x,y,w,table_data,table_length)
alt_table(table_length)
interval=w*2/(table_length+1)
h=w/2
cairo_set_line_width(cr,2)
cairo_arc(cr,x,y,w,0,(360*(math.pi/180)))
cairo_set_source_rgba(cr,.05,.1,.05,1)
cairo_fill(cr)
cairo_move_to(cr,(x-w),y)
for i = 1,tl do
cairo_line_to(cr,((x-w)+(interval*(i))),(y+(h/100*table_data[i])*alternating_table[i]))
end
cairo_line_to(cr,(x+w),y)
cairo_set_source_rgba(cr,0,.6,0,1)
cairo_stroke(cr)
cairo_set_line_width(cr,2)
cairo_arc(cr,x,y,w,0,(360*(math.pi/180)))
cairo_set_source_rgba(cr,.5,.5,.5,1)
cairo_stroke(cr)
end
function system_graph(tlx,tly,w,h,lw,table_length,interval,cores)
local updates=tonumber(conky_parse("${updates}"))
	if cores == nil then cores=1 end
	if updates < 10 then conky_start=1 else conky_start=nil end
	if timer == nil then timer=60 end
cpu_strings(cores) ; mem_strings() ; swap_strings()
timer=(updates % interval)
	if timer==0 or conky_start==1 then
	cpu_tables(table_length,cores)
	mem_table(table_length)
	swap_table(table_length)
	end
scale=100
vals={cpu_avg_table}
c={{.7,.7,1,1}}
	if cores >= 2 then
	vals[2]=cpu_1_table ; c[2]={.6,.6,1,1}
	vals[3]=cpu_2_table ; c[3]={.5,.5,1,1}
	end
	if cores >= 3 then vals[4]=cpu_3_table ; c[4]={.4,.4,1,1} end
	if cores >= 4 then vals[5]=cpu_4_table ; c[5]={.3,.3,1,1} end
vals[(#vals+1)]=mem_perc_table ; c[(#c+1)]={1,0,0,1}
vals[(#vals+1)]=swap_perc_table ; c[(#c+1)]={0,1,0,1}
for i = 1,#vals do graph_line(tlx,tly,w,h,lw,c[(#vals-(i-1))],table_length,vals[(#vals-(i-1))],scale) end
text((tlx+3),(tly+10),"step = "..interval.."",10)
end--function
--################################
--objects
--################################
function loading()
local updates=tonumber(conky_parse('${updates}'))
if updates == 1 then text(20,20,"loading.") end
if updates == 2 then text(20,20,"loading..") end
if updates == 3 then text(20,20,"loading...") end
if updates == 4 then text(20,20,"loading....") end
if updates == 5 then text(20,20,"loading.....") end
return ""
end
function usb(tlx,tly,mount,size,used,usedp,io)
--################################
--# nil prevention
--################################
if tlx == nil then tlx=50 end
if tly == nil then tly=50 end
if mount == nil then mount="broken" ; print("Error:","check mount input") end
if size == nil then size="broken" ; print("Error:","check size input") end
if used == nil then used="broken" ; print ("Error:","check used input") end
if usedp == nil then usedp=0 ; print("Error:","check used percent input") end
if io == nil then io=0 ; print("Error:","check io input") end
--################################
--colors
border={1,1,1,1}
fill={.1,.1,.1,.75}
fill2={.8,.8,.8,.75}
fill3={.5,.5,.5,.5}
gborder={.5,.5,1,1}
gfill={.5,.5,1,.5}
gbackground={0,0,0,1}
text={.8,.8,.8,1}
indicatorb1={.7,.7,.7,1}
indicatorf1={1,1,1,.3}
indicatorb2={0,.75,0,1}
indicatorf2={0,1,0,.25}
--port
hp=30 ; wp=30
--main body
hb=40 ; wb=150
--3d
offset3d=5
--gauge
gw=15
--port back
cairo_set_line_width(cr,2)
cairo_rectangle(cr,(tlx+offset3d),(tly+5),wp,hp)
cairo_set_source_rgba(cr,fill[1],fill[2],fill[3],fill[4])
cairo_fill_preserve(cr)
cairo_set_source_rgba(cr,border[1],border[2],border[3],border[4])
cairo_stroke(cr)
--main body back
cairo_rectangle(cr,(tlx+offset3d+wp),tly,150,40)
cairo_set_source_rgba(cr,fill[1],fill[2],fill[3],fill[4])
cairo_fill_preserve(cr)
cairo_set_source_rgba(cr,border[1],border[2],border[3],border[4])
cairo_stroke(cr)
--3d lines
x3d1={tlx,(tlx+wp),(tlx+wp+wb),(tlx+wp+wb),(tlx+wp),(tlx)}
y3d1={(tly+offset3d+5),(tly+offset3d),(tly+offset3d),(tly+offset3d+hb),(tly+offset3d+hb),(tly+offset3d+hp+5)}
x3d2={(tlx+offset3d),(tlx+offset3d+wp),(tlx+offset3d+wp+wb),(tlx+offset3d+wp+wb),(tlx+offset3d+wp),(tlx+offset3d)}
y3d2={(tly+5),tly,tly,(tly+hb),(tly+hb),(tly+hp+5)}
for i = 1,#x3d1 do
cairo_move_to(cr,x3d1[i],y3d1[i])
cairo_line_to(cr,x3d2[i],y3d2[i])
cairo_set_source_rgba(cr,border[1],border[2],border[3],border[4])
cairo_stroke(cr)
end
--indicator
cairo_arc(cr,(tlx+offset3d+wp+wb-6),(tly+(hb/2)),(hb/3),(300*(math.pi/180)),(60*(math.pi/180)))
cairo_close_path(cr)
	if io ~= "0B" then
	cairo_set_source_rgba(cr,indicatorf2[1],indicatorf2[2],indicatorf2[3],indicatorf2[4])
	cairo_fill_preserve(cr)
	cairo_set_source_rgba(cr,indicatorb2[1],indicatorb2[2],indicatorb2[3],indicatorb2[4])
	else
	cairo_set_source_rgba(cr,indicatorf1[1],indicatorf1[2],indicatorf1[3],indicatorf1[4])
	cairo_fill_preserve(cr)
	cairo_set_source_rgba(cr,indicatorb1[1],indicatorb1[2],indicatorb1[3],indicatorb1[4])
	end
cairo_stroke(cr)
cairo_arc(cr,(tlx+offset3d+wp+wb-6),(tly+(hb/2)),(hb/3),(300*(math.pi/180)),(60*(math.pi/180)))
cairo_arc_negative(cr,(tlx+wp+wb-6),(tly+offset3d+(hb/2)),(hb/3),(60*(math.pi/180)),(300*(math.pi/180)))
cairo_close_path(cr)
	if io ~= "0B" then
	cairo_set_source_rgba(cr,indicatorf2[1],indicatorf2[2],indicatorf2[3],indicatorf2[4])
	cairo_fill_preserve(cr)
	cairo_set_source_rgba(cr,indicatorb2[1],indicatorb2[2],indicatorb2[3],indicatorb2[4])
	else
	cairo_set_source_rgba(cr,indicatorf1[1],indicatorf1[2],indicatorf1[3],indicatorf1[4])
	cairo_fill_preserve(cr)
	cairo_set_source_rgba(cr,indicatorb1[1],indicatorb1[2],indicatorb1[3],indicatorb1[4])
	end
cairo_stroke(cr)
cairo_arc(cr,(tlx+wp+wb-6),(tly+offset3d+(hb/2)),(hb/3),(300*(math.pi/180)),(60*(math.pi/180)))
cairo_close_path(cr)
	if io ~= "0B" then
	cairo_set_source_rgba(cr,indicatorf2[1],indicatorf2[2],indicatorf2[3],indicatorf2[4])
	cairo_fill_preserve(cr)
	cairo_set_source_rgba(cr,indicatorb2[1],indicatorb2[2],indicatorb2[3],indicatorb2[4])
	else
	cairo_set_source_rgba(cr,indicatorf1[1],indicatorf1[2],indicatorf1[3],indicatorf1[4])
	cairo_fill_preserve(cr)
	cairo_set_source_rgba(cr,indicatorb1[1],indicatorb1[2],indicatorb1[3],indicatorb1[4])
	end
cairo_stroke(cr)
--port front
cairo_rectangle(cr,tlx,(tly+offset3d+5),wp,hp)
cairo_set_source_rgba(cr,fill2[1],fill2[2],fill2[3],fill2[4])
cairo_fill_preserve(cr)
cairo_set_source_rgba(cr,border[1],border[2],border[3],border[4])
cairo_stroke(cr)
--main body front
cairo_rectangle(cr,(tlx+30),(tly+offset3d),150,40)
cairo_set_source_rgba(cr,fill3[1],fill3[2],fill3[3],fill3[4])
cairo_fill_preserve(cr)
cairo_set_source_rgba(cr,border[1],border[2],border[3],border[4])
cairo_stroke(cr)
--use gauge
gx=wp ; gy=hb/4
gl=110
gi=(gl/100)*usedp
--gauge background
cairo_move_to(cr,(tlx+gx),(tly+offset3d+gy))
cairo_arc(cr,(tlx+gx+gl),(tly+offset3d+gy+(gw/2)),(gw/2),(270*(math.pi/180)),(90*(math.pi/180)))
cairo_line_to(cr,(tlx+gx),(tly+offset3d+gy+gw))
cairo_close_path(cr)
cairo_set_source_rgba(cr,gbackground[1],gbackground[2],gbackground[3],gbackground[4])
cairo_fill(cr)
--use indicator
cairo_move_to(cr,(tlx+gx),(tly+offset3d+gy))
cairo_arc(cr,(tlx+gx+gi),(tly+offset3d+gy+(gw/2)),(gw/2),(270*(math.pi/180)),(90*(math.pi/180)))
cairo_line_to(cr,(tlx+gx),(tly+offset3d+gy+gw))
cairo_close_path(cr)
cairo_set_source_rgba(cr,gfill[1],gfill[2],gfill[3],gfill[4])
cairo_fill_preserve(cr)
cairo_set_source_rgba(cr,gborder[1],gborder[2],gborder[3],gborder[4])
cairo_stroke(cr)
--gauge border
cairo_move_to(cr,(tlx+gx),(tly+offset3d+gy))
cairo_arc(cr,(tlx+gx+gl),(tly+offset3d+gy+(gw/2)),(gw/2),(270*(math.pi/180)),(90*(math.pi/180)))
cairo_line_to(cr,(tlx+gx),(tly+offset3d+gy+gw))
cairo_close_path(cr)
cairo_set_source_rgba(cr,border[1],border[2],border[3],border[4])
cairo_stroke(cr)
--text
offsett=10
x={(tlx+offsett+wp),(tlx+offsett+wp),(tlx+offsett+wp+gl)}
y={(tly+offset3d+21),(tly+offset3d+36),(tly+offset3d+21)}
t={mount,""..used.." / "..size .."",""..usedp.."%"}
for i = 1,#t do
cairo_set_source_rgba(cr,text[1],text[2],text[3],text[4])
cairo_move_to(cr,x[i],y[i])
cairo_show_text(cr,t[i])
cairo_stroke(cr)
end--text
end--fuction
function warning_triangle(x,y,w,s)
if s ~= "off" then s="on" end
cairo_set_line_width(cr,2)
if s == "off" then cairo_set_source_rgba(cr,black[1],black[2],black[3],black[4]) else cairo_set_source_rgba(cr,red[1],red[2],red[3],red[4]) end
cairo_move_to(cr,(x+(w/2)),y) ; cairo_line_to(cr,x,(y+w)) ; cairo_line_to(cr,(x+w),(y+w))
cairo_close_path(cr)
cairo_stroke(cr)
p1=w/6 ; p2=p1*4 ; p3=p1*5
cairo_move_to(cr,(x+(w/2)),(y+(p1*2))) ; cairo_line_to(cr,(x+(w/2)),(y+p2))
cairo_close_path(cr)
cairo_stroke(cr)
cairo_move_to(cr,(x+(w/2)),(y+p3)) ; cairo_line_to(cr,(x+(w/2)),(y+(p1*5.5)))
cairo_close_path(cr)
cairo_stroke(cr)
end--function warning_triangle(x,y,w)
--################################
--tables
--################################
function alt_table(table_length)
if table_length == nil then table_length=10 end
if alternating_table == nil then alternating_table={} end
for i = 1,table_length do if alternating_table[i] == nil then alternating_table[i]=1 end end
if alternating_table[table_length] == 1 then alternating=-1 else if alternating_table[table_length] == -1 then alternating=1 end end
for i = 1,table_length do
if alternating_table[i+1]==nil then alternating_table[i+1]=1 end
alternating_table[i]=alternating_table[i+1]
if i==table_length then alternating_table[i]=alternating end
if alternating_table[table_length] == nil then alternating_table[table_length]=1 end
end
end
function cpu_tables(table_length,cores)
if table_length == nil then table_length=10 end
if cores == nil then cores=1 end
--avg
if cores >= 1 then
if cpu_avg == nil then cpu_avg=0 ; print("Error:","cpu_avg=nil") end
if cpu_avg_table == nil then cpu_avg_table={} end
for i = 1, tonumber(table_length) do
            if cpu_avg_table[i+1]==nil then cpu_avg_table[i+1]=0 end
cpu_avg_table[i]=cpu_avg_table[i+1]
            if i==table_length then
            cpu_avg_table[table_length]=cpu_avg
            end
end
for i = 1,table_length do if cpu_avg_table[i] == nil then cpu_avg_table[i]=0 end end
end--avg
--cpu_1
if cores >= 2 then
if cpu_1 == nil then cpu_1=0 ; print("Error:","cpu_1=nil") end
if cpu_1_table == nil then cpu_1_table={} end
for i = 1, tonumber(table_length) do
            if cpu_1_table[i+1]==nil then cpu_1_table[i+1]=0 end
cpu_1_table[i]=cpu_1_table[i+1]
            if i==table_length then
            cpu_1_table[table_length]=cpu_1
            end
end
for i = 1,table_length do if cpu_1_table[i] == nil then cpu_1_table[i]=0 end end
end
--cpu_2
if cores >= 2 then
if cpu_2 == nil then cpu_2=0 ; print("Error:","cpu_2=nil") end
if cpu_2_table == nil then cpu_2_table={} end
for i = 1, tonumber(table_length) do
            if cpu_2_table[i+1]==nil then cpu_2_table[i+1]=0 end
cpu_2_table[i]=cpu_2_table[i+1]
            if i==table_length then
            cpu_2_table[table_length]=cpu_2
            end
end
for i = 1,table_length do if cpu_2_table[i] == nil then cpu_2_table[i]=0 end end
end
--cpu_3
if cores >= 3 then
if cpu_3 == nil then cpu_3=0 ; print("Error:","cpu_3=nil") end
if cpu_3_table == nil then cpu_3_table={} end
for i = 1, tonumber(table_length) do
            if cpu_3_table[i+1]==nil then cpu_3_table[i+1]=0 end
cpu_3_table[i]=cpu_3_table[i+1]
            if i==table_length then
            cpu_3_table[table_length]=cpu_3
            end
end
for i = 1,table_length do if cpu_3_table[i] == nil then cpu_3_table[i]=0 end end
end
--cpu_4
if cores >= 4 then
if cpu_4 == nil then cpu_4=0 ; print("Error:","cpu_4=nil") end
if cpu_4_table == nil then cpu_4_table={} end
for i = 1, tonumber(table_length) do
            if cpu_4_table[i+1]==nil then cpu_4_table[i+1]=0 end
cpu_4_table[i]=cpu_4_table[i+1]
            if i==table_length then
            cpu_4_table[table_length]=cpu_4
            end
end
for i = 1,table_length do if cpu_4_table[i] == nil then cpu_4_table[i]=0 end end
end
end--cpu_tables
function eth0_table(table_length)
if table_length == nil then table_length=10 end
if eth0_down_table == nil then eth0_down_table={} end
if eth0_up_table == nil then eth0_up_table={} end
for i = 1,table_length do if eth0_down_table[i] == nil then eth0_down_table[i]=0 end end
for i = 1,table_length do if eth0_up_table[i] == nil then eth0_up_table[i]=0 end end
if eth0_down == nil then eth0_down=0 end
for i = 1, tonumber(table_length) do
            if eth0_down_table[i+1]==nil then eth0_down_table[i+1]=0 end
eth0_down_table[i]=eth0_down_table[i+1]
            if i==table_length then
            eth0_down_table[table_length]=eth0_down
            end
end
if eth0_up == nil then eth0_up=0 end
for i = 1, tonumber(table_length) do
            if eth0_up_table[i+1]==nil then eth0_up_table[i+1]=0 end
eth0_up_table[i]=eth0_up_table[i+1]
            if i==table_length then
            eth0_up_table[table_length]=eth0_up
            end
end
end
function mem_table(table_length)
if mem_perc == nil then mem_perc=0 ; print("Error:","mem_perc=nil") end
if mem_perc_table == nil then mem_perc_table={} end
for i = 1, tonumber(table_length) do
            if mem_perc_table[i+1]==nil then mem_perc_table[i+1]=0 end
mem_perc_table[i]=mem_perc_table[i+1]
            if i==table_length then
            mem_perc_table[table_length]=mem_perc
            end
end
end--function
function net_down_table(table_length)
if table_length == nil then table_length=10 end
if down_table == nil then down_table={} end
for i = 1,table_length do if down_table[i] == nil then down_table[i]=0 end end
if down == nil then down=0 end
for i = 1, tonumber(table_length) do
            if down_table[i+1]==nil then down_table[i+1]=0 end
down_table[i]=down_table[i+1]
            if i==table_length then
            down_table[table_length]=down_value
            end
end
return down_table
end
function net_up_table(table_length)
if table_length == nil then table_length=10 end
if up_table == nil then up_table={} end
for i = 1,table_length do if up_table[i] == nil then up_table[i]=0 end end
if up == nil then up=0 end
for i = 1, tonumber(table_length) do
            if up_table[i+1]==nil then up_table[i+1]=0 end
up_table[i]=up_table[i+1]
            if i==table_length then
            up_table[table_length]=up_value
            end
end
return up_table
end
function swap_table(table_length)
if swap_perc == nil then swap_perc=0 ; print("Error:","swap_perc=nil") end
if swap_perc_table == nil then swap_perc_table={} end
for i = 1, tonumber(table_length) do
            if swap_perc_table[i+1]==nil then swap_perc_table[i+1]=0 end
swap_perc_table[i]=swap_perc_table[i+1]
            if i==table_length then
            swap_perc_table[table_length]=swap_perc
            end
end
end--function
function wlan0_table(table_length)
if table_length == nil then table_length=10 end
if wlan0_down_table == nil then wlan0_down_table={} end
if wlan0_up_table == nil then wlan0_up_table={} end
for i = 1,table_length do if wlan0_down_table[i] == nil then wlan0_down_table[i]=0 end end
for i = 1,table_length do if wlan0_up_table[i] == nil then wlan0_up_table[i]=0 end end
if wlan0_down == nil then wlan0_down=0 end
for i = 1, tonumber(table_length) do
            if wlan0_down_table[i+1]==nil then wlan0_down_table[i+1]=0 end
wlan0_down_table[i]=wlan0_down_table[i+1]
            if i==table_length then
            wlan0_down_table[table_length]=wlan0_down
            end
end
if wlan0_up == nil then wlan0_up=0 end
for i = 1, tonumber(table_length) do
            if wlan0_up_table[i+1]==nil then wlan0_up_table[i+1]=0 end
wlan0_up_table[i]=wlan0_up_table[i+1]
            if i==table_length then
            wlan0_up_table[table_length]=wlan0_up
            end
end
end
--################################
--strings
--################################
function misc_strings()
month_days={31,28,31,30,31,30,31,31,30,31,30,31}
end

--################################
--################################

--################################
--mrpeachy
--################################
function mrpeachy_pt(px,py,prad,pdeg)
local ppo=(math.pi/180)*pdeg
local px1=px+prad*(math.sin(ppo))
local py1=py-prad*(math.cos(ppo))
return px1,py1
end
function mrpeachy_font(fontt)
local name=fontt.f	or default_font_name	or "mono"
local size=fontt.fs	or default_font_size	or 12
local face=fontt.ff	or default_font_face	or "n"
if face=="n" then
cairo_select_font_face(cr,name,CAIRO_FONT_SLANT_NORMAL,CAIRO_FONT_WEIGHT_NORMAL)
	elseif face=="b" then
	cairo_select_font_face(cr,name,CAIRO_FONT_SLANT_NORMAL,CAIRO_FONT_WEIGHT_BOLD)
		elseif face=="i" then
		cairo_select_font_face(cr,name,CAIRO_FONT_SLANT_ITALIC,CAIRO_FONT_WEIGHT_NORMAL)
			elseif face=="bi" then
			cairo_select_font_face(cr,name,CAIRO_FONT_SLANT_ITALIC,CAIRO_FONT_WEIGHT_BOLD)
end
cairo_set_font_size(cr,size)
end
function mrpeachy_hexcolor(hexcolort)
local col=hexcolort.c	or default_hex_color	or 0xffffff
local a=hexcolort.a	or default_alpha	or 1
local r,g,b=((col/0x10000) % 0x100)/255,((col/0x100) % 0x100)/255,(col % 0x100)/255
cairo_set_source_rgba(cr,r,g,b,a)
end
function mrpeachy_text(textt)
local x=textt.x 		or 100
local y=textt.y 		or 100
local t=textt.t 		or "set txt"
local hj=textt.hj 		or default_horizontal_justify		or "l"
local vj=textt.vj 		or default_vertical_justify		or "n"
local r=textt.r			or default_rotation			or 0
cairo_text_extents(cr,t,extents)
local wx=extents.x_advance
local wd=extents.width
local hy=extents.height
local bx=extents.x_bearing
local by=extents.y_bearing+hy
--hl-- l=left, c=center, r=right
if hj=="l" then
xa=x-bx
rad=0
elseif hj=="c" then
xa=x-((wx-bx)/2)-bx
rad=(wx-bx)/2
elseif hj=="r" then
xa=x-wx
rad=wx-bx
else
print ('hj not set correctly for text: '..t..' - "l", "c" or "r"')
xa=0
rad=0
end
--vj-- n=normal, nb=normal-ybearing, m=middle, mb=middle-ybearing, t=top
if vj=="n" then
ya=y
rad2=0
ry=by
elseif vj=="nb" then
ya=y-by
rad2=-by
ry=by
elseif vj=="m" then
ya=y+((hy-by)/2)
rad2=((hy-by)/2)
ry=((hy-by)/2)-by
elseif vj=="mb" then
ya=y+(hy/2)-by
rad2=(hy/2)-by
ry=((hy-by)/2)-by
elseif vj=="t" then
ya=y+hy-by
rad2=hy-by
ry=0+by
else
print ('vj not set correctly for text: '..t..' - "n", "nb", "m", "mb" or "t"')
ya=0
rad2=0
ry=0
end
--rotation
if r~=0 then
local x2,y2=pt(x,y,rad2,r-180)
local x1,y1=pt(x2,y2,rad,r-90)
cairo_save (cr)
cairo_translate (cr,x1,y1)
cairo_rotate(cr,(math.pi/180)*r)
cairo_show_text (cr,t)
cairo_stroke (cr)
cairo_restore (cr)
else
cairo_move_to (cr,xa,ya)
cairo_show_text (cr,t)
cairo_stroke (cr)
end--if ro
--set non local variables to nil
xa=nil;ya=nil;rad=nil;rad2=nil;ry=nil
end
function mrpeachy_rgbcolor(rgbcolort)
local r=rgbcolort.r		or default_red			or 1
local g=rgbcolort.g		or default_green		or 1
local b=rgbcolort.b		or default_blue			or 1
local a=rgbcolort.a		or default_alpha		or 1
cairo_set_source_rgba(cr,r,g,b,a)
end
function mrpeachy_adeg(deg)
return(math.pi/180)*(deg-90)
end
--################################
--################################
--sort
--################################
--################################

You can find my work here

Make everything ok button

Offline

#7458 2014-05-08 22:53:59

Marenbraga
Member
Registered: 2013-11-14
Posts: 40

Re: Conky v1.9 Thread

ansem_of_nexus wrote:

system_clock
http://s5.postimg.org/p7xgvb5zn/2014_05_08_1399583194_1600x900_scrot.png
green
http://s5.postimg.org/4p2kq8s2b/2014_05_08_1399583669_1600x900_scrot.png
game_display
http://s5.postimg.org/49rax864z/2014_05_08_1399583784_1600x900_scrot.png

Here are the 3 conky I have completed while I was gone. I also have made a master function and scripts lua to be called as support called functions.lua
one of the main uses I built this for is to cut down on lines and quick calls for complex codes.
tables for cpu, mem, swap, and network.
conky_parse grouped and stringed for call once.
conky_controller I made to stop conkys from taxing a system that is struggling after a minute
roman_numeral function that will convert any number up to 199,999
several gauges and graph types

the functions.lua has been my main work for the last little while. it is still a work in progress and probably always will be. also this lua is not just mine, right now I have some of mrpeachy's functions in it (all marked), and as I borrow / collect more it will grow. so if you know of any functions I should add, please let me know.

a link to all of these and my other work is in my sig as always but here is the function.lua

--this lua script for use in conky
require 'cairo'

--################################
--Conky Functions
--################################
function conky_functions()
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)
cr = cairo_create(cs)
local updates=tonumber(conky_parse('${updates}'))
if updates>5 then
--################################
-- Main Body
--################################

--################################
end-- if updates>5
cairo_destroy(cr)
cairo_surface_destroy(cs)
cr=nil
end-- end main function
--################################
function conky_usb_list()
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)
cr = cairo_create(cs)
local updates=tonumber(conky_parse('${updates}'))
if updates>5 then
--################################
for i = 1,10 do if (conky_mount(i,"fsys",8)) == "/dev/sda" then start=i end end
istart=start+1
for i = istart,(istart+5) do
m=i-start
if (conky_mount(i,"mount")) ~= "" then
usb(
--top left x
10
,--top left y
(10+(50*(m-1)))
,--mount point
(conky_mount(i,"mount"))
,--drive size
(conky_mount(i,"size"))
,--drive used
(conky_mount(i,"used"))
,--drive used percent
(conky_parse("${fs_used_perc "..(conky_mount(i,"mount")).."}"))
,--drive io
(conky_parse("${diskio "..(conky_mount(i,"fsys")).."}"))
)--end conky_usb
end
end--for
--################################
end-- if updates>5
cairo_destroy(cr)
cairo_surface_destroy(cs)
cr=nil
return ""
end-- end main function
--################################
function conky_controller()
local updates=tonumber(conky_parse('${updates}'))
if updates>5 then
--################################
table_length=60
cpu_avg=tonumber(conky_parse("${cpu}"))
if cpu_avg == nil then cpu_avg=0 end
if cpu_avg_table == nil then cpu_avg_table={} end
--cpu_average_table={}
for i = 1,table_length do
            if cpu_avg_table[i+1]==nil then cpu_avg_table[i+1]=0 end
cpu_avg_table[i]=cpu_avg_table[i+1]
            if i == table_length then
            cpu_avg_table[table_length]=cpu_avg
            end
end
alert={}
alert_level=1
for i = 1,table_length do
if cpu_avg_table[i] ~= 100 then alert[i]=nil else alert[i]=1 end
if alert[i] == nil then alert_level=0 end
end
if alert_level ~= 0 then
os.execute("conkywonky")
os.execute("conky-load --minimal")
end
--################################
end-- if updates>5
return ""
end-- end main function
--################################
--################################
--Functions
--################################
--################################
--buttons
--################################
function button_make(name,tlx,tly,width,height)
if buttons[""..(name).."_button"]==nil then buttons[""..(name).."_button"]=0 end
--calculate if click was inside box
if localx>=(tlx) and localx<=(tlx)+(width) and localy>=(tly) and localy<=(tly)+(height) and buttons[""..(name).."_button"]~=1 then
buttons[""..(name).."_button"]=1
elseif localx>=(tlx) and localx<=(tlx)+(width) and localy>=(tly) and localy<=(tly)+(height) and buttons[""..(name).."_button"]==1 then
buttons[""..(name).."_button"]=0 end
end--function
function button_count(name,tlx,tly,width,height,max_value)
if buttons[""..(name).."_count"]==nil then buttons[""..(name).."_count"]=1 end
if (max_value) == nil then max_value=1 end
--calculate if click was inside box
if localx>=(tlx) and localx<=(tlx)+(width) and localy>=(tly) and localy<=(tly)+(height) and buttons[""..(name).."_count"] ~= max_value then
buttons[""..(name).."_count"]=(buttons[""..(name).."_count"])+1
elseif localx>=(tlx) and localx<=(tlx)+(width) and localy>=(tly) and localy<=(tly)+(height) and buttons[""..(name).."_count"] == max_value then
buttons[""..(name).."_count"]=1 end
end--function
function button_draw(tlx,tly,width,height,color,fill,fill_color)
cairo_set_line_width (cr,2)
cairo_rectangle (cr,tlx,tly,width,height)
	if fill == 1 then
	cairo_set_source_rgba (cr,fill_color[1],fill_color[2],fill_color[3],fill_color[4])
	cairo_fill_preserve(cr)
	end
cairo_set_source_rgba (cr,color[1],color[2],color[3],color[4])
cairo_stroke (cr)
end--function
function button_status(name)
return buttons[""..(name).."_button"]
end--function
function button_count_status(name)
return buttons[""..(name).."_count"]
end--function
function button_override(name,value)
buttons[""..(name).."_button"]=(value)
end--function
function button_count_override(name,value)
buttons[""..(name).."_count"]=(value)
end--function
function kill_button(name,tlx,tly,process,pid,reset,reset_inpute)
button_make(""..name.."1",tlx,tly,40,20)
	if (button_status(""..name.."1")) == 1 then
	buttons[""..name.."_process"]=process
	buttons[""..name.."_pid"]=pid
	button_override(""..name.."1",2)
	end
if (button_status(""..name.."1")) == 0 then
button_draw(tlx,tly,40,20,{.5,.5,.5,1},1,{.25,.25,.25,.5})
cairo_move_to(cr,(tlx+1),(tly+15))
cairo_set_source_rgba(cr,.8,.8,.8,1)
cairo_select_font_face (cr,"mono",CAIRO_FONT_SLANT_NORMAL,CAIRO_FONT_WEIGHT_NORMAL)
cairo_set_font_size (cr,15)
cairo_show_text(cr,"kill")
cairo_stroke(cr)
else
	if (button_status(""..name.."1")) == 2 then
	cairo_set_line_width(cr,2)
	cairo_rectangle(cr,tlx,tly,265,50)
	cairo_set_source_rgba(cr,.5,.5,.5,1)
	cairo_fill_preserve(cr)
	cairo_set_source_rgba(cr,.25,.25,.25,1)
	cairo_stroke(cr)
	x={1,57}
	t={"Are you sure you want to kill",""..buttons[""..name.."_process"]..""..buttons[""..name.."_pid"]..""}
		for i = 1,2 do
		cairo_move_to(cr,(tlx+x[i]),(tly+(i*15)))
		cairo_set_source_rgba(cr,0,0,0,1)
		cairo_select_font_face (cr,"mono",CAIRO_FONT_SLANT_NORMAL,CAIRO_FONT_WEIGHT_NORMAL)
		cairo_set_font_size (cr,15)
		cairo_show_text(cr,t[i])
		cairo_stroke(cr)
		end
	button_make(""..name.."2",(tlx+20),(tly+30),40,20)
	cairo_move_to(cr,(tlx+21),(tly+45))
	cairo_set_source_rgba(cr,.8,.8,.8,1)
	cairo_select_font_face (cr,"mono",CAIRO_FONT_SLANT_NORMAL,CAIRO_FONT_WEIGHT_NORMAL)
	cairo_set_font_size (cr,15)
	cairo_show_text(cr,"kill")
	cairo_stroke(cr)
	button_make(""..name.."3",(tlx+200),(tly+30),50,20)
	cairo_move_to(cr,(tlx+202),(tly+45))
	cairo_set_source_rgba(cr,.8,.8,.8,1)
	cairo_select_font_face (cr,"mono",CAIRO_FONT_SLANT_NORMAL,CAIRO_FONT_WEIGHT_NORMAL)
	cairo_set_font_size (cr,15)
	cairo_show_text(cr,"Close")
	cairo_stroke(cr)
		if (button_status(""..name.."3")) == 1 then
		button_override(""..name.."3",0)
		button_override(""..name.."2",0)
		button_override(""..name.."1",0)
		end
		if (button_status(""..name.."2")) == 1 then
		os.execute("kill "..buttons[""..name.."_pid"].."")
		button_override(""..name.."1",0)
		button_override(""..name.."2",0)
		end--if (button_status(""..name.."2")) == 1 then
	end--if (button_status(""..name.."1")) == 2 then
end--if (button_status(""..name.."1")) == 0 then
end--function
--################################
--cairo
--################################
function firsts()
cairo_set_line_width(cr,2)
cairo_set_source_rgba(cr,1,1,1,1)
end
function arc(x,y,r,sd,ed,br,lw,bg)
if br == nil then br={1,1,1,1} end ; if lw == nil then lw=2 end
cairo_set_line_width(cr,lw)
cairo_arc(cr,x,y,r,(sd*(math.pi/180)),(ed*(math.pi/180)))
	if bg ~= nil then
	cairo_set_source_rgba(cr,bg[1],bg[2],bg[3],bg[4])
	cairo_fill_preserve(cr)
	end
cairo_set_source_rgba(cr,br[1],br[2],br[3],br[4])
cairo_stroke(cr)
end
function font(name,slant,face)
if name == nil then name="verdana" end
if name == "mono" then
	if slant == nil then slant=CAIRO_FONT_SLANT_NORMAL end
	if face == nil then face=CAIRO_FONT_WEIGHT_NORMAL end
	if size == nil then size=11 end
end
if name == "verdana" then
	if slant == nil then slant=CAIRO_FONT_SLANT_NORMAL end
	if face == nil then face=CAIRO_FONT_WEIGHT_NORMAL end
	if size == nil then size=11 end
end
if name == "dejavu serif" then
	if slant == nil then slant=CAIRO_FONT_SLANT_NORMAL end
	if face == nil then face=CAIRO_FONT_WEIGHT_NORMAL end
	if size == nil then size=13 end
end
cairo_select_font_face (cr,name,slant,face) ; cairo_set_font_size (cr,size)
end
function line(x1,y1,x2,y2,c,w)
if c == nil then c={1,1,1,1} end
if w == nil then w=2 end
cairo_set_line_width(cr,w)
cairo_move_to(cr,x1,y1)
cairo_line_to(cr,x2,y2)
cairo_set_source_rgba(cr,c[1],c[2],c[3],c[4])
cairo_stroke(cr)
end
function line_cap(cap)
if cap == "round" then cairo_set_line_cap(cr,CAIRO_LINE_CAP_ROUND) end
if cap == "mitter" then cairo_set_line_cap(cr,CAIRO_LINE_CAP_MITTER) end
end
function rectangle(tlx,tly,w,h,lw,lc,fc)
if lw ~= nil then cairo_set_line_width(cr,lw) end
cairo_rectangle(cr,tlx,tly,w,h)
if fc ~= nil then cairo_set_source_rgba(cr,fc[1],fc[2],fc[3],fc[4]) ; cairo_fill_preserve(cr) end
if lc ~= nil then cairo_set_source_rgba(cr,lc[1],lc[2],lc[3],lc[4]) end
cairo_stroke(cr)
end
function rounded_rectangle(tlx,tly,w,h,r,border,fill)
cairo_set_line_width(cr,2)
x={tlx,(tlx+w),(tlx+w),tlx} ; y={tly,tly,(tly+h),(tly+h)}
for i = 1,4 do cairo_arc(cr,x[i],y[i],r,((180+(90*(i-1)))*(math.pi/180)),((270+(90*(i-1)))*(math.pi/180))) end
cairo_close_path(cr)
	if fill ~= nil then
	cairo_set_source_rgba(cr,fill[1],fill[2],fill[3],fill[4])
	cairo_fill_preserve(cr)
	end
cairo_set_source_rgba(cr,border[1],border[2],border[3],border[4])
cairo_stroke(cr)
end
function text(x,y,t,s,c)
if s ~= nil then cairo_set_font_size (cr,s) end
if c ~= nil then cairo_set_source_rgba (cr,c[1],c[2],c[3],c[4]) else cairo_set_source_rgba (cr,.8,.8,.8,1) end
cairo_move_to (cr,x,y)
cairo_show_text (cr,t)
cairo_stroke (cr)
end
--################################
--convertion
--################################
function adeg(input)
return (input*(math.pi/180))
end
function colors(c)
if c == "black" then return {0,0,0,1} end
if c == "blue" then return {0,1,0,1} end
if c == "green" then return {0,0,1,1} end
if c == "red" then return {1,0,0,1} end
if c == "white" then  return {1,1,1,1} end
if c == "font_color" then return {.8,.8,.8,1} end
end
function color_rgba(r,g,b,a)
c={r,g,b} ; o={}
for i = 1,3 do o[i]=255/100*c[i]/1000 end ; if a ~= nil then o[4]=a end
return o
end
function conky_mount_usep(partition_number)
output=tonumber(conky_parse("${fs_used_perc "..(conky_mount(partition_number,"mount")).."}"))
return output
end--function
function count_down(y,mo,d,h,mi)
time_strings()
if y == nil then y=year end
if mo == nil then mo=month_number end
if d == nil then d=day_number end
if h == nil then h=hour24 end
if mi == nil then mi=60 end
if y ~= "text" then
s=60
y2o=y-year
mo2o=mo-month_number
d2o=d-day_number
h2o=h-hour24
mi2o=mi-minute
s2o=s-second
	if y2o < 0 then
	s2o=0 ; mi2o=0 ; h2o=0 ; d2o=0 ; mo2o=0 ; y2o=0 end
	if mo2o < 0 then if y2o <= 0 then
	s2o=0 ; mi2o=0 ; h2o=0 ; d2o=0 ; mo2o=0 ; y2o=0 end end
	if d2o < 0 then if mo2o <= 0 then if y2o <= 0 then
	s2o=0 ; mi2o=0 ; h2o=0 ; d2o=0 ; mo2o=0 ; y2o=0 end end end
	if h2o < 0 then if d2o <= 0 then if mo2o <= 0 then if y2o <= 0 then
	s2o=0 ; mi2o=0 ; h2o=0 ; d2o=0 ; mo2o=0 ; y2o=0 end end end end
	if mi2o < 0 then if h2o <= 0 then if d2o <= 0 then if mo2o <= 0 then if y2o <= 0 then
	s2o=0 ; mi2o=0 ; h2o=0 ; d2o=0 ; mo2o=0 ; y2o=0 end end end end end
	if s2o < 0 then if mi2o <= 0 then if h2o <= 0 then if d2o <= 0 then if mo2o <= 0 then if y2o <= 0 then
	s2o=0 ; mi2o=0 ; h2o=0 ; d2o=0 ; mo2o=0 ; y2o=0 end end end end end end
if y2o < 0 then y2o=0 end
if mo2o < 0 then mo2o=0 end
if d2o < 0 then d2o=0 end
if h2o < 0 then h2o=0 end
if mi2o < 0 then mi2o=0 end
if s2o < 0 then s2o=0 end
output=""..h2o..":"..mi2o..":"..s2o.."  "..mo2o.."/"..d2o.."/"..y2o..""
if output == "0:0:0  0/0/0" then output="past" end
else
output="h:mi:s  mo/d/y" end
return output
end
function roman_numeral(input,override)
--roman_numeral's limit is "199,999"
--test=""..roman_numberal(month_number).."/"..roman_numberal(day_number).."/"..roman_numberal(year_full).."  "..roman_numberal(hour24)..":"..roman_numberal(minute)..":"..roman_numberal(second)..""
if input == nil then input=0 end
number=input ; count=0 ; output=""
thousand="M"
five_hundred="D"
hundred="C"
fifty="L"
ten="X"
five="V"
one="I"
--thousand
for i = 1,100 do if number >= 1000 then number=number-1000 ; count=i end end
if count ~= 0 then for i = 1,count do output=""..output..""..thousand.."" end end
count=0
--hundred
for i = 1,9 do if number >= 100 then number=number-100 ; count=i end end
if count == 9 then
output=""..output..""..hundred..""..thousand..""
else
	if count >= 5 then
	output=""..output..""..five_hundred..""
	if count > 5 then for i = 1,(count-5) do output=""..output..""..hundred.."" end end
	else
		if count == 4 then output=""..output..""..hundred..""..five_hundred..""
		else
			if count ~= 0 then for i = 1,count do output=""..output..""..hundred.."" end end
		end--if count 4
	end-- if count 5
end--if count 9
count=0
--ten
for i = 1,9 do if number >= 10 then number=number-10 ; count=i end end
if count == 9 then
output=""..output..""..ten..""..hundred..""
else
	if count >= 5 then
	output=""..output..""..fifty..""
	if count > 5 then for i = 1,(count-5) do output=""..output..""..ten.."" end end
	else
		if count == 4 then output=""..output..""..ten..""..fifty..""
		else
			if count ~= 0 then for i = 1,count do output=""..output..""..ten.."" end end
		end--if count 4
	end-- if count 5
end--if count 9
count=0
--one
for i = 1,9 do if number >= 1 then number=number-1 ; count=i end end
if count == 9 then
output=""..output..""..one..""..ten..""
else
	if count >= 5 then
	output=""..output..""..five..""
	if count > 5 then for i = 1,(count-5) do output=""..output..""..one.."" end end
	else
		if count == 4 then output=""..output..""..one..""..five..""
		else
			if count ~= 0 then for i = 1,count do output=""..output..""..one.."" end end
		end--if count 4
	end-- if count 5
end--if count 9
count=0
if input == 0 then output="nulla" end
return output
end--function
--################################
--conky
--################################
function cpu_strings(cores)
if cores == nil then cores=1 end
cpu_avg=tonumber(conky_parse("${cpu cpu0}"))
if cpu_avg == nil then cpu_avg=0 end
cpu=cpu_avg
cpu_1=tonumber(conky_parse("${cpu cpu1}"))
if cpu_1 == nil then cpu_1=0 end
	if cores >= 2 then
	cpu_2=tonumber(conky_parse("${cpu cpu2}"))
	if cpu_2 == nil then cpu_2=0 end
	end
	if cores >= 3 then
	cpu_3=tonumber(conky_parse("${cpu cpu3}"))
	if cpu_3 == nil then cpu_3=0 end
	end
	if cores >= 4 then
	cpu_4=tonumber(conky_parse("${cpu cpu4}"))
	if cpu_4 == nil then cpu_4=0 end
	end
end--function
function eth0_strings()
eth0_down=tonumber(conky_parse("${downspeed eth0}"))
eth0_down_value=tonumber(conky_parse("${downspeedf eth0}"))
eth0_up=tonumber(conky_parse("${upspeed eth0}"))
eth0_up_value=tonumber(conky_parse("${upspeedf eth0}"))
ip_eth0=conky_parse("${addr eth0}")
end
function file_system_strings(boot)
home_perc=tonumber(conky_parse("${fs_used_perc /home}"))
	if home_perc == nil then home_perc=0 end
home_size=conky_parse("${fs_size /home}")
home_used=conky_parse("${fs_used /home}")
io=conky_parse("${diskio}")
system_perc=tonumber(conky_parse("${fs_used_perc /}"))
	if system_perc == nil then system_perc=0 end
system_size=conky_parse("${fs_size /}")
system_used=conky_parse("${fs_used /}")
--other partitions
	if boot == 1 then
	boot_perc=tonumber(conky_parse("${fs_used_perc /boot}"))
		if boot_perc == nil then boot_perc=0 end
	boot_size=conky_parse("${fs_size /boot}")
	boot_used=conky_parse("${fs_used /boot}")
	end
end--function
function hwmon(type,n)
o=conky_parse("${hwmon "..type.." "..n.."}") ; return o
end
function mem_strings()
mem_max=conky_parse("${memmax}")
mem_perc=tonumber(conky_parse("${memperc}"))
	if mem_perc == nil then mem_perc=0 end
mem_used=conky_parse("${mem}")
end
function net_strings()
down=conky_parse("${downspeed}")
down_value=conky_parse("${downspeedf}")
up=conky_parse("${upspeed}")
up_value=conky_parse("${upspeedf}")
ip=conky_parse("${addr}")
end
function swap_strings()
swap_perc=tonumber(conky_parse("${swapperc}"))
	if swap_perc == nil then swap_perc=0 end
swap_used=conky_parse("${swap}")
swap_max=conky_parse("${swapmax}")
end
function time_strings()
abbr_month=conky_parse("${time %b}")
ampm=conky_parse("${time %p}")
date_mm_dd_yy=conky_parse("${time %D}")
day=conky_parse("${time %a}")
day_number=tonumber(conky_parse("${time %d}"))
minute=tonumber(conky_parse("${time %M}"))
month_number=tonumber(conky_parse("${time %m}"))
hour12=tonumber(conky_parse("${time %I}"))
hour24=tonumber(conky_parse("${time %H}"))
second=tonumber(conky_parse("${time %S}"))
time_hms12=conky_parse("${time %r}")
time_hms24=conky_parse("${time %T}")
weekday_number=tonumber(conky_parse("${time %u}"))
year=tonumber(conky_parse("${time %y}"))
year_full=tonumber(conky_parse("${time %Y}"))
end
function top_strings(table_length)
top_name={}
top_cpu={}
top_pid={}
top_mem={}
top_time={}
for i = 1,table_length do
top_name[i]=conky_parse("${top name "..i.."}")
top_cpu[i]=conky_parse("${top cpu "..i.."}")
top_pid[i]=conky_parse("${top pid "..i.."}")
top_mem[i]=conky_parse("${top mem "..i.."}")
top_time[i]=conky_parse("${top time "..i.."}")
end
end--function
function top_mem_strings(table_length)
top_mem_name={}
top_mem_cpu={}
top_mem_pid={}
top_mem_mem={}
top_mem_time={}
for i = 1,table_length do
top_mem_name[i]=conky_parse("${top_mem name "..i.."}")
top_mem_cpu[i]=conky_parse("${top_mem cpu "..i.."}")
top_mem_pid[i]=conky_parse("${top_mem pid "..i.."}")
top_mem_mem[i]=conky_parse("${top_mem mem "..i.."}")
top_mem_time[i]=conky_parse("${top_mem time "..i.."}")
end
end--function
function wlan0_strings()
wlan0_down=tonumber(conky_parse("${downspeed wlan0}"))
wlan0_down_value=tonumber(conky_parse("${downspeedf wlan0}"))
wlan0_up=tonumber(conky_parse("${upspeed wlan0}"))
wlan0_up_value=tonumber(conky_parse("${upspeedf wlan0}"))
ip_wlan0=conky_parse("${addr wlan0}")
end
--################################
--gauges
--################################
function bar_meter(x,y,input)
--[[bar_meter(
--x,y,
20,20,
--input
cpu_avg
)]]
for i = 1,10 do
cairo_set_line_width(cr,2)
cairo_rectangle(cr,(x),((y+91)-((i-1)*10)),15,7)
level=(i-1)*10
if (input) > level then
cairo_set_source_rgba(cr,0,.75,0,1)
	if i >= 7 then
	cairo_set_source_rgba(cr,1,1,0,1)
	end
	if i >= 9 then
	cairo_set_source_rgba(cr,1,.3,.3,1)
	end
cairo_fill_preserve(cr)
end
cairo_set_source_rgba(cr,.2,.2,.2,1)
cairo_stroke(cr)
end
end--function end
function bar_meterh(x,y,input)
--[[bar_meterh(
--x,y,
20,20,
--input
cpu_avg)]]
for i = 1,10 do
cairo_set_line_width(cr,2)
cairo_rectangle(cr,((x)+((i-1)*10)),(y),7,15)
level=(i-1)*10
if (input) > level then
cairo_set_source_rgba(cr,0,.7,0,1)
	if i >= 7 then
	cairo_set_source_rgba(cr,1,1,0,1)
	end
	if i >= 9 then
	cairo_set_source_rgba(cr,1,.3,.3,1)
	end
cairo_fill_preserve(cr)
end
cairo_set_source_rgba(cr,.2,.2,.2,1)
cairo_stroke(cr)
end
end--function end
function computer_chip(tlx,tly,width,height,input,scale)
cairo_set_line_width(cr,2)
cairo_set_source_rgba(cr,.75,.75,.75,1)
offset=5
for i = 1,10 do
cairo_move_to(cr,tlx,(tly+((height/11)*i)))
cairo_line_to(cr,(tlx+offset),(tly+((height/11)*i)))
cairo_stroke(cr)
cairo_move_to(cr,(tlx+width+offset),(tly+((height/11)*i)))
cairo_line_to(cr,(tlx+width+(offset*2)),(tly+((height/11)*i)))
cairo_stroke(cr)
end
cairo_rectangle(cr,(tlx+offset),tly,width,height)
cairo_set_source_rgba(cr,.1,.1,.1,1)
cairo_fill_preserve(cr)
cairo_set_source_rgba(cr,.2,.2,.2,1)
cairo_stroke(cr)
if (input) < 0 then input=0 end
level=(height-6)/scale
cairo_rectangle(cr,(tlx+(offset*2)),(tly+(height-3)-(level*input)),(width-(offset*2)),(level*input))
cairo_set_source_rgba(cr,0,.5,0,1)
cairo_fill(cr)
end
function gauge1(gx,gy,gl,input,scale,color1,color2,color3)
--[[gauge1(
--gx,gy,gl,
20,20,100,
--input,scale,
50,100,
--color1,color2,color3
{.5,.5,.5,1},{0,0,0,1},{1,1,1,1})]]
cairo_move_to(cr,gx,gy) ; cairo_line_to(cr,(gx+gl),gy)
cairo_set_line_cap(cr,CAIRO_LINE_CAP_ROUND)
cairo_set_line_width(cr,10)
cairo_set_source_rgba(cr,color1[1],color1[2],color1[3],color1[4])
cairo_stroke_preserve(cr)
cairo_set_line_width(cr,6)
cairo_set_source_rgba(cr,color2[1],color2[2],color2[3],color2[4])
cairo_stroke(cr)
cairo_move_to(cr,gx,gy) ; cairo_line_to(cr,(gx+(gl/100*input)),gy)
cairo_set_line_cap(cr,CAIRO_LINE_CAP_ROUND)
cairo_set_line_width(cr,2)
cairo_set_source_rgba(cr,color3[1],color3[2],color3[3],color3[4])
cairo_stroke(cr)
end--end of gauge 1
function needle_gauge(position_x,position_y,input,label)
--[[needle_gauge(
--position_x,position_y,
55,60,
--input,label
cpu_avg,"test")]]
d_math=(math.pi/180)
d_start=0
d_end=360*d_math
d_line_width=2
d_font="verdana"
d_font_size=11
d_font_slant=CAIRO_FONT_SLANT_NORMAL
d_font_face=CAIRO_FONT_WEIGHT_NORMAL
d_font_color_red=.8
d_font_color_green=.8
d_font_color_blue=.8
d_font_color_alpha=1
br_line=3
br_red=.5
br_green=.5
br_blue=.5
br_alpha=1
fill_red=.7
fill_green=.7
fill_blue=.7
fill_alpha=1
br_fill_red=.2
br_fill_green=.2
br_fill_blue=.2
br_fill_alpha=1
i_red=0
i_green=0
i_blue=0
i_alpha=1
i_fill_red=0.3
i_fill_green=0.3
i_fill_blue=0.3
i_fill_alpha=1
m_red=0.1
m_green=0.1
m_blue=0.1
m_alpha=1
a_red=.75
a_green=0
a_blue=0
a_alpha=1
br_radius=40
br_start=15*d_math
br_end=165*d_math
i_radius0=6
i_radius=30
i_radius2=35
i_radius3=25
m_offset=10*d_math
m_start=175*d_math
m_end=m_start+m_offset
m_start2=220*d_math
m_end2=m_start2+m_offset
m_start3=265*d_math
m_end3=m_start3+m_offset
m_start4=310*d_math
m_end4=m_start4+m_offset
m_start5=355*d_math
m_end5=m_start5+m_offset
max_value=100
i_start=180*d_math
i_end_rad=360*d_math
i_math=i_end_rad-i_start
i_math2=i_math/max_value
i_math3=(input)*i_math2
i_point=i_start+i_math3
i_start0=i_point+(80*d_math)
i_end0=i_point-(80*d_math)
a_radius=8
a_x=(position_x)-15
a_y=(position_y)+22
label_x=(position_x)-5
label_y=(position_y)+22
--cairo
cairo_set_line_width(cr,br_line)
cairo_arc(cr,(position_x),(position_y),br_radius,d_start,d_end)
cairo_set_source_rgba(cr,fill_red,fill_green,fill_blue,fill_alpha)
cairo_fill_preserve(cr)
cairo_set_source_rgba(cr,br_red,br_green,br_blue,br_alpha)
cairo_stroke(cr)
cairo_set_line_width(cr,d_line_width)
cairo_arc(cr,(position_x),(position_y),i_radius2,m_start,m_end)
cairo_arc_negative(cr,(position_x),(position_y),i_radius3,m_end,m_start)
cairo_set_source_rgba(cr,m_red,m_green,m_blue,m_alpha)
cairo_close_path(cr)
cairo_fill(cr)
cairo_set_line_width(cr,d_line_width)
cairo_arc(cr,(position_x),(position_y),i_radius2,m_start2,m_end2)
cairo_arc_negative(cr,(position_x),(position_y),i_radius3,m_end2,m_start2)
cairo_set_source_rgba(cr,m_red,m_green,m_blue,m_alpha)
cairo_close_path(cr)
cairo_fill(cr)
cairo_set_line_width(cr,d_line_width)
cairo_arc(cr,(position_x),(position_y),i_radius2,m_start3,m_end3)
cairo_arc_negative(cr,(position_x),(position_y),i_radius3,m_end3,m_start3)
cairo_set_source_rgba(cr,m_red,m_green,m_blue,m_alpha)
cairo_close_path(cr)
cairo_fill(cr)
cairo_set_line_width(cr,d_line_width)
cairo_arc(cr,(position_x),(position_y),i_radius2,m_start4,m_end4)
cairo_arc_negative(cr,(position_x),(position_y),i_radius3,m_end4,m_start4)
cairo_set_source_rgba(cr,m_red,m_green,m_blue,m_alpha)
cairo_close_path(cr)
cairo_fill(cr)
cairo_set_line_width(cr,d_line_width)
cairo_arc(cr,(position_x),(position_y),i_radius2,m_start5,m_end5)
cairo_arc_negative(cr,(position_x),(position_y),i_radius3,m_end5,m_start5)
cairo_set_source_rgba(cr,m_red,m_green,m_blue,m_alpha)
cairo_close_path(cr)
cairo_fill(cr)
cairo_set_line_width(cr,d_line_width)
cairo_arc(cr,(position_x),(position_y),i_radius2,m_end4,m_start5)
cairo_arc_negative(cr,(position_x),(position_y),i_radius3,m_start5,m_end4)
cairo_set_source_rgba(cr,a_red,a_green,a_blue,a_alpha)
cairo_close_path(cr)
cairo_fill(cr)
cairo_set_line_width(cr,d_line_width)
cairo_arc(cr,(position_x),(position_y),i_radius,i_point,i_point)
cairo_arc(cr,(position_x),(position_y),i_radius0,i_start0,i_end0)
cairo_set_source_rgba(cr,i_fill_red,i_fill_green,i_fill_blue,i_fill_alpha)
cairo_fill_preserve(cr)
cairo_set_source_rgba(cr,i_red,i_green,i_blue,i_alpha)
cairo_close_path(cr)
cairo_stroke(cr)
cairo_set_line_width(cr,br_line)
cairo_arc(cr,(position_x),(position_y),br_radius,br_start,br_end)
cairo_set_source_rgba(cr,br_fill_red,br_fill_green,br_fill_blue,br_fill_alpha)
cairo_fill_preserve(cr)
cairo_set_source_rgba(cr,br_red,br_green,br_blue,br_alpha)
cairo_stroke(cr)
cairo_set_line_width(cr,d_line_width)
cairo_arc(cr,a_x,a_y,a_radius,d_start,d_end)
if (input) < 75 then
cairo_set_source_rgba(cr,i_red,i_green,i_blue,i_alpha)
else
cairo_set_source_rgba(cr,a_red,a_green,a_blue,a_alpha)
end
cairo_fill_preserve(cr)
cairo_set_source_rgba(cr,br_red,br_green,br_blue,br_alpha)
cairo_stroke(cr)
cairo_select_font_face (cr,d_font,d_font_slant,d_font_face);
cairo_set_font_size (cr,d_font_size)
cairo_set_source_rgba (cr,d_font_color_red,d_font_color_green,d_font_color_blue,d_font_color_alpha)
cairo_move_to (cr,label_x,label_y)
cairo_show_text (cr,(label))
cairo_stroke(cr)
end
function themometer(x,y,temp,text)
if (temp) > 100 then temp_value=100 else temp_value=tonumber(temp) end
if (text) ~= 1 then text=0 end
cairo_set_line_width(cr,2)
cairo_arc(cr,(x),(y),7.5,(180*(math.pi/180)),(360*(math.pi/180)))
cairo_arc(cr,(x),((y)+100),10,(315*(math.pi/180)),(225*(math.pi/180)))
cairo_close_path(cr)
cairo_set_source_rgba(cr,1,1,1,1)
cairo_stroke(cr)
cairo_arc(cr,(x),(((y)+100)-temp_value),5,(180*(math.pi/180)),(360*(math.pi/180)))
cairo_arc_negative(cr,(x),((y)+100),7,(315*(math.pi/180)),(225*(math.pi/180)))
cairo_close_path(cr)
cairo_set_source_rgba(cr,1,.1,.1,1)
cairo_fill(cr)
cairo_arc(cr,(x),((y)+100),7.5,(0*(math.pi/180)),(360*(math.pi/180)))
cairo_close_path(cr)
cairo_set_source_rgba(cr,1,0,0,1)
cairo_fill(cr)
cairo_arc(cr,(x),(y),7.5,(180*(math.pi/180)),(360*(math.pi/180)))
cairo_arc(cr,(x),((y)+100),10,(315*(math.pi/180)),(225*(math.pi/180)))
cairo_close_path(cr)
cairo_set_source_rgba(cr,.75,.75,1,.25)
cairo_fill(cr)
	if (text) ==1 then
	t={0,25,50,75,100}
		for i = 1,5 do
		a=((y)+105)-(25*(i-1))
		cairo_move_to(cr,((x)+15),a)
		cairo_set_source_rgba(cr,.8,.8,.8,1)
		cairo_select_font_face (cr,"mono",CAIRO_FONT_SLANT_NORMAL,CAIRO_FONT_WEIGHT_NORMAL)
		cairo_set_font_size (cr,11)
		cairo_show_text(cr,t[i])
		cairo_stroke(cr)
		end
	end--if
end--themometer
function transition_arc(x,y,outer,inner,sd,ed,value,scale,bg,br,ic,alert_level,ac)
if (value) == nil then value=0 end
cairo_set_line_width(cr,2)
cairo_arc(cr,x,y,(outer),((sd)*(math.pi/180)),((ed)*(math.pi/180)))
cairo_arc_negative(cr,x,y,(inner),((ed)*(math.pi/180)),((sd)*(math.pi/180)))
cairo_close_path(cr)
cairo_set_source_rgba(cr,bg[1],bg[2],bg[3],bg[4])
cairo_fill(cr)
i_end=(((ed)-(sd))/(scale))*(value)
for i=1,i_end do
position1=((sd)*(math.pi/180))+((i-2)*(math.pi/180))
position2=((sd)*(math.pi/180))+(i*(math.pi/180))
alpha=(1/i_end)*i
cairo_arc(cr,x,y,(outer),position1,position2)
cairo_arc_negative(cr,x,y,(inner),position2,position1)
cairo_close_path(cr)
	if (value) > (alert_level) then
	cairo_set_source_rgba(cr,(ac[1]),(ac[2]),(ac[3]),alpha)
	else
	cairo_set_source_rgba(cr,(ic[1]),(ic[2]),(ic[3]),alpha)
	end
cairo_fill(cr)
end--for end
cairo_arc(cr,x,y,(outer),((sd)*(math.pi/180)),((ed)*(math.pi/180)))
cairo_arc_negative(cr,x,y,(inner),((ed)*(math.pi/180)),((sd)*(math.pi/180)))
cairo_close_path(cr)
cairo_set_source_rgba(cr,br[1],br[2],br[3],br[4])
cairo_stroke(cr)
end--function end
function transition_arc_reverse(x,y,outer,inner,sd,ed,value,scale,bg,br,ic,alert_level,ac)
if (value) == nil then value=0 end
cairo_set_line_width(cr,2)
cairo_arc(cr,x,y,(outer),((sd)*(math.pi/180)),((ed)*(math.pi/180)))
cairo_arc_negative(cr,x,y,(inner),((ed)*(math.pi/180)),((sd)*(math.pi/180)))
cairo_close_path(cr)
cairo_set_source_rgba(cr,bg[1],bg[2],bg[3],bg[4])
cairo_fill(cr)
i_end=((sd-ed)/(scale))*(value)
for i=1,i_end do
position1=((ed)*(math.pi/180))-((i+1)*(math.pi/180))
position2=((ed)*(math.pi/180))-(i*(math.pi/180))
alpha=(1/i_end)*i
cairo_arc(cr,x,y,(outer),position1,position2)
cairo_arc_negative(cr,x,y,(inner),position2,position1)
cairo_close_path(cr)
	if (value) > (alert_level) then
	cairo_set_source_rgba(cr,(ac[1]),(ac[2]),(ac[3]),alpha)
	else
	cairo_set_source_rgba(cr,(ic[1]),(ic[2]),(ic[3]),alpha)
	end
cairo_fill(cr)
end--for end
cairo_arc(cr,x,y,(outer),((sd)*(math.pi/180)),((ed)*(math.pi/180)))
cairo_arc_negative(cr,x,y,(inner),((ed)*(math.pi/180)),((sd)*(math.pi/180)))
cairo_close_path(cr)
cairo_set_source_rgba(cr,br[1],br[2],br[3],br[4])
cairo_stroke(cr)
end--function end
function transition_bar(x,y,l,h,scale,input,ic,br,bg)
cairo_set_line_width(cr,2)
cairo_arc(cr,x,y,(h/2),(90*(math.pi/180)),(270*(math.pi/180)))
cairo_arc(cr,(x+l),y,(h/2),(270*(math.pi/180)),(90*(math.pi/180)))
cairo_close_path(cr)
	if bg ~= nil then
	cairo_set_source_rgba(cr,bg[1],bg[2],bg[3],bg[4])
	else
	cairo_set_source_rgba(cr,.25,.25,.25,.5)
	end
cairo_fill(cr)
i_end=l/100*input
for i = 1,i_end do
cairo_arc(cr,x,y,(h/2),(90*(math.pi/180)),(270*(math.pi/180)))
cairo_arc(cr,(x+i),y,(h/2),(270*(math.pi/180)),(90*(math.pi/180)))
cairo_close_path(cr)
	if ic ~= nil then
	cairo_set_source_rgba(cr,ic[1],ic[2],ic[3],(ic[4]/i_end*i))
	else
	cairo_set_source_rgba(cr,.5,.5,1,(.75/i_end*i))
	end
cairo_stroke(cr)
end
cairo_set_line_width(cr,2)
cairo_arc(cr,x,y,(h/2),(90*(math.pi/180)),(270*(math.pi/180)))
cairo_arc(cr,(x+l),y,(h/2),(270*(math.pi/180)),(90*(math.pi/180)))
cairo_close_path(cr)
	if br ~= nil then
	cairo_set_source_rgba(cr,br[1],br[2],br[3],br[4])
	else
	cairo_set_source_rgba(cr,.75,.75,.75,1)
	end
cairo_stroke(cr)
end
--################################
--graphs
--################################
function bar_graph(tlx,tly,w,h,scale,data,bbrc,bbgc,brc,bgc)
--[[bar_graph(
tlx,tly,w,h,
scale,data,
bbrc,
bbgc,
brc,
bgc
)]]
if bgc ~= nil then
cairo_set_line_width(cr,2)
cairo_rectangle(cr,tlx,tly,w,h)
cairo_set_source_rgba(cr,bgc[1],bgc[2],bgc[3],bgc[4])
cairo_fill(cr)
end
for i = 1,#data do
xi=w/(#data*2+1)
yi=h/scale*data[i]
cairo_rectangle(cr,((tlx+xi)+(xi*((i-1)*2))),(tly+h),xi,-yi)
cairo_set_source_rgba(cr,bbg[1],bbg[2],bbg[3],bbg[4])
cairo_fill_preserve(cr)
cairo_set_source_rgba(cr,bbr[1],bbr[2],bbr[3],bbr[4])
cairo_stroke(cr)
end
if brc ~= nil then
cairo_rectangle(cr,tlx,tly,w,h)
cairo_set_source_rgba(cr,brc[1],brc[2],brc[3],brc[4])
cairo_stroke(cr)
end
end--function
function bar_graphH(tlx,tly,w,size,scale,table_data,bbgc,bbrc,brc,bgc)
--[[tlx=20 ; tly=20
w=100 ; size=4
scale=100
table_data={}
for i = 1,tonumber(conky_mount(1,"total")) do table_data[i]=conky_mount_usep(i) end
bbgc={0,0,0,1}
bbrc={0,1,0,1}
bar_graphH(tlx,tly,w,size,scale,table_data,bbgc,bbrc)]]
if bgc ~= nil then
cairo_set_line_width(cr,2)
cairo_rectangle(cr,tlx,tly,w,(size*2*#table_data+size))
cairo_set_source_rgba(cr,bgc[1],bgc[2],bgc[3],bgc[4])
cairo_fill(cr)
end--if
for i = 1,#table_data do
cairo_set_line_width(cr,2)
cairo_rectangle(cr,tlx,((tly+size)+(size*((i-1)*2))),(w/scale*table_data[i]),size)
cairo_set_source_rgba(cr,bbgc[1],bbgc[2],bbgc[3],bbgc[4])
cairo_fill_preserve(cr)
cairo_set_source_rgba(cr,bbrc[1],bbrc[2],bbrc[3],bbrc[4])
cairo_stroke(cr)
end--for
if brc ~= nil then
cairo_set_line_width(cr,2)
cairo_rectangle(cr,tlx,tly,w,(size*2*#table_data+size))
cairo_set_source_rgba(cr,brc[1],brc[2],brc[3],brc[4])
cairo_stroke(cr)
end--if
end--function
function graph(tlx,tly,w,h,lw,lc,table_length,data,scale,fc)
--[[cpu_table(table_length)
graph(
--tlx,tly,w,h,
20,20,150,60,
--lw,lc,
2,{1,1,1,1},
--table_length,data,scale,
10,cpu_avg_table,100
--outline,fc
)]]
cairo_set_source_rgba(cr,.1,.1,.1,1)
cairo_rectangle(cr,tlx,tly,w,h)
cairo_fill(cr)
cairo_set_line_width(cr,lw)
cairo_move_to(cr,(tlx+w),(tly+h))
for i = 1,#data do cairo_line_to(cr,((tlx+w)-(w/(table_length+1)*i)),((tly+h)-(h/scale*data[i]))) end
cairo_line_to(cr,tlx,(tly+h))
if fc ~= nil then cairo_set_source_rgba(cr,fc[1],fc[2],fc[3],fc[4]) ; cairo_fill_preserve(cr) end
cairo_set_source_rgba(cr,lc[1],lc[2],lc[3],lc[4])
cairo_stroke(cr)
cairo_set_line_width(cr,2)
cairo_set_source_rgba(cr,.5,.5,.5,1)
for i = 1,4 do cairo_move_to(cr,tlx,(tly+(h/5*i))) ; cairo_line_to(cr,(tlx+(w/(table_length+1))),(tly+(h/5*i))) ; cairo_stroke(cr) end
cairo_set_line_width(cr,4)
cairo_set_source_rgba(cr,.5,.5,.5,1)
cairo_rectangle(cr,(tlx-2),(tly-2),(w+2),(h+2))
cairo_stroke(cr)
end
function graph_background(tlx,tly,w,h,scale,interval,lc,brc,bgc)
if bgc ~= nil then
cairo_rectangle(cr,tlx,tly,w,h)
cairo_set_source_rgba(cr,bgc[1],bgc[2],bgc[3],bgc[4])
cairo_fill(cr)
end
for i = 1,(scale/interval) do
cairo_move_to(cr,tlx,((tly+h)-((h/scale)*(interval*i))))
cairo_line_to(cr,(tlx+w),((tly+h)-((h/scale)*(interval*i))))
cairo_set_source_rgba(cr,lc[1],lc[2],lc[3],lc[4])
cairo_stroke(cr)
end
if brc ~= nil then
cairo_rectangle(cr,tlx,tly,w,h)
cairo_set_source_rgba(cr,brc[1],brc[2],brc[3],brc[4])
cairo_stroke(cr)
end
end
function graph_line(tlx,tly,w,h,lw,lc,table_length,data,scale,fc,outline)
if lw == nil then lw=2 end ; if lc == nil then lc={1,1,1,1} end
if data == nil then print("Error:","data=nil") end
if outline == 1 then
cairo_set_line_width(cr,2)
cairo_set_source_rgba(cr,1,1,1,1)
cairo_rectangle(cr,tlx,tly,w,h)
cairo_stroke(cr)
end
cairo_set_line_width(cr,lw)
cairo_move_to(cr,(tlx+w),(tly+h))
for i = 1,#data do cairo_line_to(cr,((tlx+w)-(w/(table_length+1)*i)),((tly+h)-(h/scale*data[i]))) end
cairo_line_to(cr,tlx,(tly+h))
if fc ~= nil then cairo_set_source_rgba(cr,fc[1],fc[2],fc[3],fc[4]) ; cairo_fill_preserve(cr) end
cairo_set_source_rgba(cr,lc[1],lc[2],lc[3],lc[4])
cairo_stroke(cr)
end
function scope(x,y,w,table_data,table_length)
alt_table(table_length)
interval=w*2/(table_length+1)
h=w/2
cairo_set_line_width(cr,2)
cairo_arc(cr,x,y,w,0,(360*(math.pi/180)))
cairo_set_source_rgba(cr,.05,.1,.05,1)
cairo_fill(cr)
cairo_move_to(cr,(x-w),y)
for i = 1,tl do
cairo_line_to(cr,((x-w)+(interval*(i))),(y+(h/100*table_data[i])*alternating_table[i]))
end
cairo_line_to(cr,(x+w),y)
cairo_set_source_rgba(cr,0,.6,0,1)
cairo_stroke(cr)
cairo_set_line_width(cr,2)
cairo_arc(cr,x,y,w,0,(360*(math.pi/180)))
cairo_set_source_rgba(cr,.5,.5,.5,1)
cairo_stroke(cr)
end
function system_graph(tlx,tly,w,h,lw,table_length,interval,cores)
local updates=tonumber(conky_parse("${updates}"))
	if cores == nil then cores=1 end
	if updates < 10 then conky_start=1 else conky_start=nil end
	if timer == nil then timer=60 end
cpu_strings(cores) ; mem_strings() ; swap_strings()
timer=(updates % interval)
	if timer==0 or conky_start==1 then
	cpu_tables(table_length,cores)
	mem_table(table_length)
	swap_table(table_length)
	end
scale=100
vals={cpu_avg_table}
c={{.7,.7,1,1}}
	if cores >= 2 then
	vals[2]=cpu_1_table ; c[2]={.6,.6,1,1}
	vals[3]=cpu_2_table ; c[3]={.5,.5,1,1}
	end
	if cores >= 3 then vals[4]=cpu_3_table ; c[4]={.4,.4,1,1} end
	if cores >= 4 then vals[5]=cpu_4_table ; c[5]={.3,.3,1,1} end
vals[(#vals+1)]=mem_perc_table ; c[(#c+1)]={1,0,0,1}
vals[(#vals+1)]=swap_perc_table ; c[(#c+1)]={0,1,0,1}
for i = 1,#vals do graph_line(tlx,tly,w,h,lw,c[(#vals-(i-1))],table_length,vals[(#vals-(i-1))],scale) end
text((tlx+3),(tly+10),"step = "..interval.."",10)
end--function
--################################
--objects
--################################
function loading()
local updates=tonumber(conky_parse('${updates}'))
if updates == 1 then text(20,20,"loading.") end
if updates == 2 then text(20,20,"loading..") end
if updates == 3 then text(20,20,"loading...") end
if updates == 4 then text(20,20,"loading....") end
if updates == 5 then text(20,20,"loading.....") end
return ""
end
function usb(tlx,tly,mount,size,used,usedp,io)
--################################
--# nil prevention
--################################
if tlx == nil then tlx=50 end
if tly == nil then tly=50 end
if mount == nil then mount="broken" ; print("Error:","check mount input") end
if size == nil then size="broken" ; print("Error:","check size input") end
if used == nil then used="broken" ; print ("Error:","check used input") end
if usedp == nil then usedp=0 ; print("Error:","check used percent input") end
if io == nil then io=0 ; print("Error:","check io input") end
--################################
--colors
border={1,1,1,1}
fill={.1,.1,.1,.75}
fill2={.8,.8,.8,.75}
fill3={.5,.5,.5,.5}
gborder={.5,.5,1,1}
gfill={.5,.5,1,.5}
gbackground={0,0,0,1}
text={.8,.8,.8,1}
indicatorb1={.7,.7,.7,1}
indicatorf1={1,1,1,.3}
indicatorb2={0,.75,0,1}
indicatorf2={0,1,0,.25}
--port
hp=30 ; wp=30
--main body
hb=40 ; wb=150
--3d
offset3d=5
--gauge
gw=15
--port back
cairo_set_line_width(cr,2)
cairo_rectangle(cr,(tlx+offset3d),(tly+5),wp,hp)
cairo_set_source_rgba(cr,fill[1],fill[2],fill[3],fill[4])
cairo_fill_preserve(cr)
cairo_set_source_rgba(cr,border[1],border[2],border[3],border[4])
cairo_stroke(cr)
--main body back
cairo_rectangle(cr,(tlx+offset3d+wp),tly,150,40)
cairo_set_source_rgba(cr,fill[1],fill[2],fill[3],fill[4])
cairo_fill_preserve(cr)
cairo_set_source_rgba(cr,border[1],border[2],border[3],border[4])
cairo_stroke(cr)
--3d lines
x3d1={tlx,(tlx+wp),(tlx+wp+wb),(tlx+wp+wb),(tlx+wp),(tlx)}
y3d1={(tly+offset3d+5),(tly+offset3d),(tly+offset3d),(tly+offset3d+hb),(tly+offset3d+hb),(tly+offset3d+hp+5)}
x3d2={(tlx+offset3d),(tlx+offset3d+wp),(tlx+offset3d+wp+wb),(tlx+offset3d+wp+wb),(tlx+offset3d+wp),(tlx+offset3d)}
y3d2={(tly+5),tly,tly,(tly+hb),(tly+hb),(tly+hp+5)}
for i = 1,#x3d1 do
cairo_move_to(cr,x3d1[i],y3d1[i])
cairo_line_to(cr,x3d2[i],y3d2[i])
cairo_set_source_rgba(cr,border[1],border[2],border[3],border[4])
cairo_stroke(cr)
end
--indicator
cairo_arc(cr,(tlx+offset3d+wp+wb-6),(tly+(hb/2)),(hb/3),(300*(math.pi/180)),(60*(math.pi/180)))
cairo_close_path(cr)
	if io ~= "0B" then
	cairo_set_source_rgba(cr,indicatorf2[1],indicatorf2[2],indicatorf2[3],indicatorf2[4])
	cairo_fill_preserve(cr)
	cairo_set_source_rgba(cr,indicatorb2[1],indicatorb2[2],indicatorb2[3],indicatorb2[4])
	else
	cairo_set_source_rgba(cr,indicatorf1[1],indicatorf1[2],indicatorf1[3],indicatorf1[4])
	cairo_fill_preserve(cr)
	cairo_set_source_rgba(cr,indicatorb1[1],indicatorb1[2],indicatorb1[3],indicatorb1[4])
	end
cairo_stroke(cr)
cairo_arc(cr,(tlx+offset3d+wp+wb-6),(tly+(hb/2)),(hb/3),(300*(math.pi/180)),(60*(math.pi/180)))
cairo_arc_negative(cr,(tlx+wp+wb-6),(tly+offset3d+(hb/2)),(hb/3),(60*(math.pi/180)),(300*(math.pi/180)))
cairo_close_path(cr)
	if io ~= "0B" then
	cairo_set_source_rgba(cr,indicatorf2[1],indicatorf2[2],indicatorf2[3],indicatorf2[4])
	cairo_fill_preserve(cr)
	cairo_set_source_rgba(cr,indicatorb2[1],indicatorb2[2],indicatorb2[3],indicatorb2[4])
	else
	cairo_set_source_rgba(cr,indicatorf1[1],indicatorf1[2],indicatorf1[3],indicatorf1[4])
	cairo_fill_preserve(cr)
	cairo_set_source_rgba(cr,indicatorb1[1],indicatorb1[2],indicatorb1[3],indicatorb1[4])
	end
cairo_stroke(cr)
cairo_arc(cr,(tlx+wp+wb-6),(tly+offset3d+(hb/2)),(hb/3),(300*(math.pi/180)),(60*(math.pi/180)))
cairo_close_path(cr)
	if io ~= "0B" then
	cairo_set_source_rgba(cr,indicatorf2[1],indicatorf2[2],indicatorf2[3],indicatorf2[4])
	cairo_fill_preserve(cr)
	cairo_set_source_rgba(cr,indicatorb2[1],indicatorb2[2],indicatorb2[3],indicatorb2[4])
	else
	cairo_set_source_rgba(cr,indicatorf1[1],indicatorf1[2],indicatorf1[3],indicatorf1[4])
	cairo_fill_preserve(cr)
	cairo_set_source_rgba(cr,indicatorb1[1],indicatorb1[2],indicatorb1[3],indicatorb1[4])
	end
cairo_stroke(cr)
--port front
cairo_rectangle(cr,tlx,(tly+offset3d+5),wp,hp)
cairo_set_source_rgba(cr,fill2[1],fill2[2],fill2[3],fill2[4])
cairo_fill_preserve(cr)
cairo_set_source_rgba(cr,border[1],border[2],border[3],border[4])
cairo_stroke(cr)
--main body front
cairo_rectangle(cr,(tlx+30),(tly+offset3d),150,40)
cairo_set_source_rgba(cr,fill3[1],fill3[2],fill3[3],fill3[4])
cairo_fill_preserve(cr)
cairo_set_source_rgba(cr,border[1],border[2],border[3],border[4])
cairo_stroke(cr)
--use gauge
gx=wp ; gy=hb/4
gl=110
gi=(gl/100)*usedp
--gauge background
cairo_move_to(cr,(tlx+gx),(tly+offset3d+gy))
cairo_arc(cr,(tlx+gx+gl),(tly+offset3d+gy+(gw/2)),(gw/2),(270*(math.pi/180)),(90*(math.pi/180)))
cairo_line_to(cr,(tlx+gx),(tly+offset3d+gy+gw))
cairo_close_path(cr)
cairo_set_source_rgba(cr,gbackground[1],gbackground[2],gbackground[3],gbackground[4])
cairo_fill(cr)
--use indicator
cairo_move_to(cr,(tlx+gx),(tly+offset3d+gy))
cairo_arc(cr,(tlx+gx+gi),(tly+offset3d+gy+(gw/2)),(gw/2),(270*(math.pi/180)),(90*(math.pi/180)))
cairo_line_to(cr,(tlx+gx),(tly+offset3d+gy+gw))
cairo_close_path(cr)
cairo_set_source_rgba(cr,gfill[1],gfill[2],gfill[3],gfill[4])
cairo_fill_preserve(cr)
cairo_set_source_rgba(cr,gborder[1],gborder[2],gborder[3],gborder[4])
cairo_stroke(cr)
--gauge border
cairo_move_to(cr,(tlx+gx),(tly+offset3d+gy))
cairo_arc(cr,(tlx+gx+gl),(tly+offset3d+gy+(gw/2)),(gw/2),(270*(math.pi/180)),(90*(math.pi/180)))
cairo_line_to(cr,(tlx+gx),(tly+offset3d+gy+gw))
cairo_close_path(cr)
cairo_set_source_rgba(cr,border[1],border[2],border[3],border[4])
cairo_stroke(cr)
--text
offsett=10
x={(tlx+offsett+wp),(tlx+offsett+wp),(tlx+offsett+wp+gl)}
y={(tly+offset3d+21),(tly+offset3d+36),(tly+offset3d+21)}
t={mount,""..used.." / "..size .."",""..usedp.."%"}
for i = 1,#t do
cairo_set_source_rgba(cr,text[1],text[2],text[3],text[4])
cairo_move_to(cr,x[i],y[i])
cairo_show_text(cr,t[i])
cairo_stroke(cr)
end--text
end--fuction
function warning_triangle(x,y,w,s)
if s ~= "off" then s="on" end
cairo_set_line_width(cr,2)
if s == "off" then cairo_set_source_rgba(cr,black[1],black[2],black[3],black[4]) else cairo_set_source_rgba(cr,red[1],red[2],red[3],red[4]) end
cairo_move_to(cr,(x+(w/2)),y) ; cairo_line_to(cr,x,(y+w)) ; cairo_line_to(cr,(x+w),(y+w))
cairo_close_path(cr)
cairo_stroke(cr)
p1=w/6 ; p2=p1*4 ; p3=p1*5
cairo_move_to(cr,(x+(w/2)),(y+(p1*2))) ; cairo_line_to(cr,(x+(w/2)),(y+p2))
cairo_close_path(cr)
cairo_stroke(cr)
cairo_move_to(cr,(x+(w/2)),(y+p3)) ; cairo_line_to(cr,(x+(w/2)),(y+(p1*5.5)))
cairo_close_path(cr)
cairo_stroke(cr)
end--function warning_triangle(x,y,w)
--################################
--tables
--################################
function alt_table(table_length)
if table_length == nil then table_length=10 end
if alternating_table == nil then alternating_table={} end
for i = 1,table_length do if alternating_table[i] == nil then alternating_table[i]=1 end end
if alternating_table[table_length] == 1 then alternating=-1 else if alternating_table[table_length] == -1 then alternating=1 end end
for i = 1,table_length do
if alternating_table[i+1]==nil then alternating_table[i+1]=1 end
alternating_table[i]=alternating_table[i+1]
if i==table_length then alternating_table[i]=alternating end
if alternating_table[table_length] == nil then alternating_table[table_length]=1 end
end
end
function cpu_tables(table_length,cores)
if table_length == nil then table_length=10 end
if cores == nil then cores=1 end
--avg
if cores >= 1 then
if cpu_avg == nil then cpu_avg=0 ; print("Error:","cpu_avg=nil") end
if cpu_avg_table == nil then cpu_avg_table={} end
for i = 1, tonumber(table_length) do
            if cpu_avg_table[i+1]==nil then cpu_avg_table[i+1]=0 end
cpu_avg_table[i]=cpu_avg_table[i+1]
            if i==table_length then
            cpu_avg_table[table_length]=cpu_avg
            end
end
for i = 1,table_length do if cpu_avg_table[i] == nil then cpu_avg_table[i]=0 end end
end--avg
--cpu_1
if cores >= 2 then
if cpu_1 == nil then cpu_1=0 ; print("Error:","cpu_1=nil") end
if cpu_1_table == nil then cpu_1_table={} end
for i = 1, tonumber(table_length) do
            if cpu_1_table[i+1]==nil then cpu_1_table[i+1]=0 end
cpu_1_table[i]=cpu_1_table[i+1]
            if i==table_length then
            cpu_1_table[table_length]=cpu_1
            end
end
for i = 1,table_length do if cpu_1_table[i] == nil then cpu_1_table[i]=0 end end
end
--cpu_2
if cores >= 2 then
if cpu_2 == nil then cpu_2=0 ; print("Error:","cpu_2=nil") end
if cpu_2_table == nil then cpu_2_table={} end
for i = 1, tonumber(table_length) do
            if cpu_2_table[i+1]==nil then cpu_2_table[i+1]=0 end
cpu_2_table[i]=cpu_2_table[i+1]
            if i==table_length then
            cpu_2_table[table_length]=cpu_2
            end
end
for i = 1,table_length do if cpu_2_table[i] == nil then cpu_2_table[i]=0 end end
end
--cpu_3
if cores >= 3 then
if cpu_3 == nil then cpu_3=0 ; print("Error:","cpu_3=nil") end
if cpu_3_table == nil then cpu_3_table={} end
for i = 1, tonumber(table_length) do
            if cpu_3_table[i+1]==nil then cpu_3_table[i+1]=0 end
cpu_3_table[i]=cpu_3_table[i+1]
            if i==table_length then
            cpu_3_table[table_length]=cpu_3
            end
end
for i = 1,table_length do if cpu_3_table[i] == nil then cpu_3_table[i]=0 end end
end
--cpu_4
if cores >= 4 then
if cpu_4 == nil then cpu_4=0 ; print("Error:","cpu_4=nil") end
if cpu_4_table == nil then cpu_4_table={} end
for i = 1, tonumber(table_length) do
            if cpu_4_table[i+1]==nil then cpu_4_table[i+1]=0 end
cpu_4_table[i]=cpu_4_table[i+1]
            if i==table_length then
            cpu_4_table[table_length]=cpu_4
            end
end
for i = 1,table_length do if cpu_4_table[i] == nil then cpu_4_table[i]=0 end end
end
end--cpu_tables
function eth0_table(table_length)
if table_length == nil then table_length=10 end
if eth0_down_table == nil then eth0_down_table={} end
if eth0_up_table == nil then eth0_up_table={} end
for i = 1,table_length do if eth0_down_table[i] == nil then eth0_down_table[i]=0 end end
for i = 1,table_length do if eth0_up_table[i] == nil then eth0_up_table[i]=0 end end
if eth0_down == nil then eth0_down=0 end
for i = 1, tonumber(table_length) do
            if eth0_down_table[i+1]==nil then eth0_down_table[i+1]=0 end
eth0_down_table[i]=eth0_down_table[i+1]
            if i==table_length then
            eth0_down_table[table_length]=eth0_down
            end
end
if eth0_up == nil then eth0_up=0 end
for i = 1, tonumber(table_length) do
            if eth0_up_table[i+1]==nil then eth0_up_table[i+1]=0 end
eth0_up_table[i]=eth0_up_table[i+1]
            if i==table_length then
            eth0_up_table[table_length]=eth0_up
            end
end
end
function mem_table(table_length)
if mem_perc == nil then mem_perc=0 ; print("Error:","mem_perc=nil") end
if mem_perc_table == nil then mem_perc_table={} end
for i = 1, tonumber(table_length) do
            if mem_perc_table[i+1]==nil then mem_perc_table[i+1]=0 end
mem_perc_table[i]=mem_perc_table[i+1]
            if i==table_length then
            mem_perc_table[table_length]=mem_perc
            end
end
end--function
function net_down_table(table_length)
if table_length == nil then table_length=10 end
if down_table == nil then down_table={} end
for i = 1,table_length do if down_table[i] == nil then down_table[i]=0 end end
if down == nil then down=0 end
for i = 1, tonumber(table_length) do
            if down_table[i+1]==nil then down_table[i+1]=0 end
down_table[i]=down_table[i+1]
            if i==table_length then
            down_table[table_length]=down_value
            end
end
return down_table
end
function net_up_table(table_length)
if table_length == nil then table_length=10 end
if up_table == nil then up_table={} end
for i = 1,table_length do if up_table[i] == nil then up_table[i]=0 end end
if up == nil then up=0 end
for i = 1, tonumber(table_length) do
            if up_table[i+1]==nil then up_table[i+1]=0 end
up_table[i]=up_table[i+1]
            if i==table_length then
            up_table[table_length]=up_value
            end
end
return up_table
end
function swap_table(table_length)
if swap_perc == nil then swap_perc=0 ; print("Error:","swap_perc=nil") end
if swap_perc_table == nil then swap_perc_table={} end
for i = 1, tonumber(table_length) do
            if swap_perc_table[i+1]==nil then swap_perc_table[i+1]=0 end
swap_perc_table[i]=swap_perc_table[i+1]
            if i==table_length then
            swap_perc_table[table_length]=swap_perc
            end
end
end--function
function wlan0_table(table_length)
if table_length == nil then table_length=10 end
if wlan0_down_table == nil then wlan0_down_table={} end
if wlan0_up_table == nil then wlan0_up_table={} end
for i = 1,table_length do if wlan0_down_table[i] == nil then wlan0_down_table[i]=0 end end
for i = 1,table_length do if wlan0_up_table[i] == nil then wlan0_up_table[i]=0 end end
if wlan0_down == nil then wlan0_down=0 end
for i = 1, tonumber(table_length) do
            if wlan0_down_table[i+1]==nil then wlan0_down_table[i+1]=0 end
wlan0_down_table[i]=wlan0_down_table[i+1]
            if i==table_length then
            wlan0_down_table[table_length]=wlan0_down
            end
end
if wlan0_up == nil then wlan0_up=0 end
for i = 1, tonumber(table_length) do
            if wlan0_up_table[i+1]==nil then wlan0_up_table[i+1]=0 end
wlan0_up_table[i]=wlan0_up_table[i+1]
            if i==table_length then
            wlan0_up_table[table_length]=wlan0_up
            end
end
end
--################################
--strings
--################################
function misc_strings()
month_days={31,28,31,30,31,30,31,31,30,31,30,31}
end

--################################
--################################

--################################
--mrpeachy
--################################
function mrpeachy_pt(px,py,prad,pdeg)
local ppo=(math.pi/180)*pdeg
local px1=px+prad*(math.sin(ppo))
local py1=py-prad*(math.cos(ppo))
return px1,py1
end
function mrpeachy_font(fontt)
local name=fontt.f	or default_font_name	or "mono"
local size=fontt.fs	or default_font_size	or 12
local face=fontt.ff	or default_font_face	or "n"
if face=="n" then
cairo_select_font_face(cr,name,CAIRO_FONT_SLANT_NORMAL,CAIRO_FONT_WEIGHT_NORMAL)
	elseif face=="b" then
	cairo_select_font_face(cr,name,CAIRO_FONT_SLANT_NORMAL,CAIRO_FONT_WEIGHT_BOLD)
		elseif face=="i" then
		cairo_select_font_face(cr,name,CAIRO_FONT_SLANT_ITALIC,CAIRO_FONT_WEIGHT_NORMAL)
			elseif face=="bi" then
			cairo_select_font_face(cr,name,CAIRO_FONT_SLANT_ITALIC,CAIRO_FONT_WEIGHT_BOLD)
end
cairo_set_font_size(cr,size)
end
function mrpeachy_hexcolor(hexcolort)
local col=hexcolort.c	or default_hex_color	or 0xffffff
local a=hexcolort.a	or default_alpha	or 1
local r,g,b=((col/0x10000) % 0x100)/255,((col/0x100) % 0x100)/255,(col % 0x100)/255
cairo_set_source_rgba(cr,r,g,b,a)
end
function mrpeachy_text(textt)
local x=textt.x 		or 100
local y=textt.y 		or 100
local t=textt.t 		or "set txt"
local hj=textt.hj 		or default_horizontal_justify		or "l"
local vj=textt.vj 		or default_vertical_justify		or "n"
local r=textt.r			or default_rotation			or 0
cairo_text_extents(cr,t,extents)
local wx=extents.x_advance
local wd=extents.width
local hy=extents.height
local bx=extents.x_bearing
local by=extents.y_bearing+hy
--hl-- l=left, c=center, r=right
if hj=="l" then
xa=x-bx
rad=0
elseif hj=="c" then
xa=x-((wx-bx)/2)-bx
rad=(wx-bx)/2
elseif hj=="r" then
xa=x-wx
rad=wx-bx
else
print ('hj not set correctly for text: '..t..' - "l", "c" or "r"')
xa=0
rad=0
end
--vj-- n=normal, nb=normal-ybearing, m=middle, mb=middle-ybearing, t=top
if vj=="n" then
ya=y
rad2=0
ry=by
elseif vj=="nb" then
ya=y-by
rad2=-by
ry=by
elseif vj=="m" then
ya=y+((hy-by)/2)
rad2=((hy-by)/2)
ry=((hy-by)/2)-by
elseif vj=="mb" then
ya=y+(hy/2)-by
rad2=(hy/2)-by
ry=((hy-by)/2)-by
elseif vj=="t" then
ya=y+hy-by
rad2=hy-by
ry=0+by
else
print ('vj not set correctly for text: '..t..' - "n", "nb", "m", "mb" or "t"')
ya=0
rad2=0
ry=0
end
--rotation
if r~=0 then
local x2,y2=pt(x,y,rad2,r-180)
local x1,y1=pt(x2,y2,rad,r-90)
cairo_save (cr)
cairo_translate (cr,x1,y1)
cairo_rotate(cr,(math.pi/180)*r)
cairo_show_text (cr,t)
cairo_stroke (cr)
cairo_restore (cr)
else
cairo_move_to (cr,xa,ya)
cairo_show_text (cr,t)
cairo_stroke (cr)
end--if ro
--set non local variables to nil
xa=nil;ya=nil;rad=nil;rad2=nil;ry=nil
end
function mrpeachy_rgbcolor(rgbcolort)
local r=rgbcolort.r		or default_red			or 1
local g=rgbcolort.g		or default_green		or 1
local b=rgbcolort.b		or default_blue			or 1
local a=rgbcolort.a		or default_alpha		or 1
cairo_set_source_rgba(cr,r,g,b,a)
end
function mrpeachy_adeg(deg)
return(math.pi/180)*(deg-90)
end
--################################
--################################
--sort
--################################
--################################

WOWWWWW

AMAZING!
REALLY AWESOME

Offline

#7459 2014-05-08 23:00:43

Marenbraga
Member
Registered: 2013-11-14
Posts: 40

Re: Conky v1.9 Thread

Guys,
I have a basic and easy question about that command:   ${exec lshw -c memory | grep clock: | tail -n 3}

How do I separate the command result on individual lines? I need to put them aligned right, but this command only allows this  with the first line.

Does anyone know how should I proceed?

Offline

#7460 2014-05-08 23:37:32

Sector11
#!'er to BL'er
From: SR11 Cockpit
Registered: 2010-05-05
Posts: 15,667
Website

Re: Conky v1.9 Thread

Welcome back ... and talk about coming back in full style!  Those are ... AWESOME!


·  ↓   ↓   ↓   ↓   ↓   ↓  ·
BunsenLabs Forums now Open for Registration
·  ↑   ↑   ↑   ↑   ↑   ↑  · BL ModSquad

Offline

#7461 2014-05-09 10:21:59

easysid
#! CrunchBanger
From: India
Registered: 2013-01-25
Posts: 150

Re: Conky v1.9 Thread

mrpeachy wrote:

:
i wonder where they are getting those different numbers!
:

Try using

amixer -M 

This will give the mapped values like alsamixer.

Offline

#7462 2014-05-09 10:32:06

ansem_of_nexus
#! CrunchBanger
Registered: 2012-09-19
Posts: 234

Re: Conky v1.9 Thread

So I final started on the display section of Functions. up first is the gauges.
2014_05_09_1399626595_1600x900_scrot.jpg
I beleive that all but one of these gauges were on the last Functions I uploaded, if not then they will be on the next upload. the one that I know was not in the upload was text_as_gauge.

text_as_gauge is sort of odd. you have to enter the text one letter at a time into a table then it prints out as the color the input value decides.

here is a quick copy:

--[[paste into conky_main
text_as_guage(
	--(x,y,
	20,20,
	--t,
	{"e","x","a","m","p","l","e","s"},
	--scale,input,
	60,(tonumber(conky_parse("${time %S}"))),
	--normal,use,alert,
	{.8,.8,.8,1},{0,1,0,1},{1,0,0,1},
	--size)
	16)
]]
--######################################
function text_as_guage(x,y,t,scale,input,normal,use,alert,size)--5/8/14
--t={"e","x","a","m","p","l","e"}
if size == nil then size=13 end
for i = 1,#t do
if i <= (#t/scale*input) then
	if input >= (scale/4*3) then
	c=alert
	else
	c=use
	end
else
c=normal
end
text((x+((size/1.5)*(i-1))),y,t[i],size,c)
end--for
end--function
function text(x,y,t,s,c)
if s ~= nil then cairo_set_font_size (cr,s) end
if c ~= nil then cairo_set_source_rgba (cr,c[1],c[2],c[3],c[4]) else cairo_set_source_rgba (cr,.8,.8,.8,1) end
cairo_move_to (cr,x,y)
cairo_show_text (cr,t)
cairo_stroke (cr)
end

You can find my work here

Make everything ok button

Offline

#7463 2014-05-09 14:03:10

Avreml
Member
From: Leipzig, Germany
Registered: 2014-05-09
Posts: 28
Website

Re: Conky v1.9 Thread

Hey there!

I'm a Linux newbie and discovered crunchbang to be my favourite distro!

I had not much problems yet and even this one is not a too big issue.
But I would be glad if anyone could help: I was trying to install wineasio and did a lot of installs and auto-removals.
When i restarted, all of a sudden, my background was gone, also my tint2 menu and my conky.
Background and tint2 are back now (tint2 seems to be it had been uninstalled - i reinstalled it). But my conky is still gone.
If i take a look into the task manager, its running - so it must be a background layer problem?

Thanks in advance!

Last edited by Avreml (2014-05-10 18:31:19)

Offline

#7464 2014-05-09 16:08:33

Sector11
#!'er to BL'er
From: SR11 Cockpit
Registered: 2010-05-05
Posts: 15,667
Website

Re: Conky v1.9 Thread

@ Avreml

Welcome to #!.

I doubt this is a 'conky' problem so much as maybe something changed regarding the background.

Are you using the default #! conky at: ~/.conkyrc - even if you edited it?

If yes, try this in a terminal once you are running:

killall conky && conky &

does that bring up the conky?


·  ↓   ↓   ↓   ↓   ↓   ↓  ·
BunsenLabs Forums now Open for Registration
·  ↑   ↑   ↑   ↑   ↑   ↑  · BL ModSquad

Offline

#7465 2014-05-09 23:54:24

pandroidanaroid
Member
Registered: 2014-02-22
Posts: 19

Re: Conky v1.9 Thread

I just want a simple countdown timer in conky.

I managed to get exactly what I want in a bash script. This is the code in my .bashrc:

function countdown
{
        local OLD_IFS="${IFS}"
        IFS=":"
        local ARR=( $1 )
        local SECONDS=$((  (ARR[0] * 60 * 60) + (ARR[1] * 60) + ARR[2]  ))
        local START=$(date +%s)
        local END=$((START + SECONDS))
        local CUR=$START

        while [[ $CUR -lt $END ]]
        do
                CUR=$(date +%s)
                LEFT=$((END-CUR))

                printf "\r%02d:%02d:%02d" \
                        $((LEFT/3600)) $(( (LEFT/60)%60)) $((LEFT%60))

                sleep 1
        done
        IFS="${OLD_IFS}"
        echo "        "

Now when I type

countdown HH:MM:SS

in shell it works flawlessly and starts to count down.

I want to count down about 240 hours, it does that fine 240:00:00 starts off 239:59:59....

How do I get this to show in conky?

Thanks

Offline

#7466 2014-05-10 00:16:09

ansem_of_nexus
#! CrunchBanger
Registered: 2012-09-19
Posts: 234

Re: Conky v1.9 Thread

pandroidanaroid wrote:

I just want a simple countdown timer in conky.

I managed to get exactly what I want in a bash script. This is the code in my .bashrc:

function countdown
{
        local OLD_IFS="${IFS}"
        IFS=":"
        local ARR=( $1 )
        local SECONDS=$((  (ARR[0] * 60 * 60) + (ARR[1] * 60) + ARR[2]  ))
        local START=$(date +%s)
        local END=$((START + SECONDS))
        local CUR=$START

        while [[ $CUR -lt $END ]]
        do
                CUR=$(date +%s)
                LEFT=$((END-CUR))

                printf "\r%02d:%02d:%02d" \
                        $((LEFT/3600)) $(( (LEFT/60)%60)) $((LEFT%60))

                sleep 1
        done
        IFS="${OLD_IFS}"
        echo "        "

Now when I type

countdown HH:MM:SS

in shell it works flawlessly and starts to count down.

I want to count down about 240 hours, it does that fine 240:00:00 starts off 239:59:59....

How do I get this to show in conky?

Thanks

Here is the count down i made, it doesnt do exactly what you want but it will count down from a set time/ day. It comes out as a hh:mm:ss mm/dd/yy display, then changes to say past when finished. So if you just calculate when your 240 hours is from when you set it it should work just fine.

function count_down(y,mo,d,h,mi)
time_strings()
if y == nil then y=year end
if mo == nil then mo=month_number end
if d == nil then d=day_number end
if h == nil then h=hour24 end
if mi == nil then mi=60 end
if y ~= "text" then
s=60
y2o=y-year
mo2o=mo-month_number
d2o=d-day_number
h2o=h-hour24
mi2o=mi-minute
s2o=s-second
	if y2o < 0 then
	s2o=0 ; mi2o=0 ; h2o=0 ; d2o=0 ; mo2o=0 ; y2o=0 end
	if mo2o < 0 then if y2o <= 0 then
	s2o=0 ; mi2o=0 ; h2o=0 ; d2o=0 ; mo2o=0 ; y2o=0 end end
	if d2o < 0 then if mo2o <= 0 then if y2o <= 0 then
	s2o=0 ; mi2o=0 ; h2o=0 ; d2o=0 ; mo2o=0 ; y2o=0 end end end
	if h2o < 0 then if d2o <= 0 then if mo2o <= 0 then if y2o <= 0 then
	s2o=0 ; mi2o=0 ; h2o=0 ; d2o=0 ; mo2o=0 ; y2o=0 end end end end
	if mi2o < 0 then if h2o <= 0 then if d2o <= 0 then if mo2o <= 0 then if y2o <= 0 then
	s2o=0 ; mi2o=0 ; h2o=0 ; d2o=0 ; mo2o=0 ; y2o=0 end end end end end
	if s2o < 0 then if mi2o <= 0 then if h2o <= 0 then if d2o <= 0 then if mo2o <= 0 then if y2o <= 0 then
	s2o=0 ; mi2o=0 ; h2o=0 ; d2o=0 ; mo2o=0 ; y2o=0 end end end end end end
if y2o < 0 then y2o=0 end
if mo2o < 0 then mo2o=0 end
if d2o < 0 then d2o=0 end
if h2o < 0 then h2o=0 end
if mi2o < 0 then mi2o=0 end
if s2o < 0 then s2o=0 end
output=""..h2o..":"..mi2o..":"..s2o.."  "..mo2o.."/"..d2o.."/"..y2o..""
if output == "0:0:0  0/0/0" then output="past" end
else
output="h:mi:s  mo/d/y" end
return output
end
function time_strings()
abbr_month=conky_parse("${time %b}")
ampm=conky_parse("${time %p}")
date_mm_dd_yy=conky_parse("${time %D}")
day=conky_parse("${time %a}")
day_number=tonumber(conky_parse("${time %d}"))
minute=tonumber(conky_parse("${time %M}"))
month_number=tonumber(conky_parse("${time %m}"))
hour12=tonumber(conky_parse("${time %I}"))
hour24=tonumber(conky_parse("${time %H}"))
second=tonumber(conky_parse("${time %S}"))
time_hms12=conky_parse("${time %r}")
time_hms24=conky_parse("${time %T}")
weekday_number=tonumber(conky_parse("${time %u}"))
year=tonumber(conky_parse("${time %y}"))
year_full=tonumber(conky_parse("${time %Y}"))
end

Edit: You can cut the time_strings function out if you copy the stings that count down uses into it.

Last edited by ansem_of_nexus (2014-05-10 00:22:06)


You can find my work here

Make everything ok button

Offline

#7467 2014-05-10 00:59:32

pandroidanaroid
Member
Registered: 2014-02-22
Posts: 19

Re: Conky v1.9 Thread

ansem_of_nexus wrote:

Here is the count down i made, it doesnt do exactly what you want but it will count down from a set time/ day. It comes out as a hh:mm:ss mm/dd/yy display, then changes to say past when finished. So if you just calculate when your 240 hours is from when you set it it should work just fine.

function count_down(y,mo,d,h,mi)
time_strings()
if y == nil then y=year end
if mo == nil then mo=month_number end
if d == nil then d=day_number end
if h == nil then h=hour24 end
if mi == nil then mi=60 end
if y ~= "text" then
s=60
y2o=y-year
mo2o=mo-month_number
d2o=d-day_number
h2o=h-hour24
mi2o=mi-minute
s2o=s-second
	if y2o < 0 then
	s2o=0 ; mi2o=0 ; h2o=0 ; d2o=0 ; mo2o=0 ; y2o=0 end
	if mo2o < 0 then if y2o <= 0 then
	s2o=0 ; mi2o=0 ; h2o=0 ; d2o=0 ; mo2o=0 ; y2o=0 end end
	if d2o < 0 then if mo2o <= 0 then if y2o <= 0 then
	s2o=0 ; mi2o=0 ; h2o=0 ; d2o=0 ; mo2o=0 ; y2o=0 end end end
	if h2o < 0 then if d2o <= 0 then if mo2o <= 0 then if y2o <= 0 then
	s2o=0 ; mi2o=0 ; h2o=0 ; d2o=0 ; mo2o=0 ; y2o=0 end end end end
	if mi2o < 0 then if h2o <= 0 then if d2o <= 0 then if mo2o <= 0 then if y2o <= 0 then
	s2o=0 ; mi2o=0 ; h2o=0 ; d2o=0 ; mo2o=0 ; y2o=0 end end end end end
	if s2o < 0 then if mi2o <= 0 then if h2o <= 0 then if d2o <= 0 then if mo2o <= 0 then if y2o <= 0 then
	s2o=0 ; mi2o=0 ; h2o=0 ; d2o=0 ; mo2o=0 ; y2o=0 end end end end end end
if y2o < 0 then y2o=0 end
if mo2o < 0 then mo2o=0 end
if d2o < 0 then d2o=0 end
if h2o < 0 then h2o=0 end
if mi2o < 0 then mi2o=0 end
if s2o < 0 then s2o=0 end
output=""..h2o..":"..mi2o..":"..s2o.."  "..mo2o.."/"..d2o.."/"..y2o..""
if output == "0:0:0  0/0/0" then output="past" end
else
output="h:mi:s  mo/d/y" end
return output
end
function time_strings()
abbr_month=conky_parse("${time %b}")
ampm=conky_parse("${time %p}")
date_mm_dd_yy=conky_parse("${time %D}")
day=conky_parse("${time %a}")
day_number=tonumber(conky_parse("${time %d}"))
minute=tonumber(conky_parse("${time %M}"))
month_number=tonumber(conky_parse("${time %m}"))
hour12=tonumber(conky_parse("${time %I}"))
hour24=tonumber(conky_parse("${time %H}"))
second=tonumber(conky_parse("${time %S}"))
time_hms12=conky_parse("${time %r}")
time_hms24=conky_parse("${time %T}")
weekday_number=tonumber(conky_parse("${time %u}"))
year=tonumber(conky_parse("${time %y}"))
year_full=tonumber(conky_parse("${time %Y}"))
end

Edit: You can cut the time_strings function out if you copy the stings that count down uses into it.

I'm too stupid to figure out how to get that to work. Do I just paste it in conkyrc? What do I change to put in the time?

Thanks for your help.

Last edited by pandroidanaroid (2014-05-10 01:00:11)

Offline

#7468 2014-05-10 01:03:13

mrpeachy
20% cooler
From: The Everfree Forest
Registered: 2009-11-08
Posts: 3,460

Re: Conky v1.9 Thread

^ one suggestion, you can get time data more cheaply without using conky parse

for example:

abbr_month=os.date("%b")

and perhaps you could use if's so that you could ask the function for a specific time output, say abbr_month, and only that line is calculated an returned instead of all lines being run when the function is called

Last edited by mrpeachy (2014-05-10 01:07:12)

Offline

#7469 2014-05-10 02:41:54

pandroidanaroid
Member
Registered: 2014-02-22
Posts: 19

Re: Conky v1.9 Thread

Still clueless.  sad

Offline

#7470 2014-05-10 03:23:02

ansem_of_nexus
#! CrunchBanger
Registered: 2012-09-19
Posts: 234

Re: Conky v1.9 Thread

@pandroidanaroid it is alright. When making sure it would go to conkyrc just fine I noticed i made a small error. I will have it fixed in a little bit and post it with how to use it when i am done. Sorry


You can find my work here

Make everything ok button

Offline

#7471 2014-05-10 03:26:44

ansem_of_nexus
#! CrunchBanger
Registered: 2012-09-19
Posts: 234

Re: Conky v1.9 Thread

mrpeachy wrote:

^ one suggestion, you can get time data more cheaply without using conky parse

for example:

abbr_month=os.date("%b")

and perhaps you could use if's so that you could ask the function for a specific time output, say abbr_month, and only that line is calculated an returned instead of all lines being run when the function is called

Is os.something let steps and will reduce the conky cpu usage?


You can find my work here

Make everything ok button

Offline

#7472 2014-05-10 03:55:21

ansem_of_nexus
#! CrunchBanger
Registered: 2012-09-19
Posts: 234

Re: Conky v1.9 Thread

Ok all fixed.
first the code below needs to be saved in to a new file like count_down.lua or anything ending in .lua
second you need to copy and paste these into you conkyrc
    above TEXT in the conky settings "lua_load /path/to/file.lua"
    below TEXT "${lua count_down year month day hour minute}
third replace year, month, day, hour, and minute with the caculated time of 240 hours later

function conky_count_down(y,mo,d,h,mi)--5/9/14
hour24=tonumber(conky_parse("${time %H}"))
second=tonumber(conky_parse("${time %S}"))
day_number=tonumber(conky_parse("${time %d}"))
minute=tonumber(conky_parse("${time %M}"))
month_number=tonumber(conky_parse("${time %m}"))
year=tonumber(conky_parse("${time %y}"))
if y == nil then y=year end
if mo == nil then mo=month_number end
if d == nil then d=day_number end
if h == nil then h=hour24 end
if mi == nil then mi=minute end
s=0
if y ~= "text" then
	if s == 0 then s=59 ; mi=mi-1 end
s2o=s-second
mi2o=mi-minute
	if mi2o < 0 then mi2o=60 ; h=h-1 end
h2o=h-hour24
	if h2o < 0 then h2o=24 ; d=d-1 end
d2o=d-day_number
	if d2o < 0 then d2o=(month_days[month_number]) ; mo=mo-1 end
mo2o=mo-month_number
	if mo2o < 0 then mo2o=12 ; y=y-1 end
y2o=y-year
	if y2o < 0 then s2o=0 ; mi2o=0 ; h2o=0 ; d2o=0 ; mo2o=0 y2o=0 end
output=""..h2o..":"..mi2o..":"..s2o.."  "..mo2o.."/"..d2o.."/"..y2o..""
if output == "0:0:0  0/0/0" then output="past" end
else
output="h:mi:s  mo/d/y" end
return output
end

You can find my work here

Make everything ok button

Offline

#7473 2014-05-10 04:01:43

mrpeachy
20% cooler
From: The Everfree Forest
Registered: 2009-11-08
Posts: 3,460

Re: Conky v1.9 Thread

ansem_of_nexus wrote:
mrpeachy wrote:

for example:

abbr_month=os.date("%b")

Is os.something let steps and will reduce the conky cpu usage?

It may need some testing, but it seems that using native lua commands should be potentially lighter than running conky parse, haveing conky run the data option, then send it back to the lua script

Last edited by mrpeachy (2014-05-10 04:05:22)

Offline

#7474 2014-05-10 04:33:17

pandroidanaroid
Member
Registered: 2014-02-22
Posts: 19

Re: Conky v1.9 Thread

Sorry I still don't get it.

ansem_of_nexus really appreciate the help. I put the code in a file called cnt.lua and put this in my .conkyrc file:

lua_load /home/me/cnt.lua
lua count_down 5/20/14 10:00

And I just see this as text on the screen it doesn't do anything.

(Also I changed 5/9/14 in your code to 5/10/14 as it is already 10 in my timezone)

Last edited by pandroidanaroid (2014-05-10 04:33:39)

Offline

Help fund CrunchBang, donate to the project!

#7475 2014-05-10 04:36:57

mrpeachy
20% cooler
From: The Everfree Forest
Registered: 2009-11-08
Posts: 3,460

Re: Conky v1.9 Thread

pandroidanaroid wrote:

Sorry I still don't get it.

ansem_of_nexus really appreciate the help. I put the code in a file called cnt.lua and put this in my .conkyrc file:

lua_load /home/me/cnt.lua
lua count_down 5/20/14 10:00

And I just see this as text on the screen it doesn't do anything.

(Also I changed 5/9/14 in your code to 5/10/14 as it is already 10 in my timezone)

Try it without the punctuation, just

lua count_down 5 20 14 10 00

If I read the setup text correctly

Offline

Board footer

Powered by FluxBB

Copyright © 2012 CrunchBang Linux.
Proudly powered by Debian. Hosted by Linode.
Debian is a registered trademark of Software in the Public Interest, Inc.
Server: acrobat

Debian Logo