You are not logged in.
Hello
I try to make a lua script who launch 2 or more script .lua but he not work
package.path = "/home/loutch/.conky/blanc/?.lua"
require 'baro'
require 'textwriting'
function conky_main()
lua_draw_hook_pre main()
lua_draw_hook_post draw_text()
end
and calling in conky with
lua_load ~/.conky/blanc/barotext.lua
lua_draw_hook_pre main
post main not work too ,to remplace this
lua_load ~/.conky/blanc/baro.lua
lua_draw_hook_pre main
lua_load ~/.conky/blanc/textwriting.lua
lua_draw_hook_post draw_text
any idea what i'am wrong
Last edited by loutch (2016-01-10 10:15:06)
Linuxmint 22.1 Xia xfce & mageia 9 XFCE on ssd hp pavilion g7
Xubuntu 18.04 lts & 24.04 lts on ASUS Rog STRIX
Offline
Moved this here as it's not really a Teo bash script problem.
Sorry I can't help you with lua.
Debian 12 Beardog, SoxDog and still a Conky 1.9er
Offline
loutch , i think i got it ,i am running conky-all 1.10.6-1 try this:
--paths-must-be->/home/worldchampions/.conky/...
--not--> ~/
function conky_main()
dofile ('/home/manuel/conky-conf/Conky_all_Lua/lua/text.lua')
dofile ('/home/manuel/conky-conf/Conky_all_Lua/lua/equalizer.lua')
dofile ('/home/manuel/conky-conf/Conky_all_Lua/lua/draw_bg.lua')
--call of the two mains functions in the lua files
conky_draw_text()
conky_main_bars()
conky_draw_bg()
end
Cheers........
Offline
conky.config = {
--Use XFT?
use_xft = true,
font = 'Franklin Gothic Book:size=9 --#Helvetica-Neue-LT-Std-95-Black',
xftalpha = 0.8,
text_buffer_size = 2048,
max_text_width = 0,
override_utf8_locale = true,
uppercase = false,
no_buffers = true,
short_units = true,
format_human_readable = true,
-- Like it says, ot pads the decimals on % values
-- doesn't seem to work since v1.7.1
pad_percents = 2,
-- Update interval in seconds
update_interval = 1,
-- This is the number of times Conky will update before quitting.
-- Set to zero to run forever.
total_run_times = 0,
-- Create own window instead of using desktop (required in nautilus)
own_window = true,
own_window_transparent = true,
own_window_type = 'desktop',
own_window_hints = 'undecorated,below,sticky,skip_taskbar,skip_pager',
own_window_argb_visual = true,
own_window_argb_value = 5,
background = true,
use_spacer = 'none',
-- Use double buffering (reduces flicker, may not work for everyone)
double_buffer = true,
-- Minimum size of text area -adjust if you would like to user smaller fonts etc.
minimum_width = 300, minimum_height = 600,
--maximum_width = 300,
--max_specials = '1024',
max_user_text = 16384,
--default_bar_size 215 5
-- Desired output unit of all objects displaying a temperature. Parameters are
-- either "fahrenheit" or "celsius". The default unit is degree Celsius.
temperature_unit = 'fahrenheit',
-- Draw shades?
draw_shades = false,
default_shade_color = '#000000',
-- Draw outlines?
draw_outline = false,
default_outline_color = '#000000',
--## Color Settings
default_color = '#b2b2b2',--220 220 220 Gainsboro
color0 = '#8FBC8F',--143 188 143 DarkSeaGreen
color1 = '#778899',--119 136 153 LightSlateGray
color2 = '#FF8C00',--255 140 0 DarkOrange
color3 = '#7FFF00',--127 255 0 Chartreuse
color4 = '#FFA07A',--255 160 122 LightSalmon
color5 = '#FFDEAD',--255 222 173 NavajoWhite
color6 = '#00BFFF',-- 0 191 255 DeepSkyBlue
color7 = '#00FFFF',-- 0 255 255 Cyan
color8 = '#FFFF00',--255 255 0 Yellow
color9 = '#B22222',--178 34 34 FireBrick ##FF0000 #255 0 0 Red
-- Draw borders around text
draw_borders = false,
-- Stippled borders?
stippled_borders = 0,
-- border margins
border_inner_margin = 0,
border_outer_margin = 0,
-- border width
border_width = 1,
-- graph borders
draw_graph_borders = true,--no
--default_graph_size 15 40
--show_graph_range no
--show_graph_scale no
-- Text alignment, other possible values are commented
alignment = 'top_middle',
--alignment top_right
--alignment bottom_left
--alignment bottom_right
-- Gap between borders of screen and text
-- same thing as passing -x at command line
gap_x = 10,
gap_y = 90,
--Default weather to Fahrenheit, please change the below if you prefer Celsius.
temperature_unit = 'fahrenheit',
-- -- Lua Load -- #
--lua_load ~/.draw-bg.lua
-- ${lua conky_draw_bg 125 0 0 0 0 0x000000 0.2}
--lua_draw_hook_pre draw_bg 20 0 0 0 0 0x000000 0.2
--lua_draw_hook_post draw_bg 20 0 0 0 0 0x000000 0.2
-- -- Album art fix -- #
imlib_cache_size = 0,
-- ASCII Characters
-- │ ─ ┌ ┬ ┐ └ ┴ ┘ ├ ┼ ┤
-- ║ ═ ╔ ╦ ╗ ╚ ╩ ╝ ╠ ╬ ╣
-- ↑ ↓ → ← ↔ ► ◄ ▲ ▼ « »
-- ░ ▒ ▓ ☺ ☻ ♥ ♦ ♣ ♠
-- • ◘ ○ ◙ ♂ ♀ ♪ ♫ ☼
-- ¼ ½ ¾ ® ©
--lua_load ~/conky-conf/Conky_all_Lua/lua/draw_bg.lua
lua_load = '~/conky-conf/Conky_all_Lua/lua/launcher.lua',
lua_draw_hook_pre = 'main',
};
conky.text = [[
${lua conky_draw_bg 10 30 5 241 80 0x000000 0.4}
${lua conky_draw_bg 10 30 90 241 95 0x000000 0.4}
${lua conky_draw_bg 10 0 190 300 110 0x000000 0.4}
${lua conky_draw_bg 10 0 305 300 95 0x000000 0.4}
${lua conky_draw_bg 10 0 405 300 120 0x000000 0.4}
${lua conky_draw_bg 10 0 530 300 55 0x000000 0.4}
]];
draw_bg.lua
--[[Background originally by londonali1010 (2009)
ability to set any size for background mrpeachy 2011
ability to set variables for bg in conkyrc dk75
the change is that if you set width and/or height to 0
then it assumes the width and/or height of the conky window
so:
lua_load ~/Conky/LUA/draw_bg.lua
TEXT
${lua conky_draw_bg 20 0 0 0 0 0x000000 0.4}
${lua conky_draw_bg corner_radius x_position y_position width height color alpha}
covers the whole window and will change if you change the minimum_size setting
20 corner_radius
0 x_position
0 y_position
0 width
0 height
0x000000 color
0.4 alpha
]]
require 'cairo'
local cs, cr = nil
function rgb_to_r_g_b(colour,alpha)
return ((colour / 0x10000) % 0x100) / 255., ((colour / 0x100) % 0x100) / 255., (colour % 0x100) / 255., alpha
end
function conky_draw_bg(r,x,y,w,h,color,alpha)
if conky_window == nil then return end
if cs == nil then cairo_surface_destroy(cs) end
if cr == nil then cairo_destroy(cr) end
local cs = cairo_xlib_surface_create(conky_window.display, conky_window.drawable, conky_window.visual, conky_window.width, conky_window.height)
local cr = cairo_create(cs)
w=w
h=h
if w=="0" then w=tonumber(conky_window.width) end
if h=="0" then h=tonumber(conky_window.height) end
cairo_set_source_rgba (cr,rgb_to_r_g_b(color,alpha))
--top left mid circle
local xtl=x+r
local ytl=y+r
--top right mid circle
local xtr=(x+r)+((w)-(2*r))
local ytr=y+r
--bottom right mid circle
local xbr=(x+r)+((w)-(2*r))
local ybr=(y+r)+((h)-(2*r))
--bottom right mid circle
local xbl=(x+r)
local ybl=(y+r)+((h)-(2*r))
-----------------------------
cairo_move_to (cr,xtl,ytl-r)
cairo_line_to (cr,xtr,ytr-r)
cairo_arc(cr,xtr,ytr,r,((2*math.pi/4)*3),((2*math.pi/4)*4))
cairo_line_to (cr,xbr+r,ybr)
cairo_arc(cr,xbr,ybr,r,((2*math.pi/4)*4),((2*math.pi/4)*1))
cairo_line_to (cr,xbl,ybl+r)
cairo_arc(cr,xbl,ybl,r,((2*math.pi/4)*1),((2*math.pi/4)*2))
cairo_line_to (cr,xtl-r,ytl)
cairo_arc(cr,xtl,ytl,r,((2*math.pi/4)*2),((2*math.pi/4)*3))
cairo_close_path(cr)
cairo_fill (cr)
------------------------------------------------------------
cairo_surface_destroy(cs)
cairo_destroy(cr)
return ""
end
equalizer.lua
--[[ BARGRAPH WIDGET
v2.1 by wlourf (07 Jan. 2011)
edited by Caymus
this widget draws a bargraph with different effects
http://u-scripts.blogspot.com/2010/07/bargraph-widget.html
To call the script in a conky, use, before TEXT
lua_load /path/to/the/script/bargraph.lua
lua_draw_hook_pre main_rings
and add one line (blank or not) after TEXT
Parameters are :
3 parameters are mandatory
name - the name of the conky variable to display, for example for {$cpu cpu0}, just write name="cpu"
arg - the argument of the above variable, for example for {$cpu cpu0}, just write arg="cpu0"
arg can be a numerical value if name=""
max - the maximum value the above variable can reach, for example, for {$cpu cpu0}, just write max=100
Optional parameters:
x,y - coordinates of the starting point of the bar, default = middle of the conky window
cap - end of cap line, ossibles values are r,b,s (for round, butt, square), default="b"
http://www.cairographics.org/samples/set_line_cap/
angle - angle of rotation of the bar in degress, default = 0 (i.e. a vertical bar)
set to 90 for an horizontal bar
skew_x - skew bar around x axis, default = 0
skew_y - skew bar around y axis, default = 0
blocks - number of blocks to display for a bar (values >0) , default= 10
height - height of a block, default=10 pixels
width - width of a block, default=20 pixels
space - space between 2 blocks, default=2 pixels
angle_bar - this angle is used to draw a bar on a circular way (ok, this is no more a bar !) default=0
radius - for cicular bars, internal radius, default=0
with radius, parameter width has no more effect.
Colours below are defined into braces {colour in hexadecimal, alpha}
fg_colour - colour of a block ON, default= {0x00FF00,1}
bg_colour - colour of a block OFF, default = {0x00FF00,0.5}
alarm - threshold, values after this threshold will use alarm_colour colour , default=max
alarm_colour - colour of a block greater than alarm, default=fg_colour
smooth - (true or false), create a gradient from fg_colour to bg_colour, default=false
mid_colour - colours to add to gradient, with this syntax {position into the gradient (0 to1), colour hexa, alpha}
for example, this table {{0.25,0xff0000,1},{0.5,0x00ff00,1},{0.75,0x0000ff,1}} will add
3 colurs to gradient created by fg_colour and alarm_colour, default=no mid_colour
led_effect - add LED effects to each block, default=no led_effect
if smooth=true, led_effect is not used
possibles values : "r","a","e" for radial, parallelel, perdendicular to the bar (just try!)
led_effect has to be used with theses colours :
fg_led - middle colour of a block ON, default = fg_colour
bg_led - middle colour of a block OFF, default = bg_colour
alarm_led - middle colour of a block > ALARM, default = alarm_colour
reflection parameters, not avaimable for circular bars
reflection_alpha - add a reflection effect (values from 0 to 1) default = 0 = no reflection
other values = starting opacity
reflection_scale - scale of the reflection (default = 1 = height of text)
reflection_length - length of reflection, define where the opacity will be set to zero
calues from 0 to 1, default =1
reflection - position of reflection, relative to a vertical bar, default="b"
possibles values are : "b","t","l","r" for bottom, top, left, right
draw_me - if set to false, text is not drawn (default = true or 1)
it can be used with a conky string, if the string returns 1, the text is drawn :
example : "${if_empty ${wireless_essid wlan0}}${else}1$endif",
v1.0 (10 Feb. 2010) original release
v1.1 (13 Feb. 2010) numeric values can be passed instead conky stats with parameters name="", arg = numeric_value
v1.2 (28 Feb. 2010) just renamed the widget to bargraph
v1.3 (03 Mar. 2010) added parameters radius & angle_bar to draw the bar in a circular way
v2.0 (12 Jul. 2010) rewrite script + add reflection effects and parameters are now set into tables
v2.1 (07 Jan. 2011) Add draw_me parameter and correct memory leaks, thanks to "Creamy Goodness"
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation version 3 (GPLv3)
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program; if not, write to the Free Software
-- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
-- MA 02110-1301, USA.
]]
require 'cairo'
----------------START OF PARAMETERS ----------
function conky_main_bars()
local bars_settings={
{
name="cpu",
arg="cpu0",
max=100,
alarm=80,
bg_colour={0XDCDCDC,0.25},
fg_colour={0X708090,1},
alarm_colour={0xff0000,1},
x=27,y=290,
blocks=20,
height=2,width=10,
angle=0,
smooth=true,
cap="e",
skew_y=0,
mid_colour={{0.5,0xB0E2FF,1}}
},
{
name="cpu",
arg="cpu1",
max=100,
alarm=80,
bg_colour={0XDCDCDC,0.25},
fg_colour={0X708090,1},
alarm_colour={0xff0000,1},
x=67,y=290,
blocks=20,
height=2,width=10,
angle=0,
smooth=true,
cap="e",
skew_y=0,
mid_colour={{0.5,0xB0E2FF,1}}
},
{
name="cpu",
arg="cpu2",
max=100,
alarm=80,
bg_colour={0XDCDCDC,0.25},
fg_colour={0X708090,1},
alarm_colour={0xff0000,1},
x=107,y=290,
blocks=20,
height=2,width=10,
angle=0,
smooth=true,
cap="e",
skew_y=0,
mid_colour={{0.5,0xB0E2FF,1}}
},
{
name="cpu",
arg="cpu3",
max=100,
alarm=80,
bg_colour={0XDCDCDC,0.25},
fg_colour={0X708090,1},
alarm_colour={0xff0000,1},
x=147,y=290,
blocks=20,
height=2,width=10,
angle=0,
smooth=true,
cap="e",
skew_y=0,
mid_colour={{0.5,0xB0E2FF,1}}
},
{
name="cpu",
arg="cpu4",
max=100,
alarm=80,
bg_colour={0XDCDCDC,0.25},
fg_colour={0X708090,1},
alarm_colour={0xff0000,1},
x=187,y=290,
blocks=20,
height=2,width=10,
angle=0,
smooth=true,
cap="e",
skew_y=0,
mid_colour={{0.5,0xB0E2FF,1}}
},
{
name="memperc",
arg="",
max=100,
alarm=80,
bg_colour={0XDCDCDC,0.25},
fg_colour={0X708090,1},
x=227,y=290,
blocks=20,
height=2,width=10,
angle=0,
smooth=true,
cap="e",
skew_y=0,
mid_colour={{0.5,0xB0E2FF,1}}
},
{
name="swapperc",
arg="",
max=100,
alarm=80,
bg_colour={0XDCDCDC,0.25},
fg_colour={0X708090,1},
alarm_colour={0xff0000,1},
x=267,y=290,
blocks=20,
height=2,width=10,
angle=0,
smooth=true,
cap="e",
skew_y=0,
mid_colour={{0.5,0xB0E2FF,1}}
},
{
name="fs_used_perc",
arg="/",
max=100,
alarm=80,
bg_colour={0XDCDCDC,0.25},
fg_colour={0X708090,1},
alarm_colour={0xff0000,1},
x=27,y=395,
blocks=15,
height=2,width=10,
angle=0,
smooth=true,
cap="e",
skew_y=0,
mid_colour={{0.5,0xB0E2FF,1}}
},
{
name="fs_used_perc",
arg="/media/manuel/Files",
max=100,
alarm=80,
bg_colour={0XDCDCDC,0.25},
fg_colour={0X708090,1},
alarm_colour={0xff0000,1},
x=107,y=395,
blocks=15,
height=2,width=10,
angle=0,
smooth=true,
cap="e",
skew_y=0,
mid_colour={{0.5,0xB0E2FF,1}}
},
{
name="fs_used_perc",
arg="/media/manuel/Windows 10",
max=100,
alarm=80,
bg_colour={0XDCDCDC,0.25},
fg_colour={0X708090,1},
alarm_colour={0xff0000,1},
x=187,y=395,
blocks=15,
height=2,width=10,
angle=0,
smooth=true,
cap="e",
skew_y=0,
mid_colour={{0.5,0xB0E2FF,1}}
},
{
name="fs_used_perc",
arg="/media/manuel/61f3f05a-6619-4fa1-90e3-ac333c3461db",
max=100,
alarm=80,
bg_colour={0XDCDCDC,0.25},
fg_colour={0X708090,1},
alarm_colour={0xff0000,1},
x=267,y=395,
blocks=15,
height=2,width=10,
angle=0,
smooth=true,
cap="e",
skew_y=0,
mid_colour={{0.5,0xB0E2FF,1}}
},
{
name="downspeedf",
arg="eth0",
max=1000,
alarm=80,
bg_colour={0XDCDCDC,0.25},
fg_colour={0X708090,1},
alarm_colour={0xff0000,1},
x=10,y=475,
blocks=35,
height=2,width=13,
angle=90,
smooth=true,
cap="e",
skew_y=0,
draw_me="${if_existing /proc/net/route eth0}1${else}0$endif",
mid_colour={{0.5,0xB0E2FF,1}}
},
{
name="upspeedf",
arg="eth0",
max=500,
alarm=80,
bg_colour={0XDCDCDC,0.25},
fg_colour={0X708090,1},
alarm_colour={0xff0000,1},
x=160,y=475,
blocks=35,
height=2,width=13,
angle=90,
smooth=true,
cap="e",
skew_y=0,
draw_me="${if_existing /proc/net/route eth0}1${else}0$endif",
mid_colour={{0.5,0xB0E2FF,1}}
},
{
name="downspeedf",
arg="wlan0",
max=1000,
alarm=80,
bg_colour={0XDCDCDC,0.25},
fg_colour={0X708090,1},
alarm_colour={0xff0000,1},
x=10,y=475,
blocks=35,
height=2,width=13,
angle=90,
smooth=true,
cap="e",
skew_y=0,
draw_me="${if_existing /proc/net/route wlan0}1${else}0$endif",
mid_colour={{0.5,0xB0E2FF,1}}
},
{
name="upspeedf",
arg="wlan0",
max=500,
alarm=80,
bg_colour={0XDCDCDC,0.25},
fg_colour={0X708090,1},
alarm_colour={0xff0000,1},
x=160,y=475,
blocks=35,
height=2,width=13,
angle=90,
smooth=true,
cap="e",
skew_y=0,
draw_me="${if_existing /proc/net/route wlan0}1${else}0$endif",
mid_colour={{0.5,0xB0E2FF,1}}
},
{
name="wireless_link_qual_perc",
arg="wlan0",
max=100,
alarm=80,
bg_colour={0XDCDCDC,0.25},
fg_colour={0X708090,1},
alarm_colour={0xff0000,1},
x=80,y=505,
blocks=35,
height=2,width=13,
angle=90,
smooth=true,
cap="e",
skew_y=0,
draw_me="${if_existing /proc/net/route wlan0}1${else}0$endif",
mid_colour={{0.5,0xB0E2FF,1}}
},
{
name="battery_percent",
arg="BAT0",
max=100,
alarm=80,
bg_colour={0XDCDCDC,0.25},
fg_colour={0X708090,1},
alarm_colour={0xff0000,1},
x=15,y=565,
blocks=68,
height=2,width=13,
angle=90,
smooth=true,
cap="e",
skew_y=0,
--draw_me="${if_existing /proc/net/route wlan0}1${else}0$endif",
mid_colour={{0.5,0xB0E2FF,1}}
},
}
-----------END OF PARAMETERS--------------
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)
--prevent segmentation error when reading cpu state
if tonumber(conky_parse('${updates}'))>3 then
for i in pairs(bars_settings) do
draw_multi_bar_graph(bars_settings[i])
end
end
cairo_destroy(cr)
cairo_surface_destroy(cs)
cr=nil
end
function draw_multi_bar_graph(t)
cairo_save(cr)
--check values
if t.draw_me == true then t.draw_me = nil end
if t.draw_me ~= nil and conky_parse(tostring(t.draw_me)) ~= "1" then return end
if t.name==nil and t.arg==nil then
print ("No input values ... use parameters 'name' with 'arg' or only parameter 'arg' ")
return
end
if t.max==nil then
print ("No maximum value defined, use 'max'")
return
end
if t.name==nil then t.name="" end
if t.arg==nil then t.arg="" end
--set default values
if t.x == nil then t.x = conky_window.width/2 end
if t.y == nil then t.y = conky_window.height/2 end
if t.blocks == nil then t.blocks=10 end
if t.height == nil then t.height=10 end
if t.angle == nil then t.angle=0 end
t.angle = t.angle*math.pi/180
--line cap style
if t.cap==nil then t.cap = "b" end
local cap="b"
for i,v in ipairs({"s","r","b"}) do
if v==t.cap then cap=v end
end
local delta=0
if t.cap=="r" or t.cap=="s" then delta = t.height end
if cap=="s" then cap = CAIRO_LINE_CAP_SQUARE
elseif cap=="r" then
cap = CAIRO_LINE_CAP_ROUND
elseif cap=="b" then
cap = CAIRO_LINE_CAP_BUTT
end
--end line cap style
--if t.led_effect == nil then t.led_effect="r" end
if t.width == nil then t.width=20 end
if t.space == nil then t.space=2 end
if t.radius == nil then t.radius=0 end
if t.angle_bar == nil then t.angle_bar=0 end
t.angle_bar = t.angle_bar*math.pi/360 --halt angle
--colours
if t.bg_colour == nil then t.bg_colour = {0x00FF00,0.5} end
if #t.bg_colour~=2 then t.bg_colour = {0x00FF00,0.5} end
if t.fg_colour == nil then t.fg_colour = {0x00FF00,1} end
if #t.fg_colour~=2 then t.fg_colour = {0x00FF00,1} end
if t.alarm_colour == nil then t.alarm_colour = t.fg_colour end
if #t.alarm_colour~=2 then t.alarm_colour = t.fg_colour end
if t.mid_colour ~= nil then
for i=1, #t.mid_colour do
if #t.mid_colour[i]~=3 then
print ("error in mid_color table")
t.mid_colour[i]={1,0xFFFFFF,1}
end
end
end
if t.bg_led ~= nil and #t.bg_led~=2 then t.bg_led = t.bg_colour end
if t.fg_led ~= nil and #t.fg_led~=2 then t.fg_led = t.fg_colour end
if t.alarm_led~= nil and #t.alarm_led~=2 then t.alarm_led = t.fg_led end
if t.led_effect~=nil then
if t.bg_led == nil then t.bg_led = t.bg_colour end
if t.fg_led == nil then t.fg_led = t.fg_colour end
if t.alarm_led == nil then t.alarm_led = t.fg_led end
end
if t.alarm==nil then t.alarm = t.max end --0.8*t.max end
if t.smooth == nil then t.smooth = false end
if t.skew_x == nil then
t.skew_x=0
else
t.skew_x = math.pi*t.skew_x/180
end
if t.skew_y == nil then
t.skew_y=0
else
t.skew_y = math.pi*t.skew_y/180
end
if t.reflection_alpha==nil then t.reflection_alpha=0 end
if t.reflection_length==nil then t.reflection_length=1 end
if t.reflection_scale==nil then t.reflection_scale=1 end
--end of default values
local function rgb_to_r_g_b(col_a)
return ((col_a[1] / 0x10000) % 0x100) / 255., ((col_a[1] / 0x100) % 0x100) / 255., (col_a[1] % 0x100) / 255., col_a[2]
end
--functions used to create patterns
local function create_smooth_linear_gradient(x0,y0,x1,y1)
local pat = cairo_pattern_create_linear (x0,y0,x1,y1)
cairo_pattern_add_color_stop_rgba (pat, 0, rgb_to_r_g_b(t.fg_colour))
cairo_pattern_add_color_stop_rgba (pat, 1, rgb_to_r_g_b(t.alarm_colour))
if t.mid_colour ~=nil then
for i=1, #t.mid_colour do
cairo_pattern_add_color_stop_rgba (pat, t.mid_colour[i][1], rgb_to_r_g_b({t.mid_colour[i][2],t.mid_colour[i][3]}))
end
end
return pat
end
local function create_smooth_radial_gradient(x0,y0,r0,x1,y1,r1)
local pat = cairo_pattern_create_radial (x0,y0,r0,x1,y1,r1)
cairo_pattern_add_color_stop_rgba (pat, 0, rgb_to_r_g_b(t.fg_colour))
cairo_pattern_add_color_stop_rgba (pat, 1, rgb_to_r_g_b(t.alarm_colour))
if t.mid_colour ~=nil then
for i=1, #t.mid_colour do
cairo_pattern_add_color_stop_rgba (pat, t.mid_colour[i][1], rgb_to_r_g_b({t.mid_colour[i][2],t.mid_colour[i][3]}))
end
end
return pat
end
local function create_led_linear_gradient(x0,y0,x1,y1,col_alp,col_led)
local pat = cairo_pattern_create_linear (x0,y0,x1,y1) ---delta, 0,delta+ t.width,0)
cairo_pattern_add_color_stop_rgba (pat, 0.0, rgb_to_r_g_b(col_alp))
cairo_pattern_add_color_stop_rgba (pat, 0.5, rgb_to_r_g_b(col_led))
cairo_pattern_add_color_stop_rgba (pat, 1.0, rgb_to_r_g_b(col_alp))
return pat
end
local function create_led_radial_gradient(x0,y0,r0,x1,y1,r1,col_alp,col_led,mode)
local pat = cairo_pattern_create_radial (x0,y0,r0,x1,y1,r1)
if mode==3 then
cairo_pattern_add_color_stop_rgba (pat, 0, rgb_to_r_g_b(col_alp))
cairo_pattern_add_color_stop_rgba (pat, 0.5, rgb_to_r_g_b(col_led))
cairo_pattern_add_color_stop_rgba (pat, 1, rgb_to_r_g_b(col_alp))
else
cairo_pattern_add_color_stop_rgba (pat, 0, rgb_to_r_g_b(col_led))
cairo_pattern_add_color_stop_rgba (pat, 1, rgb_to_r_g_b(col_alp))
end
return pat
end
local function draw_single_bar()
--this fucntion is used for bars with a single block (blocks=1) but
--the drawing is cut in 3 blocks : value/alarm/background
--not zvzimzblr for circular bar
local function create_pattern(col_alp,col_led,bg)
local pat
if not t.smooth then
if t.led_effect=="e" then
pat = create_led_linear_gradient (-delta, 0,delta+ t.width,0,col_alp,col_led)
elseif t.led_effect=="a" then
pat = create_led_linear_gradient (t.width/2, 0,t.width/2,-t.height,col_alp,col_led)
elseif t.led_effect=="r" then
pat = create_led_radial_gradient (t.width/2, -t.height/2, 0, t.width/2,-t.height/2,t.height/1.5,col_alp,col_led,2)
else
pat = cairo_pattern_create_rgba (rgb_to_r_g_b(col_alp))
end
else
if bg then
pat = cairo_pattern_create_rgba (rgb_to_r_g_b(t.bg_colour))
else
pat = create_smooth_linear_gradient(t.width/2, 0, t.width/2,-t.height)
end
end
return pat
end
local y1=-t.height*pct/100
local y2,y3
if pct>(100*t.alarm/t.max) then
y1 = -t.height*t.alarm/100
y2 = -t.height*pct/100
if t.smooth then y1=y2 end
end
if t.angle_bar==0 then
--block for fg value
local pat = create_pattern(t.fg_colour,t.fg_led,false)
cairo_set_source(cr,pat)
cairo_rectangle(cr,0,0,t.width,y1)
cairo_fill(cr)
cairo_pattern_destroy(pat)
-- block for alarm value
if not t.smooth and y2 ~=nil then
pat = create_pattern(t.alarm_colour,t.alarm_led,false)
cairo_set_source(cr,pat)
cairo_rectangle(cr,0,y1,t.width,y2-y1)
cairo_fill(cr)
y3=y2
cairo_pattern_destroy(pat)
else
y2,y3=y1,y1
end
-- block for bg value
cairo_rectangle(cr,0,y2,t.width,-t.height-y3)
pat = create_pattern(t.bg_colour,t.bg_led,true)
cairo_set_source(cr,pat)
cairo_pattern_destroy(pat)
cairo_fill(cr)
end
end --end single bar
local function draw_multi_bar()
--function used for bars with 2 or more blocks
for pt = 1,t.blocks do
--set block y
local y1 = -(pt-1)*(t.height+t.space)
local light_on=false
--set colors
local col_alp = t.bg_colour
local col_led = t.bg_led
if pct>=(100/t.blocks) or pct>0 then --ligth on or not the block
if pct>=(pcb*(pt-1)) then
light_on = true
col_alp = t.fg_colour
col_led = t.fg_led
if pct>=(100*t.alarm/t.max) and (pcb*pt)>(100*t.alarm/t.max) then
col_alp = t.alarm_colour
col_led = t.alarm_led
end
end
end
--set colors
--have to try to create gradients outside the loop ?
local pat
if not t.smooth then
if t.angle_bar==0 then
if t.led_effect=="e" then
pat = create_led_linear_gradient (-delta, 0,delta+ t.width,0,col_alp,col_led)
elseif t.led_effect=="a" then
pat = create_led_linear_gradient (t.width/2, -t.height/2+y1,t.width/2,0+t.height/2+y1,col_alp,col_led)
elseif t.led_effect=="r" then
pat = create_led_radial_gradient (t.width/2, y1, 0, t.width/2,y1,t.width/1.5,col_alp,col_led,2)
else
pat = cairo_pattern_create_rgba (rgb_to_r_g_b(col_alp))
end
else
if t.led_effect=="a" then
pat = create_led_radial_gradient (0, 0, t.radius+(t.height+t.space)*(pt-1),
0, 0, t.radius+(t.height+t.space)*(pt),
col_alp,col_led,3)
else
pat = cairo_pattern_create_rgba (rgb_to_r_g_b(col_alp))
end
end
else
if light_on then
if t.angle_bar==0 then
pat = create_smooth_linear_gradient(t.width/2, t.height/2, t.width/2,-(t.blocks-0.5)*(t.height+t.space))
else
pat = create_smooth_radial_gradient(0, 0, (t.height+t.space), 0,0,(t.blocks+1)*(t.height+t.space),2)
end
else
pat = cairo_pattern_create_rgba (rgb_to_r_g_b(t.bg_colour))
end
end
cairo_set_source (cr, pat)
cairo_pattern_destroy(pat)
--draw a block
if t.angle_bar==0 then
cairo_move_to(cr,0,y1)
cairo_line_to(cr,t.width,y1)
else
cairo_arc( cr,0,0,
t.radius+(t.height+t.space)*(pt)-t.height/2,
-t.angle_bar -math.pi/2 ,
t.angle_bar -math.pi/2)
end
cairo_stroke(cr)
end
end
local function setup_bar_graph()
--function used to retrieve the value to display and to set the cairo structure
if t.blocks ~=1 then t.y=t.y-t.height/2 end
local value = 0
if t.name ~="" then
value = tonumber(conky_parse(string.format('${%s %s}', t.name, t.arg)))
--$to_bytes doesn't work when value has a decimal point,
--https://garage.maemo.org/plugins/ggit/browse.php/?p=monky;a=commitdiff;h=174c256c81a027a2ea406f5f37dc036fac0a524b;hp=d75e2db5ed3fc788fb8514121f67316ac3e5f29f
--http://sourceforge.net/tracker/index.php?func=detail&aid=3000865&group_id=143975&atid=757310
--conky bug?
--value = (conky_parse(string.format('${%s %s}', t.name, t.arg)))
--if string.match(value,"%w") then
-- value = conky_parse(string.format('${to_bytes %s}',value))
--end
else
value = tonumber(t.arg)
end
if value==nil then value =0 end
pct = 100*value/t.max
pcb = 100/t.blocks
cairo_set_line_width (cr, t.height)
cairo_set_line_cap (cr, cap)
cairo_translate(cr,t.x,t.y)
cairo_rotate(cr,t.angle)
local matrix0 = cairo_matrix_t:create()
tolua.takeownership(matrix0)
cairo_matrix_init (matrix0, 1,t.skew_y,t.skew_x,1,0,0)
cairo_transform(cr,matrix0)
--call the drawing function for blocks
if t.blocks==1 and t.angle_bar==0 then
draw_single_bar()
if t.reflection=="t" or t.reflection=="b" then cairo_translate(cr,0,-t.height) end
else
draw_multi_bar()
end
--dot for reminder
--[[
if t.blocks ~=1 then
cairo_set_source_rgba(cr,1,0,0,1)
cairo_arc(cr,0,t.height/2,3,0,2*math.pi)
cairo_fill(cr)
else
cairo_set_source_rgba(cr,1,0,0,1)
cairo_arc(cr,0,0,3,0,2*math.pi)
cairo_fill(cr)
end]]
--call the drawing function for reflection and prepare the mask used
if t.reflection_alpha>0 and t.angle_bar==0 then
local pat2
local matrix1 = cairo_matrix_t:create()
tolua.takeownership(matrix1)
if t.angle_bar==0 then
pts={-delta/2,(t.height+t.space)/2,t.width+delta,-(t.height+t.space)*(t.blocks)}
if t.reflection=="t" then
cairo_matrix_init (matrix1,1,0,0,-t.reflection_scale,0,-(t.height+t.space)*(t.blocks-0.5)*2*(t.reflection_scale+1)/2)
pat2 = cairo_pattern_create_linear (t.width/2,-(t.height+t.space)*(t.blocks),t.width/2,(t.height+t.space)/2)
elseif t.reflection=="r" then
cairo_matrix_init (matrix1,-t.reflection_scale,0,0,1,delta+2*t.width,0)
pat2 = cairo_pattern_create_linear (delta/2+t.width,0,-delta/2,0)
elseif t.reflection=="l" then
cairo_matrix_init (matrix1,-t.reflection_scale,0,0,1,-delta,0)
pat2 = cairo_pattern_create_linear (-delta/2,0,delta/2+t.width,-0)
else --bottom
cairo_matrix_init (matrix1,1,0,0,-1*t.reflection_scale,0,(t.height+t.space)*(t.reflection_scale+1)/2)
pat2 = cairo_pattern_create_linear (t.width/2,(t.height+t.space)/2,t.width/2,-(t.height+t.space)*(t.blocks))
end
end
cairo_transform(cr,matrix1)
if t.blocks==1 and t.angle_bar==0 then
draw_single_bar()
cairo_translate(cr,0,-t.height/2)
else
draw_multi_bar()
end
cairo_set_line_width(cr,0.01)
cairo_pattern_add_color_stop_rgba (pat2, 0,0,0,0,1-t.reflection_alpha)
cairo_pattern_add_color_stop_rgba (pat2, t.reflection_length,0,0,0,1)
if t.angle_bar==0 then
cairo_rectangle(cr,pts[1],pts[2],pts[3],pts[4])
end
cairo_clip_preserve(cr)
cairo_set_operator(cr,CAIRO_OPERATOR_CLEAR)
cairo_stroke(cr)
cairo_mask(cr,pat2)
cairo_pattern_destroy(pat2)
cairo_set_operator(cr,CAIRO_OPERATOR_OVER)
end --reflection
pct,pcb=nil
end --setup_bar_graph()
--start here !
setup_bar_graph()
cairo_restore(cr)
end
function conky_main_box()
if conky_window==nil then return end
---------------------- PARAMETERS BEGIN HERE
local boxes_settings={
{x=0,y=50,w=200,h=60, corners={ {"circle",10} },colour={ {0,0x1F1F1F,0.5} },operator="atop" } ,
{x=0,y=195,w=200,h=60, corners={ {"circle",10} },colour={ {0,0x1F1F1F,0.5} },operator="atop" } ,
{x=0,y=320,w=200,h=60, corners={ {"circle",10} },colour={ {0,0x1F1F1F,0.5} },operator="atop" } ,
{x=0,y=410,w=200,h=60, corners={ {"circle",10} },colour={ {0,0x1F1F1F,0.5} },operator="atop" } ,
{x=0,y=520,w=200,h=60, corners={ {"circle",10} },colour={ {0,0x1F1F1F,0.5} },operator="atop" } ,
{x=0,y=615,w=200,h=150, corners={ {"circle",10} },colour={ {0,0x1F1F1F,0.5} },operator="atop" } ,
}
---------------------------- PARAMETERS END HERE
local cs=cairo_xlib_surface_create(conky_window.display, conky_window.drawable, conky_window.visual, conky_window.width, conky_window.height)
local cr=cairo_create(cs)
if tonumber(conky_parse("$updates"))<5 then return end
for i in pairs(boxes_settings) do
draw_box (cr,boxes_settings[i])
end
cairo_destroy(cr)
cairo_surface_destroy(cs)
end
function draw_box(cr,t)
if t.draw_me == true then t.draw_me = nil end
if t.draw_me ~= nil and conky_parse(tostring(t.draw_me)) ~= "1" then return end
local table_corners={"circle","curve","line"}
local t_operators={
clear = CAIRO_OPERATOR_CLEAR,
source = CAIRO_OPERATOR_SOURCE,
over = CAIRO_OPERATOR_OVER,
["in"] = CAIRO_OPERATOR_IN,
out = CAIRO_OPERATOR_OUT,
atop = CAIRO_OPERATOR_ATOP,
dest = CAIRO_OPERATOR_DEST,
dest_over = CAIRO_OPERATOR_DEST_OVER,
dest_in = CAIRO_OPERATOR_DEST_IN,
dest_out = CAIRO_OPERATOR_DEST_OUT,
dest_atop = CAIRO_OPERATOR_DEST_ATOP,
xor = CAIRO_OPERATOR_XOR,
add = CAIRO_OPERATOR_ADD,
saturate = CAIRO_OPERATOR_SATURATE,
}
function rgba_to_r_g_b_a(tc)
--tc={position,colour,alpha}
local colour = tc[2]
local alpha = tc[3]
return ((colour / 0x10000) % 0x100) / 255., ((colour / 0x100) % 0x100) / 255., (colour % 0x100) / 255., alpha
end
function table.copy(t)
local t2 = {}
for k,v in pairs(t) do
t2[k] = {v[1],v[2]}
end
return t2
end
function draw_corner(num,t)
local shape=t[1]
local radius=t[2]
local x,y = t[3],t[4]
if shape=="line" then
if num == 1 then cairo_line_to(cr,radius,0)
elseif num == 2 then cairo_line_to(cr,x,radius)
elseif num == 3 then cairo_line_to(cr,x-radius,y)
elseif num == 4 then cairo_line_to(cr,0,y-radius)
end
end
if shape=="circle" then
local PI = math.pi
if num == 1 then cairo_arc(cr,radius,radius,radius,-PI,-PI/2)
elseif num == 2 then cairo_arc(cr,x-radius,y+radius,radius,-PI/2,0)
elseif num == 3 then cairo_arc(cr,x-radius,y-radius,radius,0,PI/2)
elseif num == 4 then cairo_arc(cr,radius,y-radius,radius,PI/2,-PI)
end
end
if shape=="curve" then
if num == 1 then cairo_curve_to(cr,0,radius ,0,0 ,radius,0)
elseif num == 2 then cairo_curve_to(cr,x-radius,0, x,y, x,radius)
elseif num == 3 then cairo_curve_to(cr,x,y-radius, x,y, x-radius,y)
elseif num == 4 then cairo_curve_to(cr,radius,y, x,y, 0,y-radius)
end
end
end
--check values and set default values
if t.x == nil then t.x = 0 end
if t.y == nil then t.y = 0 end
if t.w == nil then t.w = conky_window.width end
if t.h == nil then t.h = conky_window.height end
if t.radius == nil then t.radius = 0 end
if t.border == nil then t.border = 0 end
if t.colour==nil then t.colour={{1,0xFFFFFF,0.5}} end
if t.linear_gradient ~= nil then
if #t.linear_gradient ~= 4 then
t.linear_gradient = {t.x,t.y,t.width,t.height}
end
end
if t.angle==nil then t.angle = 0 end
if t.skew_x == nil then t.skew_x=0 end
if t.skew_y == nil then t.skew_y=0 end
if t.scale_x==nil then t.scale_x=1 end
if t.scale_y==nil then t.scale_y=1 end
if t.rot_x == nil then t.rot_x=0 end
if t.rot_y == nil then t.rot_y=0 end
if t.operator == nil then t.operator = "over" end
if (t_operators[t.operator]) == nil then
print ("wrong operator :",t.operator)
t.operator = "over"
end
if t.radial_gradient ~= nil then
if #t.radial_gradient ~= 6 then
t.radial_gradient = {t.x,t.y,0, t.x,t.y, t.width}
end
end
for i=1, #t.colour do
if #t.colour[i]~=3 then
print ("error in color table")
t.colour[i]={1,0xFFFFFF,1}
end
end
if t.corners == nil then t.corners={ {"line",0} } end
local t_corners = {}
local t_corners = table.copy(t.corners)
--don't use t_corners=t.corners otherwise t.corners is altered
--complete the t_corners table if needed
for i=#t_corners+1,4 do
t_corners[i]=t_corners[#t_corners]
local flag=false
for j,v in pairs(table_corners) do flag=flag or (t_corners[i][1]==v) end
if not flag then print ("error in corners table :",t_corners[i][1]);t_corners[i][1]="curve" end
end
--this way :
-- t_corners[1][4]=x
-- t_corners[2][3]=y
--doesn't work
t_corners[1]={t_corners[1][1],t_corners[1][2],0,0}
t_corners[2]={t_corners[2][1],t_corners[2][2],t.w,0}
t_corners[3]={t_corners[3][1],t_corners[3][2],t.w,t.h}
t_corners[4]={t_corners[4][1],t_corners[4][2],0,t.h}
t.no_gradient = (t.linear_gradient == nil ) and (t.radial_gradient == nil )
cairo_save(cr)
cairo_translate(cr, t.x, t.y)
if t.rot_x~=0 or t.rot_y~=0 or t.angle~=0 then
cairo_translate(cr,t.rot_x,t.rot_y)
cairo_rotate(cr,t.angle*math.pi/180)
cairo_translate(cr,-t.rot_x,-t.rot_y)
end
if t.scale_x~=1 or t.scale_y~=1 or t.skew_x~=0 or t.skew_y~=0 then
local matrix0 = cairo_matrix_t:create()
tolua.takeownership(matrix0)
cairo_matrix_init (matrix0, t.scale_x,math.pi*t.skew_y/180 , math.pi*t.skew_x/180 ,t.scale_y,0,0)
cairo_transform(cr,matrix0)
end
local tc=t_corners
cairo_move_to(cr,tc[1][2],0)
cairo_line_to(cr,t.w-tc[2][2],0)
draw_corner(2,tc[2])
cairo_line_to(cr,t.w,t.h-tc[3][2])
draw_corner(3,tc[3])
cairo_line_to(cr,tc[4][2],t.h)
draw_corner(4,tc[4])
cairo_line_to(cr,0,tc[1][2])
draw_corner(1,tc[1])
if t.no_gradient then
cairo_set_source_rgba(cr,rgba_to_r_g_b_a(t.colour[1]))
else
if t.linear_gradient ~= nil then
pat = cairo_pattern_create_linear (t.linear_gradient[1],t.linear_gradient[2],t.linear_gradient[3],t.linear_gradient[4])
elseif t.radial_gradient ~= nil then
pat = cairo_pattern_create_radial (t.radial_gradient[1],t.radial_gradient[2],t.radial_gradient[3],
t.radial_gradient[4],t.radial_gradient[5],t.radial_gradient[6])
end
for i=1, #t.colour do
cairo_pattern_add_color_stop_rgba (pat, t.colour[i][1], rgba_to_r_g_b_a(t.colour[i]))
end
cairo_set_source (cr, pat)
cairo_pattern_destroy(pat)
end
cairo_set_operator(cr,t_operators[t.operator])
if t.border>0 then
cairo_close_path(cr)
if t.dash ~= nil then cairo_set_dash(cr, t.dash, 1, 0.0) end
cairo_set_line_width(cr,t.border)
cairo_stroke(cr)
else
cairo_fill(cr)
end
cairo_restore(cr)
end
text.lua
--[[TEXT WIDGET v1.3 by Wlourf 25/06/2010
This widget can drawn texts set in the "text_settings" table with some parameters
http://u-scripts.blogspot.com/2010/06/text-widget.html
The parameters (all optionals) are :
text - text to display, default = "Conky is good for you"
use conky_parse to display conky value ie text=conly_parse("${cpu cpu1}")
- coordinates below are relative to top left corner of the conky window
x - x coordinate of first letter (bottom-left), default = center of conky window
y - y coordinate of first letter (bottom-left), default = center of conky window
h_align - horizontal alignement of text relative to point (x,y), default="l"
available values are "l": left, "c" : center, "r" : right
v_align - vertical alignment of text relative to point (x,y), default="b"
available values "t" : top, "m" : middle, "b" : bottom
font_name - name of font to use, default = Free Sans
font_size - size of font to use, default = 14
italic - display text in italic (true/false), default=false
oblique - display text in oblique (true/false), default=false (I don' see the difference with italic!)
bold - display text in bold (true/false), default=false
angle - rotation of text in degrees, default = 0 (horizontal)
colour - table of colours for text, default = plain white {{1,0XFFFF00,1}}
this table contains one or more tables with format {P,C,A}
P=position of gradient (0 = beginning of text, 1= end of text)
C=hexadecimal colour
A=alpha (opacity) of color (0=invisible,1=opacity 100%)
Examples :
for a plain color {{1,0x00FF00,0.5}}
for a gradient with two colours {{0,0x00FF00,0.5},{1,0x000033,1}}
or {{0.5,0x00FF00,1},{1,0x000033,1}} -with this one, gradient will start in the middle of the text
for a gradient with three colours {{0,0x00FF00,0.5},{0.5,0x000033,1},{1,0x440033,1}}
and so on ...
orientation - in case of gradient, "orientation" defines the starting point of the gradient, default="ww"
there are 8 available starting points : "nw","nn","ne","ee","se","ss","sw","ww"
(n for north, w for west ...)
theses 8 points are the 4 corners + the 4 middles of text's outline
so a gradient "nn" will go from "nn" to "ss" (top to bottom, parallele to text)
a gradient "nw" will go from "nw" to "se" (left-top corner to right-bottom corner)
radial - define a radial gradient (if present at the same time as "orientation", "orientation" will have no effect)
this parameter is a table with 6 numbers : {xa,ya,ra,xb,yb,rb}
they define two circle for the gradient :
xa, ya, xb and yb are relative to x and y values above
reflection_alpha - add a reflection effect (values from 0 to 1) default = 0 = no reflection
other values = starting opacity
reflection_scale - scale of the reflection (default = 1 = height of text)
reflection_length - length of reflection, define where the opacity will be set to zero
calues from 0 to 1, default =1
skew_x,skew_y - skew text around x or y axis
Needs conky 1.8.0
To call this script in the conkyrc, in before-TEXT section:
lua_load /path/to/the/lua/script/text.lua
lua_draw_hook_pre draw_text
v1.0 07/06/2010, Original release
v1.1 10/06/2010 Add "orientation" parameter
v1.2 15/06/2010 Add "h_align", "v_align" and "radial" parameters
v1.3 25/06/2010 Add "reflection_alpha", "reflection_length", "reflection_scale",
"skew_x" et "skew_y"
-- 18/06/14/ram leak modified
]]
require 'cairo'
function conky_draw_text()
--BEGIN OF PARAMETRES
local ts=os.date("*t")
local text_settings={
--date
{
text=conky_parse"${time %a %d %b %Y}",
font_name="Larabiefont",
font_size=20,
h_align="l",
--v_align="m",
bold=true,
x=50,
y=30,
colour={{0.5,0X7FFF00,0.5},{1,0XFFFF00,0.3}},
--radial={0,300,0,0,300,370},
orientation="nn",
},
--time
{
text=conky_parse"${time %I %M}",
font_name="hooge 05_53",
font_size=50,
h_align="l",
--v_align="m",
bold=true,
x=70,
y=70,
colour={{0.5,0X7FFF00,0.5},{1,0XFFFF00,0.3}},
--radial={0,300,0,0,300,370},
orientation="nn",
},
{
text=conky_parse"${execi 3600 lsb_release -d | cut -c14-38}",
font_name="terminus",
font_size=17,
h_align="l",
--v_align="m",
bold=true,
x=40,
y=105,
colour={{0.5,0X7FFF00,0.5},{1,0XFFFF00,0.3}},
--radial={0,300,0,0,300,370},
orientation="nn",
},
{
text=conky_parse"${kernel} - ${machine}",
font_name="terminus",
font_size=15,
h_align="l",
--v_align="m",
bold=true,
x=40,
y=120,
colour={{0.5,0X7FFF00,0.5},{1,0XFFFF00,0.3}},
--radial={0,300,0,0,300,370},
orientation="nn",
},
{
text=conky_parse"${nodename} Uptime: ${uptime_short}",
font_name="terminus",
font_size=15,
h_align="l",
--v_align="m",
bold=true,
x=40,
y=135,
colour={{0.5,0X7FFF00,0.5},{1,0XFFFF00,0.3}},
--radial={0,300,0,0,300,370},
orientation="nn",
},
{
text=conky_parse"System Updates:${execi 3600 aptitude search '~U' | wc -l | tail} System:${fs_type}",
font_name="terminus",
font_size=15,
h_align="l",
--v_align="m",
bold=true,
x=40,
y=150,
colour={{0.5,0X7FFF00,0.5},{1,0XFFFF00,0.3}},
--radial={0,300,0,0,300,370},
orientation="nn",
},
{
text=conky_parse"Processes: $processes ($running_processes running)",
font_name="terminus",
font_size=15,
h_align="l",
--v_align="m",
bold=true,
x=40,
y=165,
colour={{0.5,0X7FFF00,0.5},{1,0XFFFF00,0.3}},
--radial={0,300,0,0,300,370},
orientation="nn",
},
{
text=conky_parse"Load: $loadavg",
font_name="terminus",
font_size=15,
h_align="l",
--v_align="m",
bold=true,
x=40,
y=180,
colour={{0.5,0X7FFF00,0.5},{1,0XFFFF00,0.3}},
--radial={0,300,0,0,300,370},
orientation="nn",
},
{
text=conky_parse"${execi 3600 cat /proc/cpuinfo | grep 'model name' | sed -e 's/model name.*: //' | tail -n1}",
font_name="terminus",
font_size=13,
h_align="l",
--v_align="m",
bold=true,
x=5,
y=205,
colour={{0.5,0X7FFF00,0.5},{1,0XFFFF00,0.3}},
--radial={0,300,0,0,300,370},
orientation="nn",
},
--cpu1
{
text=conky_parse"${cpu cpu0}%",
font_name="terminus",
font_size=15,
h_align="l",
--v_align="m",
bold=true,
x=6,
y=220,
colour={{0.5,0X7FFF00,0.5},{1,0XFFFF00,0.3}},
--radial={0,300,0,0,300,370},
orientation="nn",
},
--cputext
{
text="cpu",
font_name="terminus",
font_size=15,
h_align="l",
--v_align="m",
bold=true,
x=24,
y=280,
colour={{0.5,0X7FFF00,0.5},{1,0XFFFF00,0.3}},
--radial={0,300,0,0,300,370},
angle=-90,
orientation="nn",
},
--cpu2
{
text=conky_parse"${cpu cpu1}%",
font_name="terminus",
font_size=15,
h_align="l",
--v_align="m",
bold=true,
x=45,
y=220,
colour={{0.5,0X7FFF00,0.5},{1,0XFFFF00,0.3}},
--radial={0,300,0,0,300,370},
orientation="nn",
},
--cpu2text
{
text="cpu-1",
font_name="terminus",
font_size=15,
h_align="l",
--v_align="m",
bold=true,
x=64,
y=280,
colour={{0.5,0X7FFF00,0.5},{1,0XFFFF00,0.3}},
--radial={0,300,0,0,300,370},
angle=-90,
orientation="nn",
},
{
text=conky_parse"${cpu cpu2}%",
font_name="terminus",
font_size=15,
h_align="l",
--v_align="m",
bold=true,
x=87,
y=220,
colour={{0.5,0X7FFF00,0.5},{1,0XFFFF00,0.3}},
--radial={0,300,0,0,300,370},
orientation="nn",
},
--cpu2text
{
text="cpu-2",
font_name="terminus",
font_size=15,
h_align="l",
--v_align="m",
bold=true,
x=104,
y=280,
colour={{0.5,0X7FFF00,0.5},{1,0XFFFF00,0.3}},
--radial={0,300,0,0,300,370},
angle=-90,
orientation="nn",
},
--ram
{
text=conky_parse"${cpu cpu3}%",
font_name="terminus",
font_size=15,
h_align="l",
--v_align="m",
bold=true,
x=126,
y=220,
colour={{0.5,0X7FFF00,0.5},{1,0XFFFF00,0.3}},
--radial={0,300,0,0,300,370},
orientation="nn",
},
--memtext
{
text="cpu-3",
font_name="terminus",
font_size=15,
h_align="l",
--v_align="m",
bold=true,
x=144,
y=280,
colour={{0.5,0X7FFF00,0.5},{1,0XFFFF00,0.3}},
--radial={0,300,0,0,300,370},
angle=-90,
orientation="nn",
},
{
text=conky_parse"${cpu cpu4}%",
font_name="terminus",
font_size=15,
h_align="l",
--v_align="m",
bold=true,
x=165,
y=220,
colour={{0.5,0X7FFF00,0.5},{1,0XFFFF00,0.3}},
--radial={0,300,0,0,300,370},
orientation="nn",
},
--memtext
{
text="cpu-4",
font_name="terminus",
font_size=15,
h_align="l",
--v_align="m",
bold=true,
x=184,
y=280,
colour={{0.5,0X7FFF00,0.5},{1,0XFFFF00,0.3}},
--radial={0,300,0,0,300,370},
angle=-90,
orientation="nn",
},
--swap
{
text=conky_parse"${memperc}%",
font_name="terminus",
font_size=15,
h_align="l",
--v_align="m",
bold=true,
x=202,
y=220,
colour={{0.5,0X7FFF00,0.5},{1,0XFFFF00,0.3}},
--radial={0,300,0,0,300,370},
orientation="nn",
},
--swaptext
{
text="mem",
font_name="terminus",
font_size=15,
h_align="l",
--v_align="m",
bold=true,
x=223,
y=280,
colour={{0.5,0X7FFF00,0.5},{1,0XFFFF00,0.3}},
--radial={0,300,0,0,300,370},
angle=-90,
orientation="nn",
},
--root
{
text=conky_parse"${swapperc}%",
font_name="terminus",
font_size=15,
h_align="l",
--v_align="m",
bold=true,
x=247,
y=220,
colour={{0.5,0X7FFF00,0.5},{1,0XFFFF00,0.3}},
--radial={0,300,0,0,300,370},
orientation="nn",
},
--hddtext
{
text="swap",
font_name="terminus",
font_size=15,
h_align="l",
--v_align="m",
bold=true,
x=265,
y=280,
colour={{0.5,0X7FFF00,0.5},{1,0XFFFF00,0.3}},
--radial={0,300,0,0,300,370},
angle=-90,
orientation="nn",
},
--hddtext
--hdd2
{
text=conky_parse"HDD Temp: ${exec hddtemp /dev/sda -n --unit=F}°",
font_name="terminus",
font_size=15,
h_align="l",
--v_align="m",
bold=true,
x=5,
y=320,
colour={{0.5,0X7FFF00,0.5},{1,0XFFFF00,0.3}},
--radial={0,300,0,0,300,370},
orientation="nn",
},
{
text=conky_parse"Diskio_read: ${diskio_read /dev/sdb7} Diskio_write: ${diskio_write /dev/sdb7}",
font_name="terminus",
font_size=15,
h_align="l",
--v_align="m",
bold=true,
x=5,
y=330,
colour={{0.5,0X7FFF00,0.5},{1,0XFFFF00,0.3}},
--radial={0,300,0,0,300,370},
orientation="nn",
},
--hdd2text
{
text="root",
font_name="terminus",
font_size=15,
h_align="l",
--v_align="m",
bold=true,
x=23,
y=390,
colour={{0.5,0X7FFF00,0.5},{1,0XFFFF00,0.3}},
--radial={0,300,0,0,300,370},
angle=-90,
orientation="nn",
},
{
text=conky_parse"${fs_used_perc /}%",
font_name="terminus",
font_size=15,
h_align="l",
--v_align="m",
bold=true,
x=1,
y=346,
colour={{0.5,0X7FFF00,0.5},{1,0XFFFF00,0.3}},
--radial={0,300,0,0,300,370},
orientation="nn",
},
{
text="files",
font_name="terminus",
font_size=15,
h_align="l",
--v_align="m",
bold=true,
x=103,
y=390,
colour={{0.5,0X7FFF00,0.5},{1,0XFFFF00,0.3}},
--radial={0,300,0,0,300,370},
angle=-90,
orientation="nn",
},
{
text=conky_parse"${fs_used_perc /media/manuel/Files}%",
font_name="terminus",
font_size=15,
h_align="l",
--v_align="m",
bold=true,
x=80,
y=346,
colour={{0.5,0X7FFF00,0.5},{1,0XFFFF00,0.3}},
--radial={0,300,0,0,300,370},
orientation="nn",
},
{
text="win10",
font_name="terminus",
font_size=15,
h_align="l",
--v_align="m",
bold=true,
x=183,
y=390,
colour={{0.5,0X7FFF00,0.5},{1,0XFFFF00,0.3}},
--radial={0,300,0,0,300,370},
angle=-90,
orientation="nn",
},
{
text=conky_parse"${fs_used_perc /media/manuel/Windows 10}%",
font_name="terminus",
font_size=15,
h_align="l",
--v_align="m",
bold=true,
x=165,
y=346,
colour={{0.5,0X7FFF00,0.5},{1,0XFFFF00,0.3}},
--radial={0,300,0,0,300,370},
orientation="nn",
},
{
text="mint",
font_name="terminus",
font_size=15,
h_align="l",
--v_align="m",
bold=true,
x=263,
y=390,
colour={{0.5,0X7FFF00,0.5},{1,0XFFFF00,0.3}},
--radial={0,300,0,0,300,370},
angle=-90,
orientation="nn",
},
{
text=conky_parse"${fs_used_perc /media/manuel/61f3f05a-6619-4fa1-90e3-ac333c3461db}%",
font_name="terminus",
font_size=15,
h_align="l",
--v_align="m",
bold=true,
x=240,
y=346,
colour={{0.5,0X7FFF00,0.5},{1,0XFFFF00,0.3}},
--radial={0,300,0,0,300,370},
orientation="nn",
},
{
text=conky_parse"${if_gw}Network:Online DGW:$gw_ip${endif} ",
font_name="terminus",
font_size=15,
h_align="l",
--v_align="m",
bold=true,
x=5,
y=420,
colour={{0.5,0X7FFF00,0.5},{1,0XFFFF00,0.3}},
--radial={0,300,0,0,300,370},
orientation="nn",
},
{
text=conky_parse"Nameserver:$nameserver",
font_name="terminus",
font_size=15,
h_align="l",
--v_align="m",
bold=true,
x=5,
y=432,
colour={{0.5,0X7FFF00,0.5},{1,0XFFFF00,0.3}},
--radial={0,300,0,0,300,370},
orientation="nn",
},
{
text=conky_parse"${if_existing /proc/net/route eth0}Interface:eth0 IP-Address:${addr eth0}${else}${endif}${if_existing /proc/net/route wlan0}Interface:wifi IP-Address:${addr wlan0}${endif}",
font_name="terminus",
font_size=15,
h_align="l",
--v_align="m",
bold=true,
x=5,
y=444,
colour={{0.5,0X7FFF00,0.5},{1,0XFFFF00,0.3}},
--radial={0,300,0,0,300,370},
orientation="nn",
},
{
text=conky_parse"${if_existing /proc/net/route eth0}Speed: Down:${downspeedf eth0} Up:${upspeedf eth0}${else}${endif}${if_existing /proc/net/route wlan0}Speed: Down:${downspeedf wlan0} Up:${upspeedf wlan0}${else}${endif}",
font_name="terminus",
font_size=15,
h_align="l",
--v_align="m",
bold=true,
x=5,
y=470,
colour={{0.5,0X7FFF00,0.5},{1,0XFFFF00,0.3}},
--radial={0,300,0,0,300,370},
orientation="nn",
},
--ul
{
text=conky_parse"TCP Connections ${tcp_portmon 1 65535 count} ${if_existing /proc/net/route wlan0} ESSID: ${wireless_essid wlan0}${endif}",
font_name="terminus",
font_size=15,
h_align="l",
--v_align="m",
bold=true,
x=5,
y=457,
colour={{0.5,0X7FFF00,0.5},{1,0XFFFF00,0.3}},
--radial={0,300,0,0,300,370},
orientation="nn",
},
--ultext
--dl
{
text=conky_parse"${if_existing /proc/net/route wlan0} Qualty: ${wireless_link_qual_perc wlan0}${endif}",
font_name="terminus",
font_size=15,
h_align="l",
--v_align="m",
bold=true,
x=100,
y=500,
colour={{0.5,0X7FFF00,0.5},{1,0XFFFF00,0.3}},
--radial={0,300,0,0,300,370},
orientation="nn",
},
--dltext
--[[ {
text="DL",
font_name="terminus",
font_size=15,
h_align="l",
--v_align="m",
bold=true,
x=40,
y=505,
colour={{0.5,0X7FFF00,0.5},{1,0XFFFF00,0.3}},
--radial={0,300,0,0,300,370},
angle=0,
orientation="nn",
},
{
text="UL",
font_name="terminus",
font_size=15,
h_align="l",
--v_align="m",
bold=true,
x=190,
y=505,
colour={{0.5,0X7FFF00,0.5},{1,0XFFFF00,0.3}},
--radial={0,300,0,0,300,370},
angle=0,
orientation="nn",
},
{
text=conky_parse"${if_existing /proc/net/route eth0}${downspeedf eth0}${endif}${if_existing /proc/net/route wlan0}${downspeedf wlan0}${endif}",
font_name="terminus",
font_size=15,
h_align="l",
--v_align="m",
bold=true,
x=65,
y=505,
colour={{0.5,0X7FFF00,0.5},{1,0XFFFF00,0.3}},
--radial={0,300,0,0,300,370},
orientation="nn",
},
{
text=conky_parse"${if_existing /proc/net/route eth0}${upspeedf eth0}${endif}${if_existing /proc/net/route wlan0}${upspeedf wlan0}${endif}",
font_name="terminus",
font_size=15,
h_align="l",
--v_align="m",
bold=true,
x=215,
y=505,
colour={{0.5,0X7FFF00,0.5},{1,0XFFFF00,0.3}},
--radial={0,300,0,0,300,370},
orientation="nn",
}, --]]
{
text=conky_parse"Battery is ${battery BAT0}. Ac: ${acpiacadapter AC0}",
font_name="terminus",
font_size=15,
h_align="l",
--v_align="m",
bold=true,
x=5,
y=545,
colour={{0.5,0X7FFF00,0.5},{1,0XFFFF00,0.3}},
--radial={0,300,0,0,300,370},
orientation="nn",
},
{
text=conky_parse"${battery_time BAT0} remaining.",
font_name="terminus",
font_size=15,
h_align="l",
--v_align="m",
bold=true,
x=5,
y=560,
colour={{0.5,0X7FFF00,0.5},{1,0XFFFF00,0.3}},
--radial={0,300,0,0,300,370},
orientation="nn",
}, --]]
--processes
--cpuprocesstext
--[[ {
text="cpu processes",
font_name="terminus",
font_size=15,
h_align="l",
--v_align="m",
bold=true,
x=50,
y=385,
colour={{0.5,0XDCDCDC,0.5},{1,0X708090,0.4}},
--radial={0,300,0,0,300,370},
--angle=-90,
orientation="nn",
},
{
text=conky_parse"${top name 1}${top cpu 1}%",
font_name="terminus",
font_size=13,
h_align="l",
--v_align="m",
bold=true,
x=20,
y=405,
colour={{0.5,0xB0E2FF,0.5},{1,0X708090,0.4}},
--radial={0,300,0,0,300,370},
orientation="nn",
},
{
text=conky_parse"${top name 2}${top cpu 2}%",
font_name="terminus",
font_size=13,
h_align="l",
--v_align="m",
bold=true,
x=20,
y=420,
colour={{0.5,0XDCDCDC,0.5},{1,0X708090,0.4}},
--radial={0,300,0,0,300,370},
orientation="nn",
},
{
text=conky_parse"${top name 3}${top cpu 3}%",
font_name="terminus",
font_size=13,
h_align="l",
--v_align="m",
bold=true,
x=20,
y=435,
colour={{0.5,0XDCDCDC,0.5},{1,0X708090,0.4}},
--radial={0,300,0,0,300,370},
orientation="nn",
},
{
text=conky_parse"${top name 4}${top cpu 4}%",
font_name="terminus",
font_size=13,
h_align="l",
--v_align="m",
bold=true,
x=20,
y=450,
colour={{0.5,0XDCDCDC,0.5},{1,0X708090,0.4}},
--radial={0,300,0,0,300,370},
orientation="nn",
},
{
text=conky_parse"${top name 5}${top cpu 5}%",
font_name="terminus",
font_size=13,
h_align="l",
--v_align="m",
bold=true,
x=20,
y=465,
colour={{0.5,0XDCDCDC,0.5},{1,0X708090,0.4}},
--radial={0,300,0,0,300,370},
orientation="nn",
},
--ramprocesstext
{
text="ram processes",
font_name="terminus",
font_size=15,
h_align="l",
--v_align="m",
bold=true,
x=335,
y=385,
colour={{0.5,0XDCDCDC,0.5},{1,0X708090,0.4}},
--radial={0,300,0,0,300,370},
--angle=-90,
orientation="nn",
},
{
text=conky_parse"${top_mem name 1}${top_mem mem 1}%",
font_name="terminus",
font_size=13,
h_align="l",
--v_align="m",
bold=true,
x=295,
y=405,
colour={{0.5,0xB0E2FF,0.5},{1,0X708090,0.4}},
--radial={0,300,0,0,300,370},
orientation="nn",
},
{
text=conky_parse"${top_mem name 2}${top_mem mem 2}%",
font_name="terminus",
font_size=13,
h_align="l",
--v_align="m",
bold=true,
x=295,
y=420,
colour={{0.5,0XDCDCDC,0.5},{1,0X708090,0.4}},
--radial={0,300,0,0,300,370},
orientation="nn",
},
{
text=conky_parse"${top_mem name 3}${top_mem mem 3}%",
font_name="terminus",
font_size=13,
h_align="l",
--v_align="m",
bold=true,
x=295,
y=435,
colour={{0.5,0XDCDCDC,0.5},{1,0X708090,0.4}},
--radial={0,300,0,0,300,370},
orientation="nn",
},
{
text=conky_parse"${top_mem name 4}${top_mem mem 4}%",
font_name="terminus",
font_size=13,
h_align="l",
--v_align="m",
bold=true,
x=295,
y=450,
colour={{0.5,0XDCDCDC,0.5},{1,0X708090,0.4}},
--radial={0,300,0,0,300,370},
orientation="nn",
},
{
text=conky_parse"${top_mem name 5}${top_mem mem 5}%",
font_name="terminus",
font_size=13,
h_align="l",
--v_align="m",
bold=true,
x=295,
y=465,
colour={{0.5,0XDCDCDC,0.5},{1,0X708090,0.4}},
--radial={0,300,0,0,300,370},
orientation="nn",
},--]]
}
--------------END OF PARAMETERES----------------
--------------END OF PARAMETERES----------------
if conky_window == nil then return end
if tonumber(conky_parse("$updates"))<3 then return end
local cs = cairo_xlib_surface_create(conky_window.display, conky_window.drawable, conky_window.visual, conky_window.width, conky_window.height)
for i,v in pairs(text_settings) do
cr = cairo_create (cs)
display_text(v)
cairo_destroy(cr)
cr = nil
end
cairo_surface_destroy(cs)
end
function rgb_to_r_g_b2(tcolour)
local colour,alpha=tcolour[2],tcolour[3]
return ((colour / 0x10000) % 0x100) / 255., ((colour / 0x100) % 0x100) / 255., (colour % 0x100) / 255., alpha
end
function display_text(t)
if t.draw_me==true then t.draw_me = nil end
if t.draw_me~=nil and conky_parse(tostring(t.draw_me)) ~= "1" then return end
local function set_pattern(te)
--this function set the pattern
if #t.colour==1 then
cairo_set_source_rgba(cr,rgb_to_r_g_b2(t.colour[1]))
else
local pat
if t.radial==nil then
local pts=linear_orientation(t,te)
pat = cairo_pattern_create_linear (pts[1],pts[2],pts[3],pts[4])
else
pat = cairo_pattern_create_radial (t.radial[1],t.radial[2],t.radial[3],t.radial[4],t.radial[5],t.radial[6])
end
for i=1, #t.colour do
cairo_pattern_add_color_stop_rgba (pat, t.colour[i][1], rgb_to_r_g_b2(t.colour[i]))
end
cairo_set_source (cr, pat)
cairo_pattern_destroy(pat)
end
end
--set default values if needed
if t.text==nil then t.text="Conky is good for you !" end
if t.x==nil then t.x = conky_window.width/2 end
if t.y==nil then t.y = conky_window.height/2 end
if t.colour==nil then t.colour={{1,0XFFFF00,1}} end
if t.font_name==nil then t.font_name="Arial" end
if t.font_size==nil then t.font_size=15 end
if t.angle==nil then t.angle=0 end
if t.italic==nil then t.italic=false end
if t.oblique==nil then t.oblique=false end
if t.bold==nil then t.bold=false end
if t.radial ~= nil then
if #t.radial~=6 then
print ("error in radial table")
t.radial=nil
end
end
if t.orientation==nil then t.orientation="ww" end
if t.h_align==nil then t.h_align="l" end
if t.v_align==nil then t.v_align="b" end
if t.reflection_alpha == nil then t.reflection_alpha=0 end
if t.reflection_length == nil then t.reflection_length=1 end
if t.reflection_scale == nil then t.reflection_scale=1 end
if t.skew_x==nil then t.skew_x=0 end
if t.skew_y==nil then t.skew_y=0 end
cairo_translate(cr,t.x,t.y)
cairo_rotate(cr,t.angle*math.pi/180)
cairo_save(cr)
local slant = CAIRO_FONT_SLANT_NORMAL
local weight = CAIRO_FONT_WEIGHT_NORMAL
if t.italic then slant = CAIRO_FONT_SLANT_ITALIC end
if t.oblique then slant = CAIRO_FONT_SLANT_OBLIQUE end
if t.bold then weight = CAIRO_FONT_WEIGHT_BOLD end
cairo_select_font_face(cr, t.font_name, slant,weight)
for i=1, #t.colour do
if #t.colour[i]~=3 then
print ("error in color table")
t.colour[i]={1,0XFFFF00,1}
end
end
local matrix0 = cairo_matrix_t:create()
tolua.takeownership(matrix0)
local skew_x,skew_y=t.skew_x/t.font_size,t.skew_y/t.font_size
cairo_matrix_init (matrix0, 1,skew_y,skew_x,1,0,0)
cairo_transform(cr,matrix0)
cairo_set_font_size(cr,t.font_size)
local te=cairo_text_extents_t:create()
tolua.takeownership(te)
local text=conky_parse(t.text)
if text~="" then t.text = text end
cairo_text_extents (cr,t.text,te)
set_pattern(te)
local mx,my=0,0
if t.h_align=="c" then
mx=-te.width/2-te.x_bearing
elseif t.h_align=="r" then
mx=-te.width
end
if t.v_align=="m" then
my=-te.height/2-te.y_bearing
elseif t.v_align=="t" then
my=-te.y_bearing
end
cairo_move_to(cr,mx,my)
cairo_show_text(cr,t.text)
if t.reflection_alpha ~= 0 then
local matrix1 = cairo_matrix_t:create()
tolua.takeownership(matrix1)
cairo_set_font_size(cr,t.font_size)
cairo_matrix_init (matrix1,1,0,0,-1*t.reflection_scale,0,(te.height+te.y_bearing+my)*(1+t.reflection_scale))
cairo_set_font_size(cr,t.font_size)
te=nil
local te=cairo_text_extents_t:create()
tolua.takeownership(te)
cairo_text_extents (cr,t.text,te)
cairo_transform(cr,matrix1)
set_pattern(te)
cairo_move_to(cr,mx,my)
cairo_show_text(cr,t.text)
local pat2 = cairo_pattern_create_linear (0,
(te.y_bearing+te.height+my),
0,
te.y_bearing+my)
cairo_pattern_add_color_stop_rgba (pat2, 0,1,0,0,1-t.reflection_alpha)
cairo_pattern_add_color_stop_rgba (pat2, t.reflection_length,0,0,0,1)
--line is not drawn but with a size of zero, the mask won't be nice
cairo_set_line_width(cr,1)
local dy=te.x_bearing
if dy<0 then dy=dy*(-1) end
cairo_rectangle(cr,mx+te.x_bearing,te.y_bearing+te.height+my,te.width+dy,-te.height*1.05)
cairo_clip_preserve(cr)
cairo_set_operator(cr,CAIRO_OPERATOR_CLEAR)
--cairo_stroke(cr)
cairo_mask(cr,pat2)
cairo_pattern_destroy(pat2)
cairo_set_operator(cr,CAIRO_OPERATOR_OVER)
te=nil
end
end
function linear_orientation(t,te)
local w,h=te.width,te.height
local xb,yb=te.x_bearing,te.y_bearing
if t.h_align=="c" then
xb=xb-w/2
elseif t.h_align=="r" then
xb=xb-w
end
if t.v_align=="m" then
yb=-h/2
elseif t.v_align=="t" then
yb=0
end
local p=0
if t.orientation=="nn" then
p={xb+w/2,yb,xb+w/2,yb+h}
elseif t.orientation=="ne" then
p={xb+w,yb,xb,yb+h}
elseif t.orientation=="ww" then
p={xb,h/2,xb+w,h/2}
elseif vorientation=="se" then
p={xb+w,yb+h,xb,yb}
elseif t.orientation=="ss" then
p={xb+w/2,yb+h,xb+w/2,yb}
elseif t.orientation=="ee" then
p={xb+w,h/2,xb,h/2}
elseif t.orientation=="sw" then
p={xb,yb+h,xb+w,yb}
elseif t.orientation=="nw" then
p={xb,yb,xb+w,yb+h}
end
return p
end
launcher.lua
--paths-must-be->/home/worldchampions/.conky/...
--not--> ~/
function conky_main()
dofile ('/home/manuel/conky-conf/Conky_all_Lua/lua/text.lua')
dofile ('/home/manuel/conky-conf/Conky_all_Lua/lua/equalizer.lua')
dofile ('/home/manuel/conky-conf/Conky_all_Lua/lua/draw_bg.lua')
--dofile ('/home/manuel/conky-conf/Conky_all_Lua/lua/battery.lua')
--call of the two mains functions in the lua files
--conky_main_bars()
conky_draw_text()
conky_main_bars()
conky_draw_bg()
end
draw_bg.lua give and error on this line:
return ((colour / 0x10000) % 0x100) / 255., ((colour / 0x100) % 0x100) / 255., (colour % 0x100) / 255., alpha
Offline
--paths-must-be->/home/worldchampions/.conky/...
--not--> ~/
function conky_main()
dofile ('/home/manuel/conky-conf/Conky_all_Lua/lua/time.lua')
dofile ('/home/manuel/conky-conf/Conky_all_Lua/lua/draw_bg.lua')
--call of the two mains functions in the lua files
digits(n)
conky_draw_bg()
end
time.lua
words = {"One ", "Two ", "Three ", "Four ", "Five ", "Six ", "Seven ", "Eight ", "Nine "}
levels = {"THOUSAND ", "MILLION ", "BILLION ", "TRILLION ", "QUADRILLION ", "QUINTILLION ", "SEXTILLION ", "SEPTILLION ", "OCTILLION ", [0] = ""}
iwords = {"Ten ", "Twenty ", "Thirty ", "Forty ", "Fifty ", "Sixty ", "Seventy ", "Eighty ", "Ninety "}
twords = {"Eleven ", "Twelve ", "Thirteen ", "Fourteen ", "Fifteen ", "Sixteen ", "Seventeen ", "Eighteen ", "Nineteen "}
function digits(n)
local i, ret = -1
return function()
i, ret = i + 1, n % 10
if n > 0 then
n = math.floor(n / 10)
return i, ret
end
end
end
level = false
function getname(pos, dig)
level = level or pos % 3 == 0
if(dig == 0) then return "" end
local name = (pos % 3 == 1 and iwords[dig] or words[dig]) .. (pos % 3 == 2 and "HUNDRED " or "")
if(level) then name, level = name .. levels[math.floor(pos / 3)], false end
return name
end
function numberToWord(number)
if(number == 0) then return "Zero" end
vword = ""
for i, v in digits(number) do
vword = getname(i, v) .. vword
end
for i, v in ipairs(words) do
vword = vword:gsub("TY " .. v, "TY-" .. v)
vword = vword:gsub("Ten " .. v, twords[i])
end
return vword
end
function conky_Hour()
return numberToWord(os.date("%I") + 0)
end
function conky_Minute()
return numberToWord(os.date("%M") + 0)
end
function conky_Date()
return numberToWord(os.date("%d") + 0)
end
conkyrc
lua_draw_hook_post = 'draw_bg 20 0 0 0 0 0x000000 0.4',
-- -- Album art fix -- #
imlib_cache_size = 0,
lua_load = '~/conky-conf/Conky_all_Lua/lua/launcher2.lua',
lua_draw_hook_pre = 'main',
};
conky.text = [[
${color3}${offset 10}${font Justice:size=22:Bold}${lua Hour}${lua Minute}
#${color3}${offset 15}${font DymaxionScript:size=21}${time %a %d ,%b %Y}
${voffset 10}${color3}${offset 15}${font Justice:size=19:Bold}${time %a %d ,%b %Y}
#${voffset}${color3}${offset 15}${font Alba:size=21}${time %a %d ,%b %Y}
]];
same error with draw_bg.lua but work's
Offline
You can make a package and launch the conky_draw_bg function from there, something like this:
launcher2.lua
--paths-must-be->/home/worldchampions/.conky/...
--not--> ~/
package.path = '/home/manuel/conky-conf/Conky_all_Lua/?.lua'
require 'draw_bg'
require 'text'
require 'time'
require 'equalizer'
function conky_main()
conky_draw_bg(10, 30, 5, 241, 80, 0x000000, 0.4)
conky_draw_bg(10, 30, 90, 241, 95, 0x000000, 0.4)
end
and from launcher2 delete the line
lua_draw_hook_post = 'draw_bg 20 0 0 0 0 0x000000 0.4',
Offline
Thank you indian for your reply..
I will try the launcher... :-)
Did you now how to fix the draw_bg error?
Offline
indian i try the launcher code with no luck it won't run the conkyrc..
any ideas?
Offline
Do you have all the lua scripts in this folder /home/manuel/conky-conf/Conky_all_Lua/ ?
Have you deleted line lua_draw_hook_post = 'draw_bg 20 0 0 0 0 0x000000 0.4', from the conkyrc file?
How do you launch conky?
I have modified the launcher to get the time script working
package.path = '/home/manuel/conky-conf/Conky_all_Lua/?.lua'
require 'draw_bg'
require 'text'
require 'time'
require 'equalizer'
function conky_Hour_Main()
return conky_Hour()
end
function conky_Minute_Main()
return conky_Minute()
end
function conky_main()
conky_draw_bg(10, 30, 5, 241, 80, 0x000000, 0.4)
conky_draw_bg(10, 30, 90, 241, 95, 0x000000, 0.4)
digits()
end
And in the conkyrc the i have also modified the first line in conky.text
${color3}${offset 10}${font Justice:size=22:Bold}${lua Hour_Main}${lua Minute_Main}
And i get something similar to the example1 image you have posted.
Offline
It works, using conky_draw_bg(10, 30, 5, 241, 80, 0x000000, 0.4) get background one size,
and using lua_draw_hook_post = 'draw_bg 20 0 0 0 0 0x000000 0.4', inside conky backround change with the text size..
Thank you indian..
Offline
It works, using conky_draw_bg(10, 30, 5, 241, 80, 0x000000, 0.4) get background one size,
and using lua_draw_hook_post = 'draw_bg 20 0 0 0 0 0x000000 0.4', inside conky backround change with the text size..
^ Please show!
Offline
Yeah, picture or it didn't happen!
Offline
package.path = '/home/manuel/conky-conf/Conky_all_Lua/lua/?.lua'
require 'draw_bg'
require 'time'
function conky_Hour_Main()
return conky_Hour()
end
function conky_Minute_Main()
return conky_Minute()
end
function conky_main()
-- conky_draw_bg(10, 10, 10, 241, 35, 0x000000, 0.4)
-- conky_draw_bg(10, 30, 90, 241, 95, 0x000000, 0.4)
digits()
end
with this in conky
lua_draw_hook_post = 'draw_bg 20 0 0 0 0 0x000000 0.3',
-- -- Album art fix -- #
imlib_cache_size = 0,
lua_load = '~/conky-conf/Conky_all_Lua/lua/launcher2.lua',
lua_draw_hook_pre = 'main',
Offline
^That's really cool, especially that weather and moon panel!
Offline
^ @Indian, @manuel-909
Okay, very nice! An excellent job.
Thus we have in Conky1.10 with "the help" of the Lua-Script
draw_bg.lua again the "round corners" and a background to be modified accordingly. Right? ]:D
Sector11 would say now, which one of you puts this in a sticky here in the forum, so that everyone gets something out of it? Because the theme of this thread does not express it...
My personal opinion is (without diminishing your work!), also in the future the user will have his trouble with the syntax of version 1.10. There's no way around it!
You guys are tops! O:)
Offline
i find a conky conf really nice have a loadall.lua that work's nice you have to make a foler for what you wan't to run.....
autostart-All.sh
#!/bin/sh
# You can use this script to create an autostart,it will cd into the theme folder before executing conky
# Conkies can be started individually through terminal from their directory (conky -c conky.conf or cd /path/to/theme/ && conky -c conky.conf)
killall conky
# Making sure theme-dir is working-dir
cd "$(dirname "$0")"
# start system conky
sh conky-system-lua-V3/autostart.sh
sleep 1
# start clock conky
sh conky-clock-lua-V1/autostart.sh
sleep 1
# start cores conky
sh conky-cores-lua/autostart.sh
sleep 1
# start vnstat conky
sh conky-vnstat-lua/autostart.sh
sleep 10
# start vnstat conky
sh conky-weather-lua/autostart.sh
exit
autostart.sh
#!/bin/sh
# You can use this script to create an autostart,it will cd into the theme folder before executing conky
# Conkies can be started individually through terminal from their directory (conky -c conky.conf or cd /path/to/theme/ && conky -c conky.conf)
#killall conky
# Making sure theme-dir is working-dir
cd "$(dirname "$0")"
( set -x; setsid conky -c cores.conf )
exit
loadall.lua
-- Set the path to the scripts folder
package.path = "./scripts/?.lua"
-- ###################################
require 'lua0-box'
require 'lua1-graphs'
require 'lua2-text'
require 'lua3-bars'
function conky_main()
conky_main_box()
conky_main_graph()
conky_draw_text()
conky_main_bars()
end
--[[
#########################
# conky-system-lua-V3 #
# by +WillemO @wim66 #
# v1.5 23-dec-17 #
# #
#########################
]]
you can download at:
https://wim66.deviantart.com/art/conky- … -719087192
i fix it for my laptop....
Offline