You are not logged in.
Here's my conky, at least what i have so far. It isnt finished yet. All images are written with lua, no image files are used. It does have a memory leak...working on fixing it.
--base_conkyrc
# -- Conky settings meters-- #
background no
update_interval 1.0
cpu_avg_samples 2
net_avg_samples 2
override_utf8_locale yes
format_human_readable yes
double_buffer yes
no_buffers yes
text_buffer_size 4048
imlib_cache_size 0
imlib_cache_flush_interval 0
# -- Window specifications -- #
own_window yes
own_window_type normal
own_window_transparent yes
own_window_argb_visual yes
own_window_hints undecorate,sticky,skip_taskbar,skip_pager,below
own_window_title graph widgets
border_inner_margin 0
border_outer_margin 0
minimum_size 1000 160
alignment bm
gap_y -8
gap_x -54
# -- Graphics settings -- #
draw_shades no
draw_outline no
draw_borders no
draw_graph_borders no
# -- Text settings -- #
use_xft yes
xftfont Inconsolata-g:size=6
xftalpha 0.85
uppercase no
# +++++ Colors +++++
default_shade_color ffffff
default_color FFFFFF
# -- Lua load -- #
lua_load ~/.conky/experimental/Graph.lua
lua_load ~/.conky/experimental/Rings.lua ~/.conky/experimental/bargraph1.lua ~/.conky/experimental/text.lua
lua_draw_hook_pre main_graph
lua_draw_hook_post main_rings
# -- Begin Conky Text -- #
TEXT
# -- Top Bar -- #
${font Droid Sans Mono:Bold:size=7}
${color #5a5a5a}${goto 825}${voffset 39}GPU${goto 725}NET${goto 146}CPU${goto 51}MEM
${color #4a4a4a}${goto 826}${voffset -11}GPU${goto 726}NET${goto 145}CPU${goto 50}MEM
${color #eeeeee}${goto 825}${voffset -12}GPU${goto 725}NET${goto 146}CPU${goto 51}MEM
${color #5a5a5a}${alignc 54}${voffset -13}${kernel}
${color #4a4a4a}${alignc 55}${voffset -11}${kernel}
${color #eeeeee}${alignc 54}${voffset -12}${kernel}
${font Droid Sans Mono:Bold:size=5}${shadecolor #cccccc}
${color #aaaaaa}${alignc 54}${voffset -12}Uptime: ${uptime}
${color #1a1a1a}${alignc 54}${voffset -10}Uptime: ${uptime}
${color #aaaaaa}${goto 353}PROC${goto 445}PID${goto 481}CPU%${goto 521}MEM%
${color #1a1a1a}${goto 353}${voffset -10}PROC${goto 445}PID${goto 481}CPU%${goto 521}MEM%
${color #aaaaaa}${goto 213}${voffset -22}${execi 300 cat /proc/cpuinfo | grep 'model name' | head -n1 | sed -e 's/model name.*: //' | cut -c 1-10}${goto 623}${addr wlan0}${goto 793}${execi 300 lspci | grep VGA | tail -c+36 | head -n1 | cut -c 1-6}
${color #2a2a2a}${goto 213}${voffset -10}${execi 300 cat /proc/cpuinfo | grep 'model name' | head -n1 | sed -e 's/model name.*: //' | cut -c 1-10}${goto 623}${addr wlan0}${goto 793}${execi 300 lspci | grep VGA | tail -c+36 | head -n1 | cut -c 1-6}
${color #aaaaaa}${goto 213}${execi 300 cat /proc/cpuinfo | grep 'model name' | head -n1 | sed -e 's/model name.*: //' | cut -c 12-26}${goto 600}.::${execi 120 wget -q -O - checkip.dyndns.org | sed -e 's/[^[:digit:]|.]//g'}::.${goto 758}${execi 300 lspci | grep VGA | tail -c+36 | head -n1 | cut -c 24-41}
${color #2a2a2a}${goto 213}${voffset -10}${execi 300 cat /proc/cpuinfo | grep 'model name' | head -n1 | sed -e 's/model name.*: //' | cut -c 12-26}${goto 600}.::${execi 120 wget -q -O - checkip.dyndns.org | sed -e 's/[^[:digit:]|.]//g'}::.${goto 758}${execi 300 lspci | grep VGA | tail -c+36 | head -n1 | cut -c 24-41}
${color #aaaaaa}${goto 76}${voffset -12}${memmax}::.
${color #2a2a2a}${goto 76}${voffset -10}${memmax}::.
# -- End Top Bar -- #
${font}
# -- MEM -- #
${color #000000}${goto 65}${font nconsolata-g:size=5}${voffset 16}$mem${alignr 870}$memperc%
${color #000000}${goto 65}${voffset 11}Swap:$swap${alignr 870}$swapperc%${font}
# -- CPU -- #
${color #000000}${alignc 345}${voffset -41}${hwmon temp 1}°
${color #ff4c94}${alignc 345}${voffset -11}${hwmon temp 1}°
${goto 170}${color #000000}${voffset -3}${freq_g cpu1}Ghz${alignr 676}${cpu cpu1%}%
${goto 170}${voffset 12}${freq_g cpu2}Ghz${alignr 676}${cpu cpu2%}%
# -- PROC --#
${goto 350}${voffset -37}${top name 1} ${top pid 1} ${top cpu 1} ${top mem 1}
${goto 350}${color #1a1a1a}${top name 2} ${top pid 2} ${top cpu 2} ${top mem 2}
${goto 350}${color #1a1a1a}${top name 3} ${top pid 3} ${top cpu 3} ${top mem 3}
${goto 350}${color #000000}${top name 4} ${top pid 4} ${top cpu 4} ${top mem 4}
${color #000000}
# -- NET -- #
${font VariShapes Solid:size=5}
${color #2a2a2a}${goto 561}${voffset -57}q ${font}${color #000000}${upspeedf wlan0}ks${alignr 266}${voffset 2}M:${execi 300 python2 ~/.conky/conkyparts/vnstat-conky-script.py -s}
${color #2a2a2a}${font VariShapes Solid:size=5}${goto 561}${voffset 8}Q ${font}${color #000000}${downspeedf wlan0}ks${alignr 266}${voffset 2}M:${execi 300 python2 ~/.conky/conkyparts/vnstat-conky-script.py -r}
${alignr 266}${voffset -39}D:${execi 300 python2 ~/.conky/conkyparts/vnstatDAILY-conky-script.py -s}
${alignr 266}${voffset 12}D:${execi 300 python2 ~/.conky/conkyparts/vnstatDAILY-conky-script.py -r}
# -- GPU -- #
${color #000000}${alignc -257}${voffset -33}${nvidia temp}°
${color #ff4c94}${alignc -257}${voffset -11}${nvidia temp}°
${color #000000}${goto 772}${font nconsolata-g:size=5}${voffset -7}GPUfreq:${alignr 162}${nvidia gpufreq}MHz
${color #000000}${goto 772}${voffset 11}Driver:${alignr 162}${execi 300 cat /proc/driver/nvidia/version | awk '/NVIDIA/ {print $8}'}
${color #000000}${goto 65}${voffset -10}Cache${alignr 870}$cached%
${color #000000}${goto 772}${voffset -18}Res:${alignr 162}${execi 300 nvidia-settings -q FrontEndResolution -t}
--Graph.lua
--[[ GRAPH widget v1.0 by wlourf (31.10.2010)
this widget draws some graphs with some effects
http://u-scripts.blogspot.com/2010/10/graph-widget.html
To call the script in a conky, use, before TEXT
lua_load /path/to/the/script/graph.lua
lua_draw_hook_pre main_graph
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 cpu1}, just write arg="cpu1"
arg can be a numerical value if name=""
max - the maximum value the above variable can reach,
for example for {$cpu cpu1}, just write max=100 or less or more
Optional parameters:
x,y - coordinates of the bottom-left corner of the graph,
relative to the top-left corner of the conky window
default = bottom-left corner of the conky window
width - width of the graph, default = 100 pixels
height - height of the graph, default = 20 pixels
nb_values - number of values to display in the graph, default=width
i.e. 1 pixel for 1 value
autoscale - if set to true, calculate the max valeu of the y axis and
doesn't use the max parameter above, default=false
skew_x - skew graph around x axis, défaut = 0
skew_y - skew graph around y axis, défaut = 0
angle - angle of rotation of the graph in degress, default = 0
i.e. a horizontal graph)
inverse - if set to true, graph are draw from right to left, default=false
background - if set to false, background is not drawn, default=true
foreground - if set to false, foreground is not drawn, default=true
foreground = plain graph
bg_bd_size - size of the border of the background, default=0=no border
fg_bd_size - size of the border of the foreground, default=0=no border
Colours tables below are defined into braces :
{position in the gradient (0 to 1), colour in hexadecimal, alpha (0 to 1)}
example for a single colour table :
{{0,0xFFAA00,1}} position parameter doesn't matter
example for a two-colours table :
{{0,0xFFAA00,1},{1,0x00AA00,1}} or {{0.5,0xFFAA00,1},{1,0x00AA00,1}}
example for a three-colours table :
{{0,0xFFAA00,1},{0.5,0xFF0000,1},{1,0x00AA00,1}}
bg_colour - colour table for background,
default = {{0,0x000000,.5},{1,0xFFFFFF,.5}}
fg_colour - colour table for foreground,
default = {{0,0x00FFFF,1},{1,0x0000FF,1}}
bg_bd_colour- colour table for background border,
default = {{1,0xFFFFFF,1}}
fg_bd_colour- colour table for foreground border,
default = {{1,0xFFFF00,1}}
bg_orientation, bg_bd_orientation, fg_orientation, fg_bd_orientation,
- "orientation" defines the starting point of the gradient,
default="nn"
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 graph
so a gradient "nn" will go from "nn" to "ss"
a gradient "nw" will go from "nw" to "se"
v1.0 (31 Oct. 2010) original release
-- 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'
function set_settings()
graph_settings={
--GLASS TOP----------------------------------------------------------
--Top Glass Base and Outline
{
name="time",
arg="%M",
max=60,
y=81,
x=46,
width=802,
height=30,
foreground=false,
bg_bd_size=0.5,
bg_colour = { {0,0xffffff,0.5},{0.4,0xFFFFFF,0.1},{1,0xffffff,0.1}},
bg_bd_colour = { {0,0xFFFFFF,1},{1,0xFFFFFF,0}},
bg_orientation="nn",
},
--Top Glass Inner Bevel
--[[ {
name="time",
arg="%M",
max=60,
y=81,
x=46,
width=802,
height=30,
foreground=false,
bg_colour = { {0,0xffffff,0},{0.5,0xFFFFFF,0.2},{1,0xffffff,0}},
bg_orientation="ww",
}, ]]
--END GLASS TOP---------------------------------------------
--
--SHADOWS---------------------------------------------------
--Top Shadow
{
name="time",
arg="%M",
max=60,
y=51,
x=45,
width=804,
height=11,
foreground=false,
bg_colour = { {0,0x000000,0},{0.5,0x000000,0.1},{1,0x000000,0.25}},
bg_orientation="nn",
},
--Top Shadow Right Side
{
name="time",
arg="%M",
max=60,
y=82,
x=849,
width=11,
height=31,
foreground=false,
bg_colour = { {0,0x000000,0.25},{0.5,0x000000,0.1},{1,0x000000,0}},
bg_orientation="ww",
},
--Top Shadow Left Side
{
name="time",
arg="%M",
max=60,
y=82,
x=34,
width=11,
height=31,
foreground=false,
bg_colour = { {0,0x000000,0},{0.5,0x000000,0.1},{1,0x000000,0.25}},
bg_orientation="ww",
},
--Bottom Shadow
{
name="time",
arg="%M",
max=60,
y=141,
x=45,
width=804,
height=11,
foreground=false,
bg_colour = { {0,0x000000,0.25},{0.5,0x000000,0.1},{1,0x000000,0}},
bg_orientation="nn",
},
--Left Side corner shadow
{
name="time",
arg="%M",
max=60,
y=51,
x=35.5,
width=9.5,
height=9.5,
foreground=false,
bg_colour = { {0,0x000000,0},{0.75,0x000000,0.1},{1,0x000000,0.25}},
bg_orientation="nw",
},
--Right Side corner shadow
{
name="time",
arg="%M",
max=60,
y=51,
x=849,
width=9.5,
height=9.5,
foreground=false,
bg_colour = { {0,0x000000,0.25},{0.25,0x000000,0.1},{1,0x000000,0}},
bg_orientation="sw",
},
--END SHADOWS-----------------------------------------------------------
--
--BASE BACKGROUND-------------------------------------------------------
--Background###Set color value 000000 to 1a1a1a when using black background!
{
name="time",
arg="%M",
max=60,
y=130,
x=45,
width=804,
height=48,
foreground=false,
bg_bd_size=0,
bg_colour = { {0,0x000000,0.65},{0.5,0x999999,0.95},{1,0x000000,0.65}},
--bg_bd_colour = { {0,0x000000,0},{0.5,0x000000,0.4},{1,0x000000,0}},
bg_orientation="nn",
--bg_bd_orientation="ww",
},
--background insett
{
name="time",
arg="%M",
max=60,
y=130,
x=45,
width=804,
height=48,
foreground=false,
bg_bd_size=0,
bg_colour = { {0,0x000000,0.0},{0.03,0xababab,0.75},{0.06,0x000000,0.0},{0.5,0x000000,0.0},{0.93,0x000000,0.0},{0.96,0xababab,0.75},{1,0x000000,0.0}},
--bg_bd_colour = { {0,0x000000,0},{0.5,0x000000,0.4},{1,0x000000,0}},
bg_orientation="nn",
--bg_bd_orientation="ww",
},
--END BASE BACKGROUND-------------------------------------------------
--
--BASE AVERAGE CPU FOREGROUND-----------------------------------------
--[[ {
name="cpu",
arg="cpu0",
max=100,
y=106,
x=45,
autoscale=true,
width=804,
height=24,
background=false,
nb_values=201,
fg_colour = { {0,0xffffff,0},{0.5,0xffffff,0.4},{1,0xffffff,0}},
fg_orientation="ww",
},
{
name="cpu",
arg="cpu0",
max=100,
y=106,
x=849,
autoscale=true,
width=804,
height=24,
angle=180,
inverse=true,
background=false,
nb_values=201,
fg_colour = { {0,0xffffff,0},{0.5,0xffffff,0.4},{1,0xffffff,0}},
fg_orientation="ww",
}, ]]
--END BASE AVERAGE CPU FOREGROUND----------------------------------
--
--INTERNAL GRAPHS--------------------------------------------------
--CPU
{
name="cpu",
arg="cpu1",
max=100,
y=104,
x=167,
autoscale=true,
width=164,
height=18,
nb_values=164,
inverse=true,
bg_bd_size=0.5,
bg_colour = { {0,0x000000,0.35},{0.6,0xFFFFFF,0.45},{1,0x000000,0}},
bg_bd_colour = { {0,0x000000,0.35},{1,0x000000,0}},
fg_colour = { {0,0x0066ff,0},{0.6,0x0066ff,1},{1,0x0066ff,0}},
bg_orientation="nn",
bg_bd_orientation="nn",
fg_orientation="nn",
},
{
--cpu2 bar
name="cpu",
arg="cpu2",
max=100,
y=108,
x=331,
autoscale=true,
width=164,
height=18,
nb_values=164,
angle=180,
--inverse=true,
bg_bd_size=0.5,
bg_colour = { {0,0x000000,0.35},{0.6,0xFFFFFF,0.45},{1,0x000000,0}},
bg_bd_colour = { {0,0x000000,0.35},{1,0x000000,0}},
fg_colour = { {0,0x9900ff,0},{0.6,0x9900ff,1},{1,0x9900ff,0}},
bg_orientation="nn",
bg_bd_orientation="nn",
fg_orientation="nn",
},
--DIVIDERS--------------------------------
----proc left
{
name="time",
arg="%M",
max=60,
y=126,
x=335,
width=6,
height=40,
foreground=false,
bg_bd_size=0.5,
bg_colour = { {0,0xffffff,0},{0.35,0xffffff,0.35},{0.5,0x000000,0.6},{0.75,0xffffff,0.35},{1,0xffffff,0}},
bg_bd_colour = { {0,0x000000,0},{0.5,0x000000,0.6},{1,0x000000,0}},
bg_orientation="ww",
bg_bd_orientation="ww",
},
----proc right
{
name="time",
arg="%M",
max=60,
y=126,
x=549,
width=6,
height=40,
foreground=false,
bg_bd_size=0.5,
bg_colour = { {0,0xffffff,0},{0.35,0xffffff,0.35},{0.5,0x000000,0.6},{0.75,0xffffff,0.35},{1,0xffffff,0}},
bg_bd_colour = { {0,0x000000,0},{0.5,0x000000,0.6},{1,0x000000,0}},
bg_orientation="ww",
bg_bd_orientation="ww",
},
----net right
{
name="time",
arg="%M",
max=60,
y=126,
x=743,
width=6,
height=40,
foreground=false,
bg_bd_size=0.5,
bg_colour = { {0,0xffffff,0},{0.35,0xffffff,0.35},{0.5,0x000000,0.6},{0.75,0xffffff,0.35},{1,0xffffff,0}},
bg_bd_colour = { {0,0x000000,0},{0.5,0x000000,0.6},{1,0x000000,0}},
bg_orientation="ww",
bg_bd_orientation="ww",
},
----cpu left
{
name="time",
arg="%M",
max=60,
y=126,
x=141,
width=6,
height=40,
foreground=false,
bg_bd_size=0.5,
bg_colour = { {0,0xffffff,0},{0.35,0xffffff,0.35},{0.5,0x000000,0.6},{0.75,0xffffff,0.35},{1,0xffffff,0}},
bg_bd_colour = { {0,0x000000,0},{0.5,0x000000,0.6},{1,0x000000,0}},
bg_orientation="ww",
bg_bd_orientation="ww",
},
--END DIVIDERS-----------------------------------------------
--
--ROWS/COLUMNS------------------------------------------------
--stripes proc
{
name="time",
arg="%M",
max=60,
y=126,
x=345,
width=200,
height=40,
foreground=false,
bg_bd_size=1,
bg_colour = { {0,0x000000,0.4},{0.05,0xababab,1},{0.125,0xababab,1},{0.2,0xababab,1},{0.25,0x000000,0.4},{0.3,0xababab,1},{0.375,0xababab,1},{0.45,0xababab,1},{0.5,0x000000,0.4},{0.55,0xababab,1},{0.625,0xababab,1},{0.7,0xababab,1},{0.75,0x000000,0.4},{0.8,0xababab,1},{0.875,0xababab,1},{0.95,0xababab,1},{1,0x000000,0.4}},
bg_bd_colour = { {0,0x000000,0.35},{0.5,0x000000,0},{1,0x000000,0.35}},
bg_orientation="nn",
},
---stripes mem
{
name="time",
arg="%M",
max=60,
y=135,
x=63,
width=73,
height=39,
foreground=false,
bg_bd_size=1,
bg_colour = { {0,0x000000,0.4},{0.05,0xababab,1},{0.125,0xababab,1},{0.2,0xababab,1},{0.25,0x000000,0.4},{0.3,0xababab,1},{0.375,0xababab,1},{0.45,0xababab,1},{0.5,0x000000,0.4},{0.55,0xababab,1},{0.625,0xababab,1},{0.7,0xababab,1},{0.75,0x000000,0.4},{0.8,0x000000,0.0},{1,0x000000,0.0}},
bg_bd_colour = { {0,0x000000,0},{0.4,0x000000,0.35},{1,0x000000,00}},
bg_orientation="nn",
},
---stripes gpu
{
name="time",
arg="%M",
max=60,
y=126,
x=769,
width=73,
height=39,
foreground=false,
bg_bd_size=1,
bg_colour = { {0,0x000000,0.4},{0.05,0xababab,1},{0.125,0xababab,1},{0.2,0xababab,1},{0.25,0x000000,0.4},{0.3,0xababab,1},{0.375,0xababab,1},{0.45,0xababab,1},{0.5,0x000000,0.4},{0.55,0xababab,1},{0.625,0xababab,1},{0.7,0xababab,1},{0.75,0x000000,0.4},{0.8,0x000000,0.0},{1,0x000000,0.0}},
bg_bd_colour = { {0,0x000000,0.35},{0.6,0x000000,0},{1,0x000000,0.15}},
bg_orientation="nn",
},
--END ROWS/COLUMNS------------------------------------------------
--NET
{
name="upspeedf",
arg="wlan0",
max=100,
y=104,
x=559,
autoscale=true,
width=180,
height=18,
nb_values=180,
bg_bd_size=1,
bg_colour = { {0,0x000000,0.35},{0.6,0xFFFFFF,0.45},{1,0x000000,0}},
bg_bd_colour = { {0,0x000000,0.35},{1,0x000000,0}},
fg_colour = { {0,0xe5ff00,0},{0.55,0xe5ff00,1},{1,0xe5ff00,0}},
bg_orientation="nn",
bg_bd_orientation="nn",
fg_orientation="nn",
},
{
name="downspeedf",
arg="wlan0",
max=100,
y=108,
x=739,
autoscale=true,
width=180,
height=18,
angle=180,
inverse=true,
nb_values=180,
bg_bd_size=1,
bg_colour = { {0,0x000000,0.35},{0.6,0xFFFFFF,0.45},{1,0x000000,0}},
bg_bd_colour = { {0,0x000000,0.35},{1,0x000000,0}},
fg_colour = { {0,0x00ff19,0},{0.55,0x00ff19,1},{1,0x00ff19,0}},
bg_orientation="nn",
bg_bd_orientation="nn",
fg_orientation="nn",
},
--Cpu temp back
{
name="time",
arg="%M",
max=100,
y=126,
x=150,
autoscale=true,
width=11,
height=33,
--angle=180,
--inverse=true,
nb_values=2,
bg_bd_size=1,
bg_colour = { {0,0x000000,0},{0.5,0xffffff,0.45},{1,0x000000,0}},
bg_bd_colour = { {0,0x000000,0},{0.5,0x000000,0.6},{1,0x000000,0}},
fg_colour = { {0,0x00ff19,0},{0.5,0x00ff19,0},{1,0x00ff19,0}},
bg_orientation="ww",
bg_bd_orientation="ww",
fg_orientation="ww",
},
--Gpu temp back
{
name="time",
arg="%M",
max=100,
y=126,
x=752,
autoscale=true,
width=11,
height=33,
--angle=180,
--inverse=true,
nb_values=2,
bg_bd_size=1,
bg_colour = { {0,0x000000,0},{0.5,0xffffff,0.45},{1,0x000000,0}},
bg_bd_colour = { {0,0x000000,0},{0.5,0x000000,0.6},{1,0x000000,0}},
fg_colour = { {0,0x00ff19,0},{0.5,0x00ff19,0},{1,0x00ff19,0}},
bg_orientation="ww",
bg_bd_orientation="ww",
fg_orientation="ww",
},
--END INTERNAL GRAPHS--------------------------------------------
}
end
function check_settings(t)
--tables are check only when conky start
if t.name==nil and t.arg==nil then
print ("No input values ... use parameters 'name'" ..
" with 'arg' or only parameter 'arg' ")
return 1
end
if t.max==nil then
print ("No maximum value defined, use 'max'")
print ("for name=" .. t.name .. " with arg=" .. t.arg)
return 1
end
if t.name==nil then t.name="" end
if t.arg==nil then t.arg="" end
return 0
end
function conky_main_graph()
if conky_window == nil then return end
local w=conky_window.width
local h=conky_window.height
local cs=cairo_xlib_surface_create(conky_window.display,
conky_window.drawable, conky_window.visual, w, h)
cr=cairo_create(cs)
updates=tonumber(conky_parse('${updates}'))
--start drawing after "updates_gap" updates
--prevent segmentation error for cpu
updates_gap=5
if updates==1 then
set_settings()
flagOK=0
for i in pairs(graph_settings) do
if graph_settings[i].width==nil then graph_settings[i].width=100 end
if graph_settings[i].nb_values==nil then
graph_settings[i].nb_values= graph_settings[i].width
end
--create an empty table to store values
graph_settings[i]["values"]={}
--beginning point
graph_settings[i].beg = graph_settings[i].nb_values
--graph_settings[i].beg = 0
for j =1, graph_settings[i].nb_values do
graph_settings[i].values[j]=0
end
graph_settings[i].flag_init=true
flagOK=flagOK + check_settings(graph_settings[i])
end
end
if flagOK>0 then
--abort script if error in one of the tables
print ("ERROR : Check the graph_setting table")
return
end
--drawing process
if updates > updates_gap then
for i in pairs(graph_settings) do
local nb_values=graph_settings[i].nb_values
graph_settings[i].automax=0
for j =1, nb_values do
if graph_settings[i].values[j+1]==nil then
graph_settings[i].values[j+1]=0
end
graph_settings[i].values[j]=graph_settings[i].values[j+1]
if j==nb_values then
--store value
if graph_settings[i].name=="" then
value=graph_settings[i].arg
else
value=tonumber(conky_parse('${' ..
graph_settings[i].name .. " " ..
graph_settings[i].arg ..'}'))
end
graph_settings[i].values[nb_values]=value
end
graph_settings[i].automax=math.max(graph_settings[i].automax,
graph_settings[i].values[j])
end
draw_graph(graph_settings[i])
end
end
cairo_destroy(cr)
cairo_surface_destroy(cs)
end
function draw_graph(t)
--drawing function
local function rgb_to_r_g_b(colour)
return ((colour[2] / 0x10000) % 0x100) / 255., ((colour[2] / 0x100) % 0x100) / 255., (colour[2] % 0x100) / 255., colour[3]
end
local function linear_orientation(o,w,h)
--set gradient for bg and bg border
if o=="nn" then
p={w/2,h,w/2,0}
elseif o=="ne" then
p={w,h,0,0}
elseif o=="ww" then
p={0,h/2,w,h/2}
elseif o=="se" then
p={w,0,0,h}
elseif o=="ss" then
p={w/2,0,w/2,h}
elseif o=="ee" then
p={w,h/2,0,h/2}
elseif o=="sw" then
p={0,0,w,h}
elseif o=="nw" then
p={0,h,w,0}
end
return p
end
local function linear_orientation_inv(o,w,h)
--set gradient for fg and fg border
if o=="ss" then
p={w/2,h,w/2,0}
elseif o=="sw" then
p={w,h,0,0}
elseif o=="ee" then
p={0,h/2,w,h/2}
elseif o=="nw" then
p={w,0,0,h}
elseif o=="nn" then
p={w/2,0,w/2,h}
elseif o=="ww" then
p={w,h/2,0,h/2}
elseif o=="ne" then
p={0,0,w,h}
elseif o=="se" then
p={0,h,w,0}
end
return p
end
--set default values
if t.height==nil then t.height=20 end
--checked in previous part : width and nb_values
if t.background==nil then t.background=true end
if t.bg_bd_size==nil then t.bg_bd_size=0 end
if t.x==nil then t.x=t.bg_bd_size end
if t.y==nil then t.y=conky_window.height -t.bg_bd_size end
if t.bg_colour==nil then t.bg_colour={{0,0x000000,.5},{1,0xFFFFFF,.5}} end
if t.bg_bd_colour==nil then t.bg_bd_colour={{1,0xFFFFFF,1}} end
if t.foreground==nil then t.foreground=true end
if t.fg_colour==nil then t.fg_colour={{0,0x00FFFF,1},{1,0x0000FF,1}} end
if t.fg_bd_size==nil then t.fg_bd_size=0 end
if t.fg_bd_colour==nil then t.fg_bd_colour={{1,0xFFFF00,1}} end
if t.autoscale==nil then t.autoscale=false end
if t.inverse==nil then t.inverse=false end
if t.angle==nil then t.angle=0 end
if t.bg_bd_orientation==nil then t.bg_bd_orientation="nn" end
if t.bg_orientation==nil then t.bg_orientation="nn" end
if t.fg_bd_orientation==nil then t.fg_bd_orientation="nn" end
if t.fg_orientation==nil then t.fg_orientation="nn" end
--check colours tables
for i=1, #t.fg_colour do
if #t.fg_colour[i]~=3 then
print ("error in fg_colour table")
t.fg_colour[i]={1,0x0000FF,1}
end
end
for i=1, #t.fg_bd_colour do
if #t.fg_bd_colour[i]~=3 then
print ("error in fg_bd_colour table")
t.fg_bd_colour[i]={1,0x00FF00,1}
end
end
for i=1, #t.bg_colour do
if #t.bg_colour[i]~=3 then
print ("error in background color table")
t.bg_colour[i]={1,0xFFFFFF,0.5}
end
end
for i=1, #t.bg_bd_colour do
if #t.bg_bd_colour[i]~=3 then
print ("error in background border color table")
t.bg_bd_colour[i]={1,0xFFFFFF,1}
end
end
--calculate skew parameters if needed
if t.flag_init then
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
t.flag_init=false
end
cairo_set_line_cap(cr,CAIRO_LINE_CAP_ROUND)
cairo_set_line_join(cr,CAIRO_LINE_JOIN_ROUND)
local matrix0 = cairo_matrix_t:create()
cairo_save(cr)
cairo_matrix_init (matrix0, 1,t.skew_y,t.skew_x,1,0,0)
cairo_transform(cr,matrix0)
local ratio=t.width/t.nb_values
cairo_translate(cr,t.x,t.y)
cairo_rotate(cr,t.angle*math.pi/180)
cairo_scale(cr,1,-1)
--background
if t.background then
local pts=linear_orientation(t.bg_orientation,t.width,t.height)
pat = cairo_pattern_create_linear (pts[1],pts[2],pts[3],pts[4])
for i=1, #t.bg_colour do
--print ("i",i,t.colour[i][1], rgb_to_r_g_b(t.colour[i]))
cairo_pattern_add_color_stop_rgba (pat, t.bg_colour[i][1], rgb_to_r_g_b(t.bg_colour[i]))
end
cairo_set_source (cr, pat)
cairo_rectangle(cr,0,0,t.width,t.height)
cairo_fill(cr)
end
--autoscale
cairo_save(cr)
if t.autoscale then
t.max= t.automax*1.1
end
local scale_x = t.width/(t.nb_values-1)
local scale_y = t.height/t.max
--define first point of the graph
if updates-updates_gap <t.nb_values then
t.beg = t.beg - 1
--next line prevent segmentation error when conky window is redraw
--quicly when another window "fly" over it
if t.beg<0 then t.beg=0 end
else
t.beg=0
end
if t.inverse then cairo_scale(cr,-1,1)
cairo_translate(cr,-t.width,0) end
--graph foreground
if t.foreground then
local pts_fg=linear_orientation_inv(t.fg_orientation,t.width,t.height)
pat = cairo_pattern_create_linear (pts_fg[1],pts_fg[2],pts_fg[3],pts_fg[4])
for i=1,#t.fg_colour,1 do
cairo_pattern_add_color_stop_rgba (pat, 1-t.fg_colour[i][1], rgb_to_r_g_b(t.fg_colour[i]))
end
cairo_set_source (cr, pat)
cairo_move_to(cr,t.beg*scale_x,0)
cairo_line_to(cr,t.beg*scale_x,t.values[t.beg+1]*scale_y)
for i=t.beg, t.nb_values-1 do
cairo_line_to(cr,i*scale_x,t.values[i+1]*scale_y)
end
cairo_line_to(cr,(t.nb_values-1)*scale_x,0)
cairo_close_path(cr)
cairo_fill(cr)
end
--graph_border
if t.fg_bd_size>0 then
local pts=linear_orientation_inv(t.fg_bd_orientation,t.width,t.height)
pat = cairo_pattern_create_linear (pts[1],pts[2],pts[3],pts[4])
for i=1,#t.fg_bd_colour,1 do
cairo_pattern_add_color_stop_rgba (pat, 1-t.fg_bd_colour[i][1], rgb_to_r_g_b(t.fg_bd_colour[i]))
end
cairo_set_source (cr, pat)
cairo_move_to(cr,t.beg*scale_x,t.values[t.beg+1]*scale_y)
for i=t.beg, t.nb_values-1 do
cairo_line_to(cr,i*scale_x,t.values[i+1]*scale_y)
end
cairo_set_line_width(cr,t.fg_bd_size)
cairo_stroke(cr)
end
cairo_restore(cr)
--background border
if t.bg_bd_size>0 then
local pts=linear_orientation(t.bg_bd_orientation,t.width,t.height)
pat = cairo_pattern_create_linear (pts[1],pts[2],pts[3],pts[4])
for i=1, #t.bg_bd_colour do
--print ("i",i,t.colour[i][1], rgb_to_r_g_b(t.colour[i]))
cairo_pattern_add_color_stop_rgba (pat, t.bg_bd_colour[i][1], rgb_to_r_g_b(t.bg_bd_colour[i]))
end
cairo_set_source (cr, pat)
cairo_rectangle(cr,0,0,t.width,t.height)
cairo_set_line_width(cr,t.bg_bd_size)
cairo_stroke(cr)
end
cairo_restore(cr)
end
--Rings.lua
--[[ RINGS with SECTORS widget
v1.0 by wlourf (08.08.2010)
this widget draws a ring with differents effects
http://u-scripts.blogspot.com/2010/08/rings-sectors-widgets.html
To call the script in a conky, use, before TEXT
lua_load /path/to/the/script/rings.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:
xc,yc - coordinates of the center of the ring,
default = middle of the conky window
radius - external radius of the ring, in pixels,
default = quarter of the width of the conky window
thickness - thickness of the ring, in pixels, default = 10 pixels
start_angle - starting angle of the ring, in degrees, value can be negative,
default = 0 degree
end_angle - ending angle of the ring, in degrees,
value must be greater than start_angle, default = 360 degrees
sectors - number of sectors in the ring, default = 10
gap_sectors - gap between two sectors, in pixels, default = 1 pixel
cap - the way to close a sector, available values are
"p" for parallel , default value
"r" for radial (follow the radius)
inverse_arc - if set to true, arc will be anticlockwise, default=false
border_size - size of the border, in pixels, default = 0 pixel i.e. no border
fill_sector - if set to true, each sector will be completely filled,
default=false, this parameter is inoperate if sectors=1
background - if set to false, background will not be drawn, default=true
foreground - if set to false, foreground will not be drawn, default=true
Colours tables below are defined into braces :
{position in the gradient (0 to 1), colour in hexadecimal, alpha (0 to 1)}
example for a single colour table :
{{0,0xFFAA00,1}} position parameter doesn't matter
example for a two-colours table :
{{0,0xFFAA00,1},{1,0x00AA00,1}} or {{0.5,0xFFAA00,1},{1,0x00AA00,1}}
example for a three-colours table :
{{0,0xFFAA00,1},{0.5,0xFF0000,1},{1,0x00AA00,1}}
bg_colour1 - colour table for background,
default = {{0,0x00ffff,0.1},{0.5,0x00FFFF,0.5},{1,0x00FFFF,0.1}}
fg_colour1 - colour table for foreground,
default = {{0,0x00FF00,0.1},{0.5,0x00FF00,1},{1,0x00FF00,0.1}}
bd_colour1 - colour table for border,
default = {{0,0xFFFF00,0.5},{0.5,0xFFFF00,1},{1,0xFFFF00,0.5}}
Seconds tables for radials gradients :
bg_colour2 - second colour table for background, default = no second colour
fg_colour2 - second colour table for foreground, default = no second colour
bd_colour2 - second colour table for border, default = no second colour
v1.0 (08 Aug. 2010) original release
]]
require 'cairo'
function conky_main_rings()
conky_main_bars()
conky_draw_text()
--conky_draw_text()
-- START PARAMETERS HERE
rings_settings={
-- MEM
-- Mem Base Fill --
--###Set color value 000000 to 1a1a1a when using black background!
{
name="",
arg="",
max=100,
xc=45,
yc=106,
thickness=24,
radius=24,
start_angle=-181,
end_angle=1,
sectors=1,
bg_colour2={{0,0x999999,0.95},{1,0x000000,0.65}},
bg_colour1={{0,0x999999,0.95},{1,0x000000,0.65}},
},
-- Mem Shadow
{
name="",
arg="",
max=100,
xc=45,
yc=106,
thickness=11,
radius=35,
start_angle=-181,
end_angle=0,
sectors=1,
bg_colour2={{0,0x000000,0.25},{0.5,0x000000,0.1},{1,0x000000,0}},
bg_colour1={{0,0x000000,0.25},{0.5,0x000000,0.1},{1,0x000000,0}},
},
--GPU
--Gpu Base Fill-- ###Set color value 000000 to 1a1a1a when using black background!
{
name="",
arg="",
max=100,
xc=849,
yc=106,
thickness=24,
radius=24,
start_angle=181,
end_angle=-1,
sectors=1,
bg_colour2={{0,0x999999,0.95},{1,0x000000,0.65}},
bg_colour1={{0,0x999999,0.95},{1,0x000000,0.65}},
},
--GPU Shadow
{
name="",
arg="",
max=100,
xc=849,
yc=106,
thickness=11,
radius=35,
start_angle=181,
end_angle=-1,
sectors=1,
bg_colour2={{0,0x000000,0.25},{0.5,0x000000,0.1},{1,0x000000,0}},
bg_colour1={{0,0x000000,0.25},{0.5,0x000000,0.1},{1,0x000000,0}},
},
--GPU Bar Corners
{
name="",
arg="",
max=100,
xc=841,
yc=92,
thickness=5,
radius=5,
start_angle=0,
end_angle=180,
--inverse_arc=true,
sectors=1,
fg_colour1={{0,0xff4c94,0},{0.5,0xff4c94,0}, {1,0xff4c94,0}},
fg_colour2={{0,0xff4c94,0},{0.5,0xff4c94,0}, {1,0xff4c94,0}},
bg_colour2={ {0,0xababab,1},{0.6,0xababab,1},{0.85,0x000000,0.4},{1,0x000000,0.4}},
bg_colour1={ {0,0xababab,1},{0.6,0xababab,1},{0.85,0x000000,0.4},{1,0x000000,0.4}},
},
{
name="",
arg="",
max=100,
xc=841,
yc=101.5,
thickness=5,
radius=5,
start_angle=0,
end_angle=180,
--inverse_arc=true,
sectors=1,
fg_colour1={{0,0xff4c94,0},{0.5,0xff4c94,0}, {1,0xff4c94,0}},
fg_colour2={{0,0xff4c94,0},{0.5,0xff4c94,0}, {1,0xff4c94,0}},
bg_colour2={ {0,0xababab,1},{0.6,0xababab,1},{0.85,0x000000,0.4},{1,0x000000,0.4}},
bg_colour1={ {0,0xababab,1},{0.6,0xababab,1},{0.85,0x000000,0.4},{1,0x000000,0.4}},
},
{
name="",
arg="",
max=100,
xc=841.5,
yc=111.3,
thickness=5.5,
radius=5.5,
start_angle=0,
end_angle=180,
--inverse_arc=true,
sectors=1,
fg_colour1={{0,0xff4c94,0},{0.5,0xff4c94,0}, {1,0xff4c94,0}},
fg_colour2={{0,0xff4c94,0},{0.5,0xff4c94,0}, {1,0xff4c94,0}},
bg_colour2={ {0,0xababab,1},{0.6,0xababab,1},{0.85,0x000000,0.4},{1,0x000000,0.4}},
bg_colour1={ {0,0xababab,1},{0.6,0xababab,1},{0.85,0x000000,0.4},{1,0x000000,0.4}},
},
--MEM Bar Corners
{
name="",
arg="",
max=100,
xc=64,
yc=101,
thickness=5,
radius=5,
start_angle=0,
end_angle=-180,
--inverse_arc=true,
sectors=1,
fg_colour1={{0,0xff4c94,0},{0.5,0xff4c94,0}, {1,0xff4c94,0}},
fg_colour2={{0,0xff4c94,0},{0.5,0xff4c94,0}, {1,0xff4c94,0}},
bg_colour2={ {0,0xababab,1},{0.6,0xababab,1},{0.85,0x000000,0.4},{1,0x000000,0.4}},
bg_colour1={ {0,0xababab,1},{0.6,0xababab,1},{0.85,0x000000,0.4},{1,0x000000,0.4}},
},
{
name="",
arg="",
max=100,
xc=64,
yc=110.5,
thickness=5,
radius=5,
start_angle=0,
end_angle=-180,
--inverse_arc=true,
sectors=1,
fg_colour1={{0,0xff4c94,0},{0.5,0xff4c94,0}, {1,0xff4c94,0}},
fg_colour2={{0,0xff4c94,0},{0.5,0xff4c94,0}, {1,0xff4c94,0}},
bg_colour2={ {0,0xababab,1},{0.6,0xababab,1},{0.85,0x000000,0.4},{1,0x000000,0.4}},
bg_colour1={ {0,0xababab,1},{0.6,0xababab,1},{0.85,0x000000,0.4},{1,0x000000,0.4}},
},
{
name="",
arg="",
max=100,
xc=64,
yc=120.2,
thickness=5.5,
radius=5.5,
start_angle=0,
end_angle=-180,
--inverse_arc=true,
sectors=1,
fg_colour1={{0,0xff4c94,0},{0.5,0xff4c94,0}, {1,0xff4c94,0}},
fg_colour2={{0,0xff4c94,0},{0.5,0xff4c94,0}, {1,0xff4c94,0}},
bg_colour2={ {0,0xababab,1},{0.6,0xababab,1},{0.85,0x000000,0.4},{1,0x000000,0.4}},
bg_colour1={ {0,0xababab,1},{0.6,0xababab,1},{0.85,0x000000,0.4},{1,0x000000,0.4}},
},
--mem
{
name="memperc",
arg="",
max=33,
xc=45,
yc=106,
thickness=8,
radius=21,
start_angle=-180,
end_angle=-0,
sectors=5,
gap_sectors=1,
fg_colour1={{0,0X1900ff,0},{0.5,0X1900ff,1}, {1,0X1900ff,0}},
fg_colour2={{0,0X1900ff,0},{0.5,0X1900ff,1}, {1,0X1900ff,0}},
bg_colour2={ {0,0x1900ff,0},{0.5,0x1900ff,0.25},{1,0x1900ff,0}},
bg_colour1={ {0,0x1900ff,0},{0.5,0x1900ff,0.25},{1,0x1900ff,0}},
},
--swap
{
name="swapperc",
arg="",
max=80,
xc=45,
yc=106,
thickness=8,
radius=12,
start_angle=-90,
end_angle=210,
sectors=4,
gap_sectors=1,
fg_colour1={{0,0Xff0066,0},{0.7,0Xff0066,1}, {1,0Xff0066,0}},
fg_colour2={{0,0Xff0066,0},{0.7,0Xff0066,1}, {1,0Xff0066,0}},
bg_colour2={ {0,0xff0066,0},{0.5,0xff0066,0.25},{1,0xff0066,0}},
bg_colour1={ {0,0xff0066,0},{0.5,0xff0066,0.25},{1,0xff0066,0}},
},
--swap alarm--
{
name="",
arg=conky_parse("${swapperc}")-80,
max=20,
xc=45,
yc=106,
thickness=8,
radius=12,
start_angle=210,
end_angle=270,
sectors=1,
gap_sectors=1,
fg_colour1={{0,0Xff0000,0},{0.7,0Xff0000,1}, {1,0Xff0000,0}},
fg_colour2={{0,0Xff0000,0},{0.7,0Xff0000,1}, {1,0Xff0000,0}},
bg_colour2={ {0,0xff0066,0},{0.5,0xff0066,0.25},{1,0xff0066,0}},
bg_colour1={ {0,0xff0066,0},{0.5,0xff0066,0.25},{1,0xff0066,0}},
},
---cpu1-- ##first part of ring##
{
name="cpu",
arg="cpu1",
max=67,
xc=178,
yc=67,
thickness=6,
radius=11,
start_angle=-128,
end_angle=90,
inverse_arc=true,
sectors=1,
fill_sectors=true,
fg_colour2={{0,0X0066ff,1},{0.5,0X0066ff,0.5},{1,0X0066ff,1}},
fg_colour1={{0,0X9900ff,1},{0.5,0X9900ff,0.5},{1,0X9900ff,1}},
bg_colour2={ {0,0xffffff,0.3},{0.5,0xffffff,0.2},{1,0xffffff,0.3}},
bg_colour1={ {0,0xffffff,0.3},{0.5,0xffffff,0.2},{1,0xffffff,0.3}},
},
---cpu1-- ##second part of ring##
{
name="",
arg=conky_parse("${cpu cpu1}")-67,
max=33,
xc=178,
yc=67,
thickness=6,
radius=11,
start_angle=127,
end_angle=230,
inverse_arc=true,
sectors=3,
fill_sectors=true,
gap_sectors=2,
fg_colour1={{0,0X0066ff,1},{0.5,0X0066ff,0.5},{1,0X0066ff,1}},
fg_colour2={{0,0X9900ff,1},{0.5,0X9900ff,0.5},{1,0X9900ff,1}},
bg_colour2={ {0,0xffffff,0.3},{0.5,0xffffff,0.2},{1,0xffffff,0.3}},
bg_colour1={ {0,0xffffff,0.05},{0.5,0xffffff,0},{1,0xffffff,0.05}},
},
---cpu2-- ##first part of ring##
{
name="cpu",
arg="cpu2",
max=67,
xc=195,
yc=67,
thickness=6,
radius=11,
start_angle=45,
end_angle=270,
inverse_arc=true,
sectors=1,
fill_sectors=true,
fg_colour1={{0,0X0066ff,1},{0.5,0X0066ff,0.5},{1,0X0066ff,1}},
fg_colour2={{0,0X9900ff,1},{0.5,0X9900ff,0.5},{1,0X9900ff,1}},
bg_colour2={ {0,0xffffff,0.3},{0.5,0xffffff,0.2},{1,0xffffff,0.3}},
bg_colour1={ {0,0xffffff,0.3},{0.5,0xffffff,0.2},{1,0xffffff,0.3}},
},
---cpu2-- ##second part of ring##
{
name="",
arg=conky_parse("${cpu cpu2}")-67,
max=33,
xc=195,
yc=67,
thickness=6,
radius=11,
start_angle=-54,
end_angle=42,
inverse_arc=true,
sectors=3,
fill_sectors=true,
gap_sectors=2,
fg_colour2={{0,0X0066ff,1},{0.5,0X0066ff,0.5},{1,0X0066ff,1}},
fg_colour1={{0,0X9900ff,1},{0.5,0X9900ff,0.5},{1,0X9900ff,1}},
bg_colour2={ {0,0xffffff,0.3},{0.5,0xffffff,0.2},{1,0xffffff,0.3}},
bg_colour1={ {0,0xffffff,0.05},{0.5,0xffffff,0},{1,0xffffff,0.05}},
},
---net up -- ##first part of ring##
{
name="upspeedf",
arg="wlan0",
max=134,
xc=694,
yc=67,
thickness=6,
radius=11,
start_angle=-45,
end_angle=-270,
sectors=1,
fill_sectors=true,
fg_colour2={{0,0Xe5ff00,1},{0.5,0Xe5ff00,0.5},{1,0Xe5ff00,1}},
fg_colour1={{0,0Xe5ff00,1},{0.5,0Xe5ff00,0.5},{1,0Xe5ff00,1}},
bg_colour2={ {0,0xffffff,0.3},{0.5,0xffffff,0.2},{1,0xffffff,0.3}},
bg_colour1={ {0,0xffffff,0.3},{0.5,0xffffff,0.2},{1,0xffffff,0.3}},
},
---net up-- #Second part of ring##
{
name="",
arg=conky_parse("${upspeedf wlan0}")-134,
max=66,
xc=694,
yc=67,
thickness=6,
radius=11,
start_angle=54,
end_angle=-42,
sectors=3,
fill_sectors=true,
gap_sectors=2,
fg_colour1={{0,0Xff9900,1},{0.5,0Xff9900,0.5},{1,0Xff9900,1}},
fg_colour2={{0,0Xe5ff00,1},{0.5,0Xe5ff00,0.5},{1,0Xe5ff00,1}},
bg_colour1={ {0,0xffffff,0.3},{0.5,0xffffff,0.2},{1,0xffffff,0.3}},
bg_colour2={ {0,0xffffff,0.1},{0.5,0xffffff,0},{1,0xffffff,0.1}},
},
---net down-- ##first part of ring##
{
name="downspeedf",
arg="wlan0",
max=366,
xc=711,
yc=67,
thickness=6,
radius=11,
start_angle=128,
end_angle=-90,
sectors=1,
fill_sectors=true,
fg_colour2={{0,0X00ff19,1},{0.5,0X00ff19,0.5},{1,0X00ff19,1}},
fg_colour1={{0,0X00ff19,1},{0.5,0X00ff19,0.5},{1,0X00ff19,1}},
bg_colour2={ {0,0xffffff,0.3},{0.5,0xffffff,0.2},{1,0xffffff,0.3}},
bg_colour1={ {0,0xffffff,0.3},{0.5,0xffffff,0.2},{1,0xffffff,0.3}},
},
---net down-- ##second part of ring##
{
name="",
arg=conky_parse("${downspeedf wlan0}")-366,
max=184,
xc=711,
yc=67,
thickness=6,
radius=11,
start_angle=129,
end_angle=230,
sectors=3,
fill_sectors=true,
gap_sectors=2,
fg_colour1={{0,0Xff9900,1},{0.5,0Xff9900,0.5},{1,0Xff9900,1}},
fg_colour2={{0,0X00ff19,1},{0.5,0X00ff19,0.5},{1,0X00ff19,1}},
bg_colour1={ {0,0xffffff,0.3},{0.5,0xffffff,0.2},{1,0xffffff,0.3}},
bg_colour2={ {0,0xffffff,0.1},{0.5,0xffffff,0},{1,0xffffff,0.1}},
},
--GPU
--GPU
{
name="",
arg=conky_parse("${nvidia gpufreq}")-266.7,
max=133.3,
xc=849,
yc=106,
thickness=8,
radius=21,
start_angle=0,
end_angle=180,
inverse_arc=true,
sectors=6,
fg_colour1={{0,0xff4c94,0},{0.5,0xff4c94,1}, {1,0xff4c94,0}},
fg_colour2={{0,0xff4c94,0},{0.5,0xff4c94,1}, {1,0xff4c94,0}},
bg_colour2={ {0,0xff4c94,0},{0.5,0xff4c94,0.25},{1,0xff4c94,0}},
bg_colour1={ {0,0xff4c94,0},{0.5,0xff4c94,0.25},{1,0xff4c94,0}},
},
}
--END OF PARAMETERS HERE
--main function
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)
if tonumber(conky_parse('${updates}'))>3 then
for i in pairs(rings_settings) do
draw_ring(rings_settings[i])
end
end
cairo_destroy(cr)
end
function draw_ring(t)
local function rgba_to_r_g_b_a(tcolour)
colour,alpha=tcolour[2],tcolour[3]
return ((colour / 0x10000) % 0x100) / 255.,
((colour / 0x100) % 0x100) / 255., (colour % 0x100) / 255., alpha
end
local function calc_delta(tcol1,tcol2)
--calculate deltas P R G B A to table_colour 1
for x = 1, #tcol1 do
tcol1[x].dA = 0
tcol1[x].dP = 0
tcol1[x].dR = 0
tcol1[x].dG = 0
tcol1[x].dB = 0
if tcol2~=nil and #tcol1 == #tcol2 then
local r1,g1,b1,a1 = rgba_to_r_g_b_a(tcol1[x])
local r2,g2,b2,a2 = rgba_to_r_g_b_a(tcol2[x])
tcol1[x].dP = (tcol2[x][1]-tcol1[x][1])/t.sectors
tcol1[x].dR = (r2-r1)/t.sectors
tcol1[x].dG = (g2-g1)/t.sectors
tcol1[x].dB = (b2-b1)/t.sectors
tcol1[x].dA = (a2-a1)/t.sectors
end
end
return tcol1
end
--check values
local function setup(t)
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'")
print ("for name=" .. t.name)
print ("with arg=" .. t.arg)
return
end
if t.name==nil then t.name="" end
if t.arg==nil then t.arg="" end
if t.xc==nil then t.xc=conky_window.width/2 end
if t.yc==nil then t.yc=conky_window.height/2 end
if t.thickness ==nil then t.thickness = 10 end
if t.radius ==nil then t.radius =conky_window.width/4 end
if t.start_angle==nil then t.start_angle =0 end
if t.end_angle==nil then t.end_angle=360 end
if t.bg_colour1==nil then
t.bg_colour1={{0,0x00ffff,0.1},{0.5,0x00FFFF,0.5},{1,0x00FFFF,0.1}}
end
if t.fg_colour1==nil then
t.fg_colour1={{0,0x00FF00,0.1},{0.5,0x00FF00,1},{1,0x00FF00,0.1}}
end
if t.bd_colour1==nil then
t.bd_colour1={{0,0xFFFF00,0.5},{0.5,0xFFFF00,1},{1,0xFFFF00,0.5}}
end
if t.sectors==nil then t.sectors=10 end
if t.gap_sectors==nil then t.gap_sectors=1 end
if t.fill_sector==nil then t.fill_sector=false end
if t.sectors==1 then t.fill_sector=false end
if t.border_size==nil then t.border_size=0 end
if t.cap==nil then t.cap="p" end
--some checks
if t.thickness>t.radius then t.thickness=t.radius*0.1 end
t.int_radius = t.radius-t.thickness
--check colors tables
for i=1, #t.bg_colour1 do
if #t.bg_colour1[i]~=3 then t.bg_colour1[i]={1,0xFFFFFF,0.5} end
end
for i=1, #t.fg_colour1 do
if #t.fg_colour1[i]~=3 then t.fg_colour1[i]={1,0xFF0000,1} end
end
for i=1, #t.bd_colour1 do
if #t.bd_colour1[i]~=3 then t.bd_colour1[i]={1,0xFFFF00,1} end
end
if t.bg_colour2~=nil then
for i=1, #t.bg_colour2 do
if #t.bg_colour2[i]~=3 then t.bg_colour2[i]={1,0xFFFFFF,0.5} end
end
end
if t.fg_colour2~=nil then
for i=1, #t.fg_colour2 do
if #t.fg_colour2[i]~=3 then t.fg_colour2[i]={1,0xFF0000,1} end
end
end
if t.bd_colour2~=nil then
for i=1, #t.bd_colour2 do
if #t.bd_colour2[i]~=3 then t.bd_colour2[i]={1,0xFFFF00,1} end
end
end
if t.start_angle>=t.end_angle then
local tmp_angle=t.end_angle
t.end_angle= t.start_angle
t.start_angle = tmp_angle
-- print ("inversed angles")
if t.end_angle-t.start_angle>360 and t.start_angle>0 then
t.end_angle=360+t.start_angle
print ("reduce angles")
end
if t.end_angle+t.start_angle>360 and t.start_angle<=0 then
t.end_angle=360+t.start_angle
print ("reduce angles")
end
if t.int_radius<0 then t.int_radius =0 end
if t.int_radius>t.radius then
local tmp_radius=t.radius
t.radius=t.int_radius
t.int_radius=tmp_radius
print ("inversed radius")
end
if t.int_radius==t.radius then
t.int_radius=0
print ("int radius set to 0")
end
end
t.fg_colour1 = calc_delta(t.fg_colour1,t.fg_colour2)
t.bg_colour1 = calc_delta(t.bg_colour1,t.bg_colour2)
t.bd_colour1 = calc_delta(t.bd_colour1,t.bd_colour2)
end
--initialize table
setup(t)
--[[grid
h=conky_window.height
w=conky_window.width
cairo_set_source_rgba(cr,1,1,1,1)
cairo_set_line_width(cr,0.5)
cairo_move_to(cr,0,t.yc)
cairo_line_to(cr,w,t.yc)
cairo_stroke(cr)
cairo_move_to(cr,t.xc,0)
cairo_line_to(cr,t.xc,h)
cairo_stroke(cr)
cairo_move_to(cr,t.xc,t.yc)
cairo_line_to(cr,t.xc+200*math.sin(math.pi/4),t.yc-200*math.cos(math.pi/4))
cairo_stroke(cr)
cairo_move_to(cr,0,t.yc-t.radius)
cairo_line_to(cr,w,t.yc-t.radius)
cairo_stroke(cr)
cairo_move_to(cr,0,t.yc-t.int_radius)
cairo_line_to(cr,w,t.yc-t.int_radius)
cairo_stroke(cr)
cairo_move_to(cr,0,t.yc-t.gap_sectors)
cairo_line_to(cr,w,t.yc-t.gap_sectors)
cairo_stroke(cr)
cairo_set_source_rgba(cr,1,0,0,0.5)
cairo_arc(cr,t.xc,t.yc,t.radius,0,2*math.pi)
cairo_stroke(cr)
cairo_arc(cr,t.xc,t.yc,t.int_radius,0,2*math.pi)
cairo_stroke(cr)
cairo_set_source_rgba(cr,0,1,0,1)
cairo_move_to(cr,t.xc+t.gap_sectors,t.yc-t.gap_sectors)
cairo_line_to(cr,t.xc+400*math.sin(math.pi/4),t.yc-400*math.cos(math.pi/4))
cairo_stroke(cr)
--END GRID
]]
--initialize cairo context
cairo_save(cr)
cairo_translate(cr,t.xc,t.yc)
cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND)
cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND)
--get value
local value = 0
if t.name ~="" then
value = tonumber(conky_parse(string.format('${%s %s}', t.name, t.arg)))
else
value = tonumber(t.arg)
end
if value==nil then value =0 end
--initialize sectors
--angle of a sector :
angleA = ((t.end_angle-t.start_angle)/t.sectors)*math.pi/180
--value of a sector :
valueA = t.max/t.sectors
--first angle of a sector :
lastAngle = t.start_angle*math.pi/180
local function draw_sector(type_arc,angle0,angle,valpc, idx)
--this function draws a portion of arc
--type of arc, angle0 = strating angle, angle= angle of sector,
--valpc = percentage inside the sector, idx = sctor number #
if type_arc=="bg" then --background
if valpc==1 then return end
tcolor=t.bg_colour1
elseif type_arc=="fg" then --foreground
if valpc==0 then return end
tcolor=t.fg_colour1
elseif type_arc=="bd" then --border
tcolor=t.bd_colour1
end
--angles equivalents to gap_sector
local ext_delta=math.atan(t.gap_sectors/(2*t.radius))
local int_delta=math.atan(t.gap_sectors/(2*t.int_radius))
--angles of arcs
local ext_angle=(angle-ext_delta*2)*valpc
local int_angle=(angle-int_delta*2)*valpc
--define colours to use for this sector
if #tcolor==1 then
--plain color
local vR,vG,vB,vA = rgba_to_r_g_b_a(tcolor[1])
cairo_set_source_rgba(cr,vR+tcolor[1].dR*idx,
vG+tcolor[1].dG*idx,
vB+tcolor[1].dB*idx,
vA+tcolor[1].dA*idx )
else
--radient color
local pat=cairo_pattern_create_radial(0,0,t.int_radius,0,0,t.radius)
for i=1, #tcolor do
local vP,vR,vG,vB,vA = tcolor[i][1], rgba_to_r_g_b_a(tcolor[i])
cairo_pattern_add_color_stop_rgba (pat,
vP+tcolor[i].dP*idx,
vR+tcolor[i].dR*idx,
vG+tcolor[i].dG*idx,
vB+tcolor[i].dB*idx,
vA+tcolor[i].dA*idx )
end
cairo_set_source (cr, pat)
cairo_pattern_destroy(pat)
end
--start drawing
cairo_save(cr)
--x axis is parrallel to start of sector
cairo_rotate(cr,angle0-math.pi/2)
local ri,re = t.int_radius ,t.radius
--point A
local angle_a
if t.cap == "p" then
angle_a = int_delta
if t.inverse_arc and type_arc ~="bg" then
angle_a = angle-int_angle-int_delta
end
if not(t.inverse_arc) and type_arc =="bg" then
angle_a = int_delta+int_angle
end
else --t.cap=="r"
angle_a = ext_delta
if t.inverse_arc and type_arc~="bg" then
angle_a = angle-ext_angle-ext_delta
end
if not(t.inverse_arc) and type_arc=="bg" then
angle_a = ext_delta+ext_angle
end
end
local ax,ay = ri*math.cos(angle_a),ri*math.sin(angle_a)
--point B
local angle_b = ext_delta
if t.cap == "p" then
if t.inverse_arc and type_arc ~="bg" then
angle_b = angle-ext_angle-ext_delta
end
if not(t.inverse_arc) and type_arc=="bg" then
angle_b = ext_delta+ext_angle
end
else
if t.inverse_arc and type_arc ~="bg" then
angle_b = angle-ext_angle-ext_delta
end
if not(t.inverse_arc) and type_arc=="bg" then
angle_b = ext_delta+ext_angle
end
end
local bx,by = re*math.cos(angle_b),re*math.sin(angle_b)
-- EXTERNAL ARC B --> C
if t.inverse_arc then
if type_arc=="bg" then
b0,b1= ext_delta, angle-ext_delta-ext_angle
else
b0,b1= angle-ext_angle-ext_delta, angle-ext_delta
end
else
if type_arc=="bg" then
b0,b1= ext_delta+ext_angle, angle-ext_delta
else
b0,b1= ext_delta, ext_angle+ext_delta
end
end
---POINT D
local angle_c
if t.cap == "p" then
angle_d = angle-int_delta
if t.inverse_arc and type_arc=="bg" then
angle_d = angle-int_delta-int_angle
end
if not(t.inverse_arc) and type_arc~="bg" then
angle_d=int_delta+int_angle
end
else
angle_d = angle-ext_delta
if t.inverse_arc and type_arc=="bg" then
angle_d =angle-ext_delta-ext_angle
end
if not(t.inverse_arc) and type_arc~="bg" then
angle_d = ext_angle+ext_delta
end
end
local dx,dy = ri*math.cos(angle_d),ri*math.sin(angle_d)
-- INTERNAL ARC D --> A
if t.cap=="p" then
if t.inverse_arc then
if type_arc=="bg" then
d0,d1= angle-int_delta-int_angle,int_delta
else
d0,d1= angle-int_delta, angle- int_angle-int_delta
end
else
if type_arc=="bg" then
d0,d1= angle-int_delta, int_delta+int_angle
else
d0,d1= int_delta+int_angle, int_delta
end
end
else
if t.inverse_arc then
if type_arc=="bg" then
d0,d1= angle-ext_delta-ext_angle,ext_delta
else
d0,d1= angle-ext_delta, angle- ext_angle-ext_delta
end
else
if type_arc=="bg" then
d0,d1= angle-ext_delta,ext_delta+ext_angle
else
d0,d1= ext_angle+ext_delta, ext_delta
end
end
end
--draw sector
cairo_move_to(cr,ax,ay)
cairo_line_to(cr,bx,by)
cairo_arc(cr,0,0,re,b0,b1)
cairo_line_to(cr,dx,dy)
cairo_arc_negative(cr,0,0,ri,d0,d1)
cairo_close_path (cr);
--stroke or fill sector
if type_arc=="bd" then
cairo_set_line_width(cr,t.border_size)
cairo_stroke(cr)
else
cairo_fill(cr)
end
cairo_restore(cr)
end
--draw sectors
local n0,n1,n2 = 1,t.sectors,1
if t.inverse_arc then n0,n1,n2 = t.sectors,1,-1 end
local index = 0
for i = n0,n1,n2 do
index = index +1
local valueZ=1
local cstA, cstB = (i-1),i
if t.inverse_arc then cstA,cstB = (t.sectors-i), (t.sectors-i+1) end
if value>valueA *cstA and value<valueA*cstB then
if not t.fill_sector then
valueZ = (value-valueA*cstA)/valueA
end
else
if value<valueA*cstB then valueZ=0 end
end
local start_angle= lastAngle+(i-1)*angleA
if t.foreground ~= false then
draw_sector("fg",start_angle,angleA,valueZ, index)
end
if t.background ~= false then
draw_sector("bg",start_angle,angleA,valueZ, i)
end
if t.border_size>0 then draw_sector("bd",start_angle,angleA,1, i) end
end
cairo_restore(cr)
end
--[[END OF RING-SECTORS WIDGET]]
function clock_hands(xc, yc, colour, alpha, show_secs, size)
--[[ Options (xc, yc, colour, alpha, show_secs, size):
"xc" and "yc" are the x and y coordinates of the centre of the clock hands, in pixels, relative to the top left corner of the Conky window
"colour" is the colour of the clock hands, in Ox33312c formate
"alpha" is the alpha of the hands, between 0 and 1
"show_secs" is a boolean; set to TRUE to show the seconds hand, otherwise set to FALSE
"size" is the total size of the widget (e.g. twice the length of the minutes hand), in pixels ]]
local secs,mins,hours,secs_arc,mins_arc,hours_arc
local xh,yh,xm,ym,xs,ys
secs=os.date("%S")
mins=os.date("%M")
hours=os.date("%I")
secs_arc=(2*math.pi/60)*secs
mins_arc=(2*math.pi/60)*mins+secs_arc/60
hours_arc=(2*math.pi/12)*hours+mins_arc/12
xh=xc+0.4*size*math.sin(hours_arc)
yh=yc-0.4*size*math.cos(hours_arc)
cairo_move_to(cr,xc,yc)
cairo_line_to(cr,xh,yh)
cairo_set_line_cap(cr,CAIRO_LINE_CAP_ROUND)
cairo_set_line_width(cr,5)
cairo_set_source_rgba(cr,rgb_to_r_g_b(colour,alpha))
cairo_stroke(cr)
xm=xc+0.5*size*math.sin(mins_arc)
ym=yc-0.5*size*math.cos(mins_arc)
cairo_move_to(cr,xc,yc)
cairo_line_to(cr,xm,ym)
cairo_set_line_width(cr,3)
cairo_stroke(cr)
if show_secs then
xs=xc+0.5*size*math.sin(secs_arc)
ys=yc-0.5*size*math.cos(secs_arc)
cairo_move_to(cr,xc,yc)
cairo_line_to(cr,xs,ys)
cairo_set_line_width(cr,1)
cairo_stroke(cr)
end
cairo_set_line_cap(cr,CAIRO_LINE_CAP_BUTT)
end
--[[ END CLOCK HANDS WIDGET ]]
function axis(ctx,alpha)
cairo_set_line_width(ctx,1)
cairo_set_source_rgba(ctx,1,0,0,alpha)
cairo_move_to(ctx,0,0)
cairo_line_to(ctx,150,0)
cairo_stroke(ctx)
cairo_set_source_rgba(ctx,0,1,0,alpha)
cairo_move_to(ctx,0,0)
cairo_line_to(ctx,0,150)
cairo_stroke(ctx)
end
--barghraph1.lua
--[[ BARGRAPH WIDGET
v2.0 by wlourf (12.07.2010)
this widget draws a bargraph with differe,ts effects
http://u-scripts.blogspot.com/2010/07/bargraph-widget.html
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 numericla 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, défaut = 0
skew_y - skew bar around y axis, défaut = 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, défaut = {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
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 March 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
]]
require 'cairo'
----------------START OF PARAMETERS ----------
function conky_main_bars()
bars_settings={
--MEM starts with ring meets into this bar
{
name="",
arg=conky_parse("${memperc}")-33,
max=67,
alarm=57,
angle=90,
height=8.3,
width=8,
space=1,
bg_colour = {0x1900ff,0},
fg_colour = {0X1900ff,0},
alarm_colour={0xff0000,0},
led_effect="e",
bg_led ={0x1900ff,0.25},
fg_led ={0x1900ff,1},
alarm_led={0xff0000,1},
x=49,y=89,
},
--GPU Feq bar start meets in with Gpu ring
{
name="nvidia",
arg="gpufreq",
max=266.7,
angle=90,
height=7,
width=8,
space=1,
bg_colour = {0xff4c94,0},
fg_colour = {0Xff4c94,0},
led_effect="e",
bg_led ={0xff4c94,0.25},
fg_led ={0xff4c94,1},
x=773,y=123,
},
--Cpu Temp
{
name="exec",
arg="sensors | grep 'temp2' | cut -c15-16",
max=105,
alarm=90,
bg_colour={0xff9900,0},
fg_colour={0xff9900,0},
alarm_colour={0xff0000,0},
x=150,y=126,
blocks=8,
height=2.3,width=11,
led_effect="r",
fg_led={0xff9900,1},
alarm_led={0xff0000,1},
bg_led={0xff9900,0.25},
},
--Gpu Temp
{
name="nvidia",
arg="temp",
max=105,
alarm=90,
bg_colour={0xff9900,0},
fg_colour={0xff9900,0},
alarm_colour={0xff0000,0},
x=752,y=126,
blocks=8,
height=2.3,width=11,
led_effect="r",
fg_led={0xff9900,1},
alarm_led={0xff0000,1},
bg_led={0xff9900,0.25},
},
}
-----------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)
end
function draw_multi_bar_graph(t)
cairo_save(cr)
--check values
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
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=nil
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
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)
-- 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
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)))
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()
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()
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
end --setup_bar_graph()
--start here !
setup_bar_graph()
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,0xFFFFFF,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"
]]
require 'cairo'
function conky_draw_text()
--BEGIN OF PARAMETRES
text_settings={
--SYSTEM LOGO-- ##Arch Linux##
{
text="B",
font_name="OpenLogos",
font_size=21,
h_align="l",
--v_align="m",
bold=true,
x=390,
y=73,
colour={{0,0Xffffff,0.1},{1,0Xffffff,0.25}},
--radial={0,300,0,0,300,370},
orientation="nn",
},
{
text="B",
font_name="OpenLogos",
font_size=20,
h_align="l",
bold=true,
orientation="sw",
x=389.5,
y=72.5,
colour={{0,0Xffffff,0.7},{0.5,0Xffffff,0.2}, {1,0Xffffff,0.8}},
},
}
--------------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)
end
cairo_surface_destroy(cs)
end
function rgb_to_r_g_b2(tcolour)
colour,alpha=tcolour[2],tcolour[3]
return ((colour / 0x10000) % 0x100) / 255., ((colour / 0x100) % 0x100) / 255., (colour % 0x100) / 255., alpha
end
function display_text(t)
local function set_pattern()
--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)
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,0xFFFFFF,1}} end
if t.font_name==nil then t.font_name="Free Sans" end
if t.font_size==nil then t.font_size=14 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,0xFFFFFF,1}
end
end
local matrix0 = cairo_matrix_t:create()
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)
te=cairo_text_extents_t:create()
cairo_text_extents (cr,t.text,te)
set_pattern()
mx,my=0,0
if t.h_align=="c" then
mx=-te.width/2
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()
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=cairo_text_extents_t:create()
cairo_text_extents (cr,t.text,te)
cairo_transform(cr,matrix1)
set_pattern()
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)
cairo_set_line_width(cr,1)
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)
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
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 vorientation=="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
--vnstat-conky-script.py
#!/usr/bin/env python2
#
# vnstat-conky-script.py
#
# get monthly download totals from vnstat, for display in conky
#
from subprocess import Popen,PIPE
import sys
def sizeformat(size):
suffix = ['B','KB','MB','GB','TB']
count = 0
while size >= 1024 and count < len(suffix)-1:
count += 1
size = size/1024
return "%.2f%s" % (size, suffix[count])
# get output
output = Popen(["vnstat", "--dumpdb"], stdout= PIPE).communicate()[0]
# get the correct line (first to start with m)
line = (i for i in output.split('\n') if i.startswith('m') ).next()
#split line out into constituent parts
mon,mon_num,nixtime,rec_mb,tran_mb,rec_kb,tran_kb,inuse=line.split(';')
if sys.argv[1] == '-r': #received
print sizeformat((float(rec_mb)*1024*1024)+(float(rec_kb)*1024))
elif sys.argv[1] == '-s':#sent
print sizeformat((float(tran_mb)*1024*1024)+(float(tran_kb)*1024))
else: #return total
print sizeformat(((float(rec_mb)*1024*1024)+(float(rec_kb)*1024))
+(float(tran_mb)*1024*1024)+(float(tran_kb)*1024))
--vnstatDAILY-conky-script.py
#!/usr/bin/env python2
#
# vnstat-conky-script.py
#
# get monthly download totals from vnstat, for display in conky
#
from subprocess import Popen,PIPE
import sys
def sizeformat(size):
suffix = ['B','KB','MB','GB','TB']
count = 0
while size >= 1024 and count < len(suffix)-1:
count += 1
size = size/1024
return "%.2f%s" % (size, suffix[count])
# get output
output = Popen(["vnstat", "--dumpdb"], stdout= PIPE).communicate()[0]
# get the correct line (first to start with m)
line = (i for i in output.split('\n') if i.startswith('m') ).next()
#split line out into constituent parts
mon,mon_num,nixtime,rec_mb,tran_mb,rec_kb,tran_kb,inuse=line.split(';')
if sys.argv[1] == '-r': #received
print sizeformat((float(rec_mb)*1024*1024)+(float(rec_kb)*1024))
elif sys.argv[1] == '-s':#sent
print sizeformat((float(tran_mb)*1024*1024)+(float(tran_kb)*1024))
else: #return total
print sizeformat(((float(rec_mb)*1024*1024)+(float(rec_kb)*1024))
+(float(tran_mb)*1024*1024)+(float(tran_kb)*1024))
screenshots:
-- mod edit: read the rules and only post thumbnails https://bbs.archlinux.org/viewtopic.php?id=61754 --
Last edited by jo-shva (2011-01-08 16:18:12)
"Democracy is being allowed to vote for the candidate you dislike least." -- Robert Byrne
http://killhellokitty.deviantart.com/
Offline
My own version of http://old-cps-do-not-use.wdfiles.com/l … _conky.png.
# ~/.conkyrc
#
# conky configuration file.
alignment top_right
background yes
#border_margin 0
#border_width 0
cpu_avg_samples 2
#color0 7d7d7d
#color1 green
#color2 ffffff
double_buffer yes
draw_shades no
draw_outline no
draw_borders no
default_color black
#draw_graph_borders no
#default_shade_color cyan
#default_outline_color cyan
gap_x 10
gap_y 10
#mail_spool $MAIL
#minimum_size 330 10
#maximum_width 330
no_buffers yes
net_avg_samples 2
out_to_console no
own_window yes
own_window_type desktop
own_window_transparent yes
own_window_colour cyan
own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager
override_utf8_locale no
stippled_borders 0
total_run_times 0
use_xft yes
use_spacer right
update_interval 1.0
uppercase no
#wm_class_name Conky
xftfont droid sans mono:size=9
xftalpha 0.8
TEXT
SYSTEM ${hr}
${alignc 15}${font droid sans mono:size=14}${nodename}${font}
${font StyleBats:size=16}u${font} kernel: ${alignr}${kernel}
${font StyleBats:size=16}o${font} cpu: ${cpu cpu0}% ${alignr}${cpubar cpu0 8,60}
${font StyleBats:size=16}a$font} mem: ${memperc}% ${alignr}${membar 8,60}
${font StyleBats:size=16}p${font} bat: ${battery_percent}% ${alignr}${battery_bar 8,60}
${font StyleBats:size=16}q${font} uptime: ${alignr}${uptime}
TIME ${hr}
${alignc 15}${font droid sans mono:size=14}${time %H:%M}${font}
${alignc}${time %a %d %b}
HDD ${hr}
${alignc}${font StyleBats:size=16}Y${font} root: ${fs_used /}
${alignc}${fs_bar 8,60 /}
NETWORK ${hr}
${if_existing /proc/net/route wlan0}${alignc}${wireless_essid wlan0} @ ${wireless_bitrate wlan0}
${alignc}${wireless_link_bar 8,60 wlan0}
${font PizzaDude Bullets:size=14}N${font} up: ${upspeedf wlan0} ${alignr}${upspeedgraph wlan0 8,60}
${font PizzaDude Bullets:size=14}T${font} down: ${downspeedf wlan0} ${alignr}${downspeedgraph wlan0 8,60}${else}${if_existing /proc/net/route eth0}${font PizzaDude Bullets:size=14}O${font} up: ${upspeedf eth0} ${alignr}${upspeedgraph eth0 8,60}
${font PizzaDude Bullets:size=14}U${font} down: ${downspeedf eth0} ${alignr}${downspeedgraph eth0 8,60}${else}${font PizzaDude Bullets:size=14}G${font} Network Unavailable${endif}${endif}
PACKAGES ${hr}
ARCH: ${alignr}${execpi 3600 paconky /home/ibnarrashid/scripts/shell/repos.paconky}
AUR: ${alignr}${execpi 3600 paconky /home/ibnarrashid/scripts/shell/aur.paconky}
# End of file.
Offline
I've made a LOT of changes and while it's still not quite perfect yet I'm getting there. I launch them all from a shell script in rc.local
MAIN CONKY (LOWER RIGHT CONFIG)
# Conky configuration
background yes
use_xft yes
xftfont Monospace:size=11
xftalpha 0.8
out_to_console no
update_interval 2
total_run_times 0
own_window yes
own_window_type override
own_window_transparent yes
own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager
double_buffer yes
minimum_size 347
draw_shades no
draw_outline no
draw_borders no
draw_graph_borders yes
stippled_borders 5
#border_margin 4
default_color grey
default_shade_color black
default_outline_color black
#alignment top_right
#gap_x 20
#gap_y 25
alignment bottom_right
gap_x 15
gap_y 103
no_buffers no
uppercase no
cpu_avg_samples 2
net_avg_samples 2
override_utf8_locale yes
use_spacer none
TEXT
${font Monospace:normal:size=12}${color white}$alignc$sysname $kernel on $machine
${color white}$alignc${exec whoami} @ $nodename
${color white}$alignc Uptime: ${color white}$uptime
${color}Date: ${color white}${time %A,%d %B}${alignr}${color}Time: ${color white}${time %k:%M:%S}${font Monospace:normal:size=11}
${color orange}TEMPERATURES/FANS:${stippled_hr}${color white}
$alignc CPU_1: ${hwmon 0 temp 1}°C $alignc MoBo: ${hwmon 2 temp 2}°C
$alignc CPU_2: ${hwmon 1 temp 1}°C $alignc GPU: ${execi 2 nvidia-settings -q gpucoretemp -t}°C
$alignc CPU_fan: ${hwmon 2 fan 1} rpm $alignc Front_fan: ${hwmon 2 fan 3} rpm
${color orange}MONITORS: $stippled_hr
${color}CPU_1:${color white} ${cpu cpu1}% ${alignc}${freq cpu1} Mhz${alignr}${cpubar cpu1 7,75}
${color}CPU_2:${color white} ${cpu cpu2}% ${alignc}${freq cpu2} Mhz${alignr}${cpubar cpu2 7,75}
${color}RAM:${color white} $memperc% ${alignc}$mem/$memmax${alignr}${membar 7,75}
${color}Swap: ${color white} $swapperc% ${alignc}$swap/$swapmax${alignr}${swapbar 7,75}
${color orange}HDD: $stippled_hr
${color white}/${color white} ${fs_used_perc /}% ${fs_used /}/${fs_size /} ${alignr}${fs_bar 7,75 /}
${color white}/home${color white} ${fs_used_perc /home}% ${fs_used /home}/${fs_size /home}${alignr}${fs_bar 7,75 /home}
${color white}/mnt/data${color white} ${fs_used_perc /mnt/data/}% ${fs_used /mnt/data/}/${fs_size /mnt/data/}${alignr}${fs_bar 7,75 /mnt/data/}
${color}Disk Read: $diskio_read ${alignr}${color}Disk Write: $diskio_write
#
#
#
${exec feh --bg-scale "`grep 'wallpaper=' ~/.kde4/share/config/plasma-desktop-appletsrc | tail --lines=1 | sed 's/wallpaper=//'`"}
F@H CONKY (LOWER LEFT CONFIG) -- The Serverbox stat data is pulled from a file on my server that's fed via a Cron job that runs every 3 minutes.
# Conky process config file
background yes
use_xft yes
xftfont Monospace:size=11
xftalpha 0.8
out_to_console no
update_interval 2
total_run_times 0
own_window yes
own_window_type override
own_window_transparent yes
own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager
double_buffer yes
minimum_size 375
draw_shades no
draw_outline no
draw_borders no
draw_graph_borders yes
stippled_borders 5
#border_margin 4
default_color grey
default_shade_color black
default_outline_color black
alignment bottom_right
gap_x 425
gap_y 90
no_buffers no
uppercase no
cpu_avg_samples 2
net_avg_samples 2
override_utf8_locale yes
use_spacer none
TEXT
${color orange}${font Monospace:normal:size=13}FOLDING AT HOME: $stippled_hr${font Monospace:normal:size=11}
${color orange} Desktop:
CPU:
${color white}${execi 60 cat /opt/fah-smp/dad/unitinfo.txt | grep "Name"} ${alignr}${execi 60 cat /opt/fah-smp/dad/unitinfo.txt | grep "Tag"}
${execi 60 cat /opt/fah-smp/dad/unitinfo.txt | grep "Due"}
${font Monospace:normal:size=13}${execi 60 cat /opt/fah-smp/dad/unitinfo.txt | grep "Progress"}${font Monospace:normal:size=11}
${color orange} GPU:${color white}
${color white}${execi 60 cat /opt/fah-gpu/unitinfo.txt | grep "Name"}
${execi 60 cat /opt/fah-gpu/unitinfo.txt | grep "Due"}
${font Monospace:normal:size=13}${execi 60 cat /opt/fah-gpu/unitinfo.txt | grep "Progress"}${font Monospace:normal:size=11}
${color orange}Serverbox:
CPU:
${color white}${execi 60 cat /mnt/Serverbox/Shared/Serverbox_outputs/cpu_unitinfo.txt | grep "Name"} ${alignr}${execi 60 cat /mnt/Serverbox/Shared/Serverbox_outputs/cpu_unitinfo.txt | grep "Tag"}
${execi 60 cat /mnt/Serverbox/Shared/Serverbox_outputs/cpu_unitinfo.txt | grep "Due"}
${font Monospace:normal:size=13}${execi 60 cat /mnt/Serverbox/Shared/Serverbox_outputs/cpu_unitinfo.txt | grep "Progress"}${font Monospace:normal:size=11}
${color orange} GPU:${color white}
${color white}${execi 60 cat /mnt/Serverbox/Shared/Serverbox_outputs/gpu_unitinfo.txt | grep "Name"}
${execi 60 cat /mnt/Serverbox/Shared/Serverbox_outputs/gpu_unitinfo.txt | grep "Due"}
${font Monospace:normal:size=13}${execi 60 cat /mnt/Serverbox/Shared/Serverbox_outputs/gpu_unitinfo.txt | grep "Progress"}${font Monospace:normal:size=11}
PROCESSES CONKY (UPPER RIGHT CONFIG)
# Conky process config file
background yes
use_xft yes
xftfont Monospace:size=11
xftalpha 0.8
out_to_console no
update_interval 2
total_run_times 0
own_window yes
own_window_type override
own_window_transparent yes
own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager
double_buffer yes
minimum_size 375
draw_shades no
draw_outline no
draw_borders no
draw_graph_borders yes
stippled_borders 5
#border_margin 4
default_color grey
default_shade_color black
default_outline_color black
alignment top_right
gap_x 20
gap_y 25
no_buffers no
uppercase no
cpu_avg_samples 2
net_avg_samples 2
override_utf8_locale yes
use_spacer none
TEXT
${color orange}TOP PROCESSES: $stippled_hr ${color white}
Processes: ${alignr}${processes}
Running: ${alignr}${running_processes}
${color orange}BY CPU: $stippled_hr ${color 000000 white}
PROCESS ${alignc} PID CPU% ${alignr}MEM% ${color white}
${top name 1} ${alignc} ${top pid 1} ${top cpu 1} ${alignr}${top mem 1}
${top name 2} ${alignc} ${top pid 2} ${top cpu 2} ${alignr}${top mem 2}
${top name 3} ${alignc} ${top pid 3} ${top cpu 3} ${alignr}${top mem 3}
${top name 4} ${alignc} ${top pid 4} ${top cpu 4} ${alignr}${top mem 4}
${top name 5} ${alignc} ${top pid 5} ${top cpu 5} ${alignr}${top mem 5}
${color orange}BY MEMORY: ${stippled_hr}${color 000000 white}
PROCESS ${alignc} PID CPU% ${alignr}MEM% ${color white}
${top_mem name 1} ${alignc} ${top_mem pid 1} ${top_mem cpu 1} ${alignr}${top_mem mem 1}
${top_mem name 2} ${alignc} ${top_mem pid 2} ${top_mem cpu 2} ${alignr}${top_mem mem 2}
${top_mem name 3} ${alignc} ${top_mem pid 3} ${top_mem cpu 3} ${alignr}${top_mem mem 3}
${top_mem name 4} ${alignc} ${top_mem pid 4} ${top_mem cpu 4} ${alignr}${top_mem mem 4}
${top_mem name 5} ${alignc} ${top_mem pid 5} ${top_mem cpu 5} ${alignr}${top_mem mem 5}
#
#
#${exec feh --bg-scale "`grep 'wallpaper=' ~/.kde4/share/config/plasma-desktop-appletsrc | tail --lines=1 | sed 's/wallpaper=//'`"}
FILESERVER RAID ARRAY CONKY (UPPER MIDDLE CONFIG) -- This data is pulled from a file on my server that's fed via a Cron job that runs every hour.
# Conky process config file
background yes
use_xft yes
xftfont Monospace:size=11
xftalpha 0.8
out_to_console no
update_interval 2
total_run_times 0
own_window yes
own_window_type override
own_window_transparent yes
own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager
double_buffer yes
minimum_size 375
draw_shades no
draw_outline no
draw_borders no
draw_graph_borders yes
stippled_borders 5
#border_margin 4
default_color grey
default_shade_color black
default_outline_color black
alignment top_right
gap_x 420
gap_y 25
no_buffers no
uppercase no
cpu_avg_samples 2
net_avg_samples 2
override_utf8_locale yes
use_spacer none
TEXT
${color orange}FILESERVER RAID ARRAY STATUS: $stippled_hr
${color white}${execi 60 tail /mnt/Serverbox/Shared/Serverbox_outputs/Raid_Check.txt}
NETWORK CONKY (UPPER LEFT CONFIG)
# Conky configuration
background yes
use_xft yes
xftfont Monospace:size=11
xftalpha 0.8
out_to_console no
update_interval 2
total_run_times 0
own_window yes
own_window_type override
own_window_transparent yes
own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager
double_buffer yes
minimum_size 347
draw_shades no
draw_outline no
draw_borders no
draw_graph_borders yes
stippled_borders 5
#border_margin 4
default_color grey
default_shade_color black
default_outline_color black
#alignment bottom_right
#gap_x 20
#gap_y 40
alignment top_right
gap_x 930
gap_y 5
no_buffers no
uppercase no
cpu_avg_samples 2
net_avg_samples 2
override_utf8_locale yes
use_spacer none
TEXT
${color orange}NETWORK: $stippled_hr
#${font Monospace:normal:size=13} Firewall Status ${alignr}${if_existing /var/run/daemons/iptables } Active${else}${alignr}Disabled$endif${font Monospace:normal:size=11}
${color white}Down:${color white} ${downspeed eth0} k/s ${color white}${offset 80}Up:${color white} ${upspeed eth0} k/s
${color #000000}${downspeedgraph eth0 25,150 000000 white} ${color #white}${upspeedgraph eth0 25,150 000000 white}
${color white}Address: ${color white}${addr eth0}${alignr}${color white}TCP Connections: ${color 000000 white}${tcp_portmon 1 65535 count}
#${color orange}CONNECTIONS ${stippled_hr}
${alignc}${color orange}--- CONNECTIONS ---
Inbound Connections: ${tcp_portmon 1 32767 count} ${alignr} Local Service / Port${color white}
${tcp_portmon 1 32767 rhost 0} ${alignr} ${tcp_portmon 1 32767 lservice 0}
${tcp_portmon 1 32767 rhost 1} ${alignr} ${tcp_portmon 1 32767 lservice 1}
${tcp_portmon 1 32767 rhost 2} ${alignr} ${tcp_portmon 1 32767 lservice 2}
${tcp_portmon 1 32767 rhost 3} ${alignr} ${tcp_portmon 1 32767 lservice 3}
${color orange} Outbound Connections: ${tcp_portmon 32768 61000 count} ${alignr} Remote Service / Port${color white}
${tcp_portmon 32768 61000 rhost 0} ${alignr} ${tcp_portmon 32768 61000 rservice 0}
${tcp_portmon 32768 61000 rhost 1} ${alignr} ${tcp_portmon 32768 61000 rservice 1}
${tcp_portmon 32768 61000 rhost 2} ${alignr} ${tcp_portmon 32768 61000 rservice 2}
${tcp_portmon 32768 61000 rhost 3} ${alignr} ${tcp_portmon 32768 61000 rservice 3}
${tcp_portmon 32768 61000 rhost 4} ${alignr} ${tcp_portmon 32768 61000 rservice 4}
Last edited by imatechguy (2011-01-15 05:07:26)
Offline
Looks great Imatechguy!!!
"Every normal man must be tempted at times to spit upon his hands, hoist the black flag, and begin slitting throats." -- H.L. Mencken
Website Configs
Forum Admin: Bruno's All Things Linux
securitybreach<a>archlinux.us
Offline
Thanks securitybreach. I'm pretty happy with the layout for the Wallpaper I have but I'd really like to find a better one so I can consolidate some of those conky files. Once I find a background I'm happy with I'll probably tweak a few things while I'm combining the conky files to make it more readable instead of being so spread out. Having a 25" monitor helps but I'd really like to have a better flow to it all.
Offline
Thanks securitybreach. I'm pretty happy with the layout for the Wallpaper I have but I'd really like to find a better one so I can consolidate some of those conky files. Once I find a background I'm happy with I'll probably tweak a few things while I'm combining the conky files to make it more readable instead of being so spread out. Having a 25" monitor helps but I'd really like to have a better flow to it all.
Kewl. I have 3x22" so I know what you mean about the screen real estate.
"Every normal man must be tempted at times to spit upon his hands, hoist the black flag, and begin slitting throats." -- H.L. Mencken
Website Configs
Forum Admin: Bruno's All Things Linux
securitybreach<a>archlinux.us
Offline
Here's a screenshot of my desktop.
http://img194.imageshack.us/img194/8392/conkyscreen.png
alignment top_right
background yes
border_width 1
cpu_avg_samples 2
draw_graph_borders yes
use_xft yes
xftfont Ubuntu:size=8
gap_x 5
gap_y 10
net_avg_samples 2
own_window yes
own_window_class Conky
own_window_type override
update_interval 5
maximum_width 220
minimum_size 220
double_buffer yes
TEXT
#DATE
DATE ${hr 1}
${alignc 17}${font Arial Black:size=16}${time %H:%M}${font}
${alignc}${time %A %d %B %Y}
#WEATHER
${voffset 6}WEATHER ${hr 1}
# CITY
${voffset 2}${alignc}${execi 1800 conkyForecast --location=FIXX0002 --datatype=CN}
#CURRENT WEATHER & WIND SYMBOL
${voffset 2}${goto 67.5}${font ConkyWeather:style=Bold:size=25}${execi 1800 conkyForecast --location=FIXX0002 --datatype=WF}${font}${goto 127.5}${voffset -21}${font ConkyWindNESW:size=25}${execi 1800 conkyForecast --location=FIXX0002 --datatype=BS}${font}
# CURRENT WEATHER TEMP/FEELS LIKE TEMP, WIND SPEED & DIRECTION
${alignc}${voffset 2}${execi 1800 conkyForecast --location=FIXX0002 --datatype=HT}/${execi 1800 conkyForecast --location=FIXX0002 --datatype=LT}, ${execi 1800 conkyForecast --location=FIXX0002 --datatype=WS} ${execi 1800 conkyForecast --location=FIXX0002 --datatype=WD}
# CURRENT WEATHER CONDITIONS, TEXT
${alignc}${font Bitstream Vera Sans Mono:size=8}${execi 1800 conkyForecast --location=FIXX0002 --datatype=CC}${font}
# WEATHER FORECAST 4 DAYS, SYMBOLS
${goto 20}${font ConkyWeather:style=Bold:size=20}${execi 1800 conkyForecast --location=FIXX0002 --datatype=WF --startday=1}${font}${goto 75}${voffset -15}${font ConkyWeather:style=Bold:size=20}${execi 1800 conkyForecast --location=FIXX0002 --datatype=WF --startday=2}${font}${goto 130}${voffset -15}${font ConkyWeather:style=Bold:size=20}${execi 1800 conkyForecast --location=FIXX0002 --datatype=WF --startday=3}${font}${goto 185}${voffset -15}${font ConkyWeather:style=Bold:size=20}${execi 1800 conkyForecast --location=FIXX0002 --datatype=WF --startday=4}${font}
# WEATHER FORECAST 4 DAYS, DAY OF WEEK
${goto 20}${execi 1800 conkyForecast --datatype=DW --startday=1 --shortweekday}${goto 75}${execi 1800 conkyForecast --datatype=DW --startday=2 --shortweekday}${goto 130}${execi 1800 conkyForecast --datatype=DW --startday=3 --shortweekday}${goto 185}${execi 1800 conkyForecast --datatype=DW --startday=4 --shortweekday}
# WEATHER FORECAST 4 DAYS, HIGH / LOW
${execi 1800 conkyForecast --location=FIXX0002 --datatype=HT --startday=1}/${execi 1800 conkyForecast --location=FIXX0002 --datatype=LT --startday=1}${goto 65}${execi 1800 conkyForecast --location=FIXX0002 --datatype=HT --startday=2}/${execi 1800 conkyForecast --location=FIXX0002 --datatype=LT --startday=2}${goto 125}${execi 1800 conkyForecast --location=FIXX0002 --datatype=HT --startday=3}/${execi 1800 conkyForecast --location=FIXX0002 --datatype=LT --startday=3}${goto 185}${execi 1800 conkyForecast --location=FIXX0002 --datatype=HT --startday=4}/${execi 1800 conkyForecast --location=FIXX0002 --datatype=LT --startday=4}
#SYSTEM
${voffset 6}SYSTEM ${hr 1}
${alignc}$kernel
${font StyleBats:size=16}O${font} Uptime: ${alignr}${uptime}
${font StyleBats:size=16}A${font} CPU: ${cpu cpu0}% ${alignr}${cpubar cpu0 6,60}
${font StyleBats:size=16}G${font} RAM: $memperc% ${alignr}${membar 6,60}
${font StyleBats:size=16}J${font} SWAP: $swapperc% ${alignr}${swapbar 6,60}
${font StyleBats:size=16}P${font} Battery: ${battery_percent}% ${alignr}${battery_bar 6,60}
${font StyleBats:size=16}T${font} Volume: $mixer% ${goto 165}${mixerbar}
${font StyleBats:size=16}8${font} ${execpi 3600 paconky ~/.paconky-conf}
${font StyleBats:size=16}8${font} ${execpi 3600 paconky ~/.paconky-aur}
#HD
${color white}${voffset 6}HD ${hr 1}
${font Pie charts for maps:size=14}7${font} ${voffset -5}Root: ${fs_used /}/${fs_size /} ${alignr}${fs_bar 6,60 /}
${font Pie charts for maps:size=14}7${font} ${voffset -5}Home: ${fs_used /home/}/${fs_size /home/} ${alignr}${fs_bar 6,60 /home/}
#WIRELESS
${voffset 6}WIRELESS ${hr 1}
${if_existing /proc/net/route wlan0}${font PizzaDude Bullets:size=14}]${font} SSID: ${alignr}${wireless_essid wlan0}
${font PizzaDude Bullets:size=14}^${font} Signal: ${wireless_link_qual wlan0}% ${alignr}${wireless_link_bar 6,60 wlan0}
${font PizzaDude Bullets:size=14}a${font} IP:${alignr}${curl ifconfig.me 600} ${voffset 4}${font PizzaDude Bullets:size=14}e${font} Local Ip: ${alignr}${addr wlan0}
${font PizzaDude Bullets:size=14}O${font} Up: ${upspeed wlan0} kb/s ${alignr}${upspeedgraph wlan0 6,60 BEBEBE BEBEBE}
${font PizzaDude Bullets:size=14}U${font} Down: ${downspeed wlan0}kb/s ${alignr}${downspeedgraph wlan0 6,60 BEBEBE BEBEBE}
${font PizzaDude Bullets:size=14}N${font} Uploaded: ${alignr}${totalup wlan0}
${font PizzaDude Bullets:size=14}T${font} Downloaded: ${alignr}${totaldown wlan0}${else}${voffset 4}${font PizzaDude Bullets:size=14}4${font} Network Unavailable${endif}
#PROCESSES
${voffset 6}PROCESSES ${hr 1}
name $alignr pid cpu
${voffset 2}${top name 1} $alignr ${top pid 1} ${top cpu 1}
${top name 2} $alignr ${top pid 2} ${top cpu 2}
${top name 3} $alignr ${top pid 3} ${top cpu 3}
${top name 4} $alignr ${top pid 4} ${top cpu 4}
${top name 5} $alignr ${top pid 5} ${top cpu 5}
${hr 1}
Offline
I'm just not a one-conky kind of guy.
Weather (using conkyforecast from AUR):
background yes
use_xft yes
xftfont Droid Sans Mono:size=8
xftalpha 0.8
update_interval 20
double_buffer yes
minimum_size 270 60
maximum_width 270
draw_shades yes
draw_outline no
draw_borders no
default_color white
default_shade_color black
own_window yes
own_window_transparent yes
own_window_argb_visual yes
own_window_type normal
own_window_hints undecorate,below,sticky,skip_taskbar,skip_pager
#own_window_color 4c4c4c
alignment top_left
gap_x 0
gap_y 20
uppercase no
cpu_avg_samples 2
net_avg_samples 2
override_utf8_locale yes
color1 white
color3 30AA30
color2 858783
color5 82D63F
color4 6ED6FF
text_buffer_size 2048
imlib_cache_size 0
TEXT
${if_gw}${execpi 1800 conkyForecast --location=######## --template=/home/zom/.conky/weather-forecast.template}
${else}${color4}Weather unavailable.$endif
Weather template:
${color4}${font ConkyWeather:style=Bold:size=60}[--datatype=WF]${font}${voffset -74}${goto 100}${color}${font Droid Sans Mono:size=29}[--datatype=HT --centeredwidth=3 --hideunits]
${goto 105}${font Droid Sans Mono:size=8}${voffset -46}
${goto 105}${color} [--datatype=CT]
${goto 105}${color2} [--datatype=SR] / [--datatype=SS]
${goto 105}[--datatype=WD ] [--datatype=WS ]
${voffset -70}${color4}${goto 230}${font ConkyWeather:size=20}[--datatype=WF --startday=1 --endday=1 --spaces=1]${font}
${voffset 12}${color4}${goto 230}${font ConkyWeather:size=20}[--datatype=WF --startday=2 --endday=2 --spaces=1]${font}
Clock (using a lua script to generate the rings):
background yes
update_interval 2
cpu_avg_samples 2
net_avg_samples 2
override_utf8_locale yes
double_buffer yes
no_buffers yes
text_buffer_size 2048
imlib_cache_size 0
own_window_type normal
own_window_hints undecorate,sticky,skip_taskbar,skip_pager,below
own_window yes
own_window_transparent yes
own_window_argb_visual yes
own_window_title clock
border_inner_margin 0
border_outer_margin 0
minimum_size 104 104
alignment bottom_left
gap_x 0
gap_y 24
draw_shades no
draw_outline no
draw_borders no
draw_graph_borders no
use_xft yes
xftfont Droid Sans Mono:size=13
xftalpha 0.7
default_color 6ED6FF
color1 5EC6EF
lua_load ~/.conky/clock.lua
#lua_load ~/.conky/text.lua
lua_draw_hook_pre main_rings
#lua_draw_hook_post draw_text
TEXT
${voffset 36}${goto 25}${time %H:%M}
${voffset -10}${goto 34}${font :size=8}$color1${time %d %b}
The Lua part of the clock:
--[[ RINGS with SECTORS widget
v1.0 by wlourf (08.08.2010)
this widget draws a ring with differents effects
http://u-scripts.blogspot.com/2010/08/rings-sectors-widgets.html
To call the script in a conky, use, before TEXT
lua_load /path/to/the/script/rings.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:
xc,yc - coordinates of the center of the ring,
default = middle of the conky window
radius - external radius of the ring, in pixels,
default = quarter of the width of the conky window
thickness - thickness of the ring, in pixels, default = 10 pixels
start_angle - starting angle of the ring, in degrees, value can be negative,
default = 0 degree
end_angle - ending angle of the ring, in degrees,
value must be greater than start_angle, default = 360 degrees
sectors - number of sectors in the ring, default = 10
gap_sectors - gap between two sectors, in pixels, default = 1 pixel
cap - the way to close a sector, available values are
"p" for parallel , default value
"r" for radial (follow the radius)
inverse_arc - if set to true, arc will be anticlockwise, default=false
border_size - size of the border, in pixels, default = 0 pixel i.e. no border
fill_sector - if set to true, each sector will be completely filled,
default=false, this parameter is inoperate if sectors=1
background - if set to false, background will not be drawn, default=true
foreground - if set to false, foreground will not be drawn, default=true
Colours tables below are defined into braces :
{position in the gradient (0 to 1), colour in hexadecimal, alpha (0 to 1)}
example for a single colour table :
{{0,0xFFAA00,1}} position parameter doesn't matter
example for a two-colours table :
{{0,0xFFAA00,1},{1,0x00AA00,1}} or {{0.5,0xFFAA00,1},{1,0x00AA00,1}}
example for a three-colours table :
{{0,0xFFAA00,1},{0.5,0xFF0000,1},{1,0x00AA00,1}}
bg_colour1 - colour table for background,
default = {{0,0x00ffff,0.1},{0.5,0x00FFFF,0.5},{1,0x00FFFF,0.1}}
fg_colour1 - colour table for foreground,
default = {{0,0x00FF00,0.1},{0.5,0x00FF00,1},{1,0x00FF00,0.1}}
bd_colour1 - colour table for border,
default = {{0,0xFFFF00,0.5},{0.5,0xFFFF00,1},{1,0xFFFF00,0.5}}
Seconds tables for radials gradients :
bg_colour2 - second colour table for background, default = no second colour
fg_colour2 - second colour table for foreground, default = no second colour
bd_colour2 - second colour table for border, default = no second colour
v1.0 (08 Aug. 2010) original release
]]
require 'cairo'
function conky_main_rings()
-- START PARAMETERS HERE
rings_settings={
{
--Ring 1 :hours
name="time",
arg="%I",
max=12,
xc=52,
yc=52,
radius=45,
thickness=6,
sectors=12,
gap_sectors=1,
fill_sector=true,
bg_colour1={{0,0x6ED6FF,0.05},{0.5,0x6ED6FF,0.05}, {1,0x6ED6FF,0.05}},
fg_colour1={{0,0x6ED6FF,0.5},{0.5,0x6ED6FF,0.6}, {1,0x6ED6FF,0.7}},
bd_colour1={{0,0X000000,0},{0.5,0x000000,0}, {1,0x000000,0}},
},
{
--Ring 1 :minutes
name="time",
arg="%M",
max=60,
xc=52,
yc=52,
radius=52,
thickness=6,
sectors=60,
gap_sectors=0,
fill_sector=true,
bg_colour1={{0,0x6ED6FF,0.05},{0.5,0x6ED6FF,0.05}, {1,0x6ED6FF,0.05}},
fg_colour1={{0,0x6ED6FF,0.5},{0.5,0x6ED6FF,0.4}, {1,0x6ED6FF,0.3}},
bd_colour1={{0,0X000000,0},{0.5,0x000000,0}, {1,0x000000,0}},
},
}
--END OF PARAMETERS HERE
--main function
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)
if tonumber(conky_parse('${updates}'))>3 then
for i in pairs(rings_settings) do
draw_ring(rings_settings[i])
end
end
cairo_destroy(cr)
end
function draw_ring(t)
local function rgba_to_r_g_b_a(tcolour)
colour,alpha=tcolour[2],tcolour[3]
return ((colour / 0x10000) % 0x100) / 255.,
((colour / 0x100) % 0x100) / 255., (colour % 0x100) / 255., alpha
end
local function calc_delta(tcol1,tcol2)
--calculate deltas P R G B A to table_colour 1
for x = 1, #tcol1 do
tcol1[x].dA = 0
tcol1[x].dP = 0
tcol1[x].dR = 0
tcol1[x].dG = 0
tcol1[x].dB = 0
if tcol2~=nil and #tcol1 == #tcol2 then
local r1,g1,b1,a1 = rgba_to_r_g_b_a(tcol1[x])
local r2,g2,b2,a2 = rgba_to_r_g_b_a(tcol2[x])
tcol1[x].dP = (tcol2[x][1]-tcol1[x][1])/t.sectors
tcol1[x].dR = (r2-r1)/t.sectors
tcol1[x].dG = (g2-g1)/t.sectors
tcol1[x].dB = (b2-b1)/t.sectors
tcol1[x].dA = (a2-a1)/t.sectors
end
end
return tcol1
end
--check values
local function setup(t)
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'")
print ("for name=" .. t.name)
print ("with arg=" .. t.arg)
return
end
if t.name==nil then t.name="" end
if t.arg==nil then t.arg="" end
if t.xc==nil then t.xc=conky_window.width/2 end
if t.yc==nil then t.yc=conky_window.height/2 end
if t.thickness ==nil then t.thickness = 10 end
if t.radius ==nil then t.radius =conky_window.width/4 end
if t.start_angle==nil then t.start_angle =0 end
if t.end_angle==nil then t.end_angle=360 end
if t.bg_colour1==nil then
t.bg_colour1={{0,0x00ffff,0.1},{0.5,0x00FFFF,0.5},{1,0x00FFFF,0.1}}
end
if t.fg_colour1==nil then
t.fg_colour1={{0,0x00FF00,0.1},{0.5,0x00FF00,1},{1,0x00FF00,0.1}}
end
if t.bd_colour1==nil then
t.bd_colour1={{0,0xFFFF00,0.5},{0.5,0xFFFF00,1},{1,0xFFFF00,0.5}}
end
if t.sectors==nil then t.sectors=10 end
if t.gap_sectors==nil then t.gap_sectors=1 end
if t.fill_sector==nil then t.fill_sector=false end
if t.sectors==1 then t.fill_sector=false end
if t.border_size==nil then t.border_size=0 end
if t.cap==nil then t.cap="p" end
--some checks
if t.thickness>t.radius then t.thickness=t.radius*0.1 end
t.int_radius = t.radius-t.thickness
--check colors tables
for i=1, #t.bg_colour1 do
if #t.bg_colour1[i]~=3 then t.bg_colour1[i]={1,0xFFFFFF,0.5} end
end
for i=1, #t.fg_colour1 do
if #t.fg_colour1[i]~=3 then t.fg_colour1[i]={1,0xFF0000,1} end
end
for i=1, #t.bd_colour1 do
if #t.bd_colour1[i]~=3 then t.bd_colour1[i]={1,0xFFFF00,1} end
end
if t.bg_colour2~=nil then
for i=1, #t.bg_colour2 do
if #t.bg_colour2[i]~=3 then t.bg_colour2[i]={1,0xFFFFFF,0.5} end
end
end
if t.fg_colour2~=nil then
for i=1, #t.fg_colour2 do
if #t.fg_colour2[i]~=3 then t.fg_colour2[i]={1,0xFF0000,1} end
end
end
if t.bd_colour2~=nil then
for i=1, #t.bd_colour2 do
if #t.bd_colour2[i]~=3 then t.bd_colour2[i]={1,0xFFFF00,1} end
end
end
if t.start_angle>=t.end_angle then
local tmp_angle=t.end_angle
t.end_angle= t.start_angle
t.start_angle = tmp_angle
-- print ("inversed angles")
if t.end_angle-t.start_angle>360 and t.start_angle>0 then
t.end_angle=360+t.start_angle
print ("reduce angles")
end
if t.end_angle+t.start_angle>360 and t.start_angle<=0 then
t.end_angle=360+t.start_angle
print ("reduce angles")
end
if t.int_radius<0 then t.int_radius =0 end
if t.int_radius>t.radius then
local tmp_radius=t.radius
t.radius=t.int_radius
t.int_radius=tmp_radius
print ("inversed radius")
end
if t.int_radius==t.radius then
t.int_radius=0
print ("int radius set to 0")
end
end
t.fg_colour1 = calc_delta(t.fg_colour1,t.fg_colour2)
t.bg_colour1 = calc_delta(t.bg_colour1,t.bg_colour2)
t.bd_colour1 = calc_delta(t.bd_colour1,t.bd_colour2)
end
--initialize table
setup(t)
--[[grid
h=conky_window.height
w=conky_window.width
cairo_set_source_rgba(cr,1,1,1,1)
cairo_set_line_width(cr,0.5)
cairo_move_to(cr,0,t.yc)
cairo_line_to(cr,w,t.yc)
cairo_stroke(cr)
cairo_move_to(cr,t.xc,0)
cairo_line_to(cr,t.xc,h)
cairo_stroke(cr)
cairo_move_to(cr,t.xc,t.yc)
cairo_line_to(cr,t.xc+200*math.sin(math.pi/4),t.yc-200*math.cos(math.pi/4))
cairo_stroke(cr)
cairo_move_to(cr,0,t.yc-t.radius)
cairo_line_to(cr,w,t.yc-t.radius)
cairo_stroke(cr)
cairo_move_to(cr,0,t.yc-t.int_radius)
cairo_line_to(cr,w,t.yc-t.int_radius)
cairo_stroke(cr)
cairo_move_to(cr,0,t.yc-t.gap_sectors)
cairo_line_to(cr,w,t.yc-t.gap_sectors)
cairo_stroke(cr)
cairo_set_source_rgba(cr,1,0,0,0.5)
cairo_arc(cr,t.xc,t.yc,t.radius,0,2*math.pi)
cairo_stroke(cr)
cairo_arc(cr,t.xc,t.yc,t.int_radius,0,2*math.pi)
cairo_stroke(cr)
cairo_set_source_rgba(cr,0,1,0,1)
cairo_move_to(cr,t.xc+t.gap_sectors,t.yc-t.gap_sectors)
cairo_line_to(cr,t.xc+400*math.sin(math.pi/4),t.yc-400*math.cos(math.pi/4))
cairo_stroke(cr)
--END GRID
]]
--initialize cairo context
cairo_save(cr)
cairo_translate(cr,t.xc,t.yc)
cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND)
cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND)
--get value
local value = 0
if t.name ~="" then
value = tonumber(conky_parse(string.format('${%s %s}', t.name, t.arg)))
else
value = tonumber(t.arg)
end
if value==nil then value =0 end
--initialize sectors
--angle of a sector :
angleA = ((t.end_angle-t.start_angle)/t.sectors)*math.pi/180
--value of a sector :
valueA = t.max/t.sectors
--first angle of a sector :
lastAngle = t.start_angle*math.pi/180
local function draw_sector(type_arc,angle0,angle,valpc, idx)
--this function draws a portion of arc
--type of arc, angle0 = strating angle, angle= angle of sector,
--valpc = percentage inside the sector, idx = sctor number #
if type_arc=="bg" then --background
if valpc==1 then return end
tcolor=t.bg_colour1
elseif type_arc=="fg" then --foreground
if valpc==0 then return end
tcolor=t.fg_colour1
elseif type_arc=="bd" then --border
tcolor=t.bd_colour1
end
--angles equivalents to gap_sector
local ext_delta=math.atan(t.gap_sectors/(2*t.radius))
local int_delta=math.atan(t.gap_sectors/(2*t.int_radius))
--angles of arcs
local ext_angle=(angle-ext_delta*2)*valpc
local int_angle=(angle-int_delta*2)*valpc
--define colours to use for this sector
if #tcolor==1 then
--plain color
local vR,vG,vB,vA = rgba_to_r_g_b_a(tcolor[1])
cairo_set_source_rgba(cr,vR+tcolor[1].dR*idx,
vG+tcolor[1].dG*idx,
vB+tcolor[1].dB*idx,
vA+tcolor[1].dA*idx )
else
--radient color
local pat=cairo_pattern_create_radial(0,0,t.int_radius,0,0,t.radius)
for i=1, #tcolor do
local vP,vR,vG,vB,vA = tcolor[i][1], rgba_to_r_g_b_a(tcolor[i])
cairo_pattern_add_color_stop_rgba (pat,
vP+tcolor[i].dP*idx,
vR+tcolor[i].dR*idx,
vG+tcolor[i].dG*idx,
vB+tcolor[i].dB*idx,
vA+tcolor[i].dA*idx )
end
cairo_set_source (cr, pat)
cairo_pattern_destroy(pat)
end
--start drawing
cairo_save(cr)
--x axis is parrallel to start of sector
cairo_rotate(cr,angle0-math.pi/2)
local ri,re = t.int_radius ,t.radius
--point A
local angle_a
if t.cap == "p" then
angle_a = int_delta
if t.inverse_arc and type_arc ~="bg" then
angle_a = angle-int_angle-int_delta
end
if not(t.inverse_arc) and type_arc =="bg" then
angle_a = int_delta+int_angle
end
else --t.cap=="r"
angle_a = ext_delta
if t.inverse_arc and type_arc~="bg" then
angle_a = angle-ext_angle-ext_delta
end
if not(t.inverse_arc) and type_arc=="bg" then
angle_a = ext_delta+ext_angle
end
end
local ax,ay = ri*math.cos(angle_a),ri*math.sin(angle_a)
--point B
local angle_b = ext_delta
if t.cap == "p" then
if t.inverse_arc and type_arc ~="bg" then
angle_b = angle-ext_angle-ext_delta
end
if not(t.inverse_arc) and type_arc=="bg" then
angle_b = ext_delta+ext_angle
end
else
if t.inverse_arc and type_arc ~="bg" then
angle_b = angle-ext_angle-ext_delta
end
if not(t.inverse_arc) and type_arc=="bg" then
angle_b = ext_delta+ext_angle
end
end
local bx,by = re*math.cos(angle_b),re*math.sin(angle_b)
-- EXTERNAL ARC B --> C
if t.inverse_arc then
if type_arc=="bg" then
b0,b1= ext_delta, angle-ext_delta-ext_angle
else
b0,b1= angle-ext_angle-ext_delta, angle-ext_delta
end
else
if type_arc=="bg" then
b0,b1= ext_delta+ext_angle, angle-ext_delta
else
b0,b1= ext_delta, ext_angle+ext_delta
end
end
---POINT D
local angle_c
if t.cap == "p" then
angle_d = angle-int_delta
if t.inverse_arc and type_arc=="bg" then
angle_d = angle-int_delta-int_angle
end
if not(t.inverse_arc) and type_arc~="bg" then
angle_d=int_delta+int_angle
end
else
angle_d = angle-ext_delta
if t.inverse_arc and type_arc=="bg" then
angle_d =angle-ext_delta-ext_angle
end
if not(t.inverse_arc) and type_arc~="bg" then
angle_d = ext_angle+ext_delta
end
end
local dx,dy = ri*math.cos(angle_d),ri*math.sin(angle_d)
-- INTERNAL ARC D --> A
if t.cap=="p" then
if t.inverse_arc then
if type_arc=="bg" then
d0,d1= angle-int_delta-int_angle,int_delta
else
d0,d1= angle-int_delta, angle- int_angle-int_delta
end
else
if type_arc=="bg" then
d0,d1= angle-int_delta, int_delta+int_angle
else
d0,d1= int_delta+int_angle, int_delta
end
end
else
if t.inverse_arc then
if type_arc=="bg" then
d0,d1= angle-ext_delta-ext_angle,ext_delta
else
d0,d1= angle-ext_delta, angle- ext_angle-ext_delta
end
else
if type_arc=="bg" then
d0,d1= angle-ext_delta,ext_delta+ext_angle
else
d0,d1= ext_angle+ext_delta, ext_delta
end
end
end
--draw sector
cairo_move_to(cr,ax,ay)
cairo_line_to(cr,bx,by)
cairo_arc(cr,0,0,re,b0,b1)
cairo_line_to(cr,dx,dy)
cairo_arc_negative(cr,0,0,ri,d0,d1)
cairo_close_path (cr);
--stroke or fill sector
if type_arc=="bd" then
cairo_set_line_width(cr,t.border_size)
cairo_stroke(cr)
else
cairo_fill(cr)
end
cairo_restore(cr)
end
--draw sectors
local n0,n1,n2 = 1,t.sectors,1
if t.inverse_arc then n0,n1,n2 = t.sectors,1,-1 end
local index = 0
for i = n0,n1,n2 do
index = index +1
local valueZ=1
local cstA, cstB = (i-1),i
if t.inverse_arc then cstA,cstB = (t.sectors-i), (t.sectors-i+1) end
if value>valueA *cstA and value<valueA*cstB then
if not t.fill_sector then
valueZ = (value-valueA*cstA)/valueA
end
else
if value<valueA*cstB then valueZ=0 end
end
local start_angle= lastAngle+(i-1)*angleA
if t.foreground ~= false then
draw_sector("fg",start_angle,angleA,valueZ, index)
end
if t.background ~= false then
draw_sector("bg",start_angle,angleA,valueZ, i)
end
if t.border_size>0 then draw_sector("bd",start_angle,angleA,1, i) end
end
cairo_restore(cr)
end
--[[END OF RING-SECTORS WIDGET]]
function axis(ctx,alpha)
cairo_set_line_width(ctx,1)
cairo_set_source_rgba(ctx,1,0,0,alpha)
cairo_move_to(ctx,0,0)
cairo_line_to(ctx,150,0)
cairo_stroke(ctx)
cairo_set_source_rgba(ctx,0,1,0,alpha)
cairo_move_to(ctx,0,0)
cairo_line_to(ctx,0,150)
cairo_stroke(ctx)
end
System monitor:
background yes
use_xft yes
xftfont Droid Sans Mono:size=8
xftalpha 0.8
update_interval 1.0
total_run_times 0
own_window yes
#own_window_type normal
own_window_type normal
own_window_argb_visual yes
own_window_argb_value 0
#own_window_transparent yes
#own_window_color 4c4c4c
own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager
double_buffer yes
minimum_size 120 8
maximum_width 120
draw_shades no
draw_outline no
draw_borders no
draw_graph_borders yes
default_color white
default_shade_color black
alignment top_right
gap_x 0
gap_y 20
no_buffers yes
cpu_avg_samples 2
override_utf8_locale yes
uppercase no
text_buffer_size 768
color2 6ED6FF
color3 858783
if_up_strictness link
TEXT
${color}${cpu cpu1}%
${font}${color}${freq_g} GHz
${font}${color}${if_up wlan0}${wireless_link_qual_perc wlan0}%
${font}${color}${scroll 10 1 ${wireless_essid wlan0}}\
${else}\
${if_up eth0}
${font}${color}By Cable\
${else}
${font}${color}Not Connected\
${endif}${endif}
${font}${color}${if_existing /proc/acpi/battery/BAT1/state no}${if_match ${battery_percent BAT1}<10}${color red}\
${endif}${battery_percent BAT1}${color}%
${font}${color}${if_existing /proc/acpi/ac_adapter/ACAD/state off-line}\
${if_match ${battery_percent BAT1}==100}Fully Charged${else}Charging${endif}${else}${battery_time BAT1}\
${endif}${else}AC Only${endif}
${voffset -70}${font :size=6}${alignr}${color2}CPU
${voffset 16}${font :size=6}${alignr}${color2}NET
${voffset 16}${font :size=6}${alignr}${color2}POW
Calendar:
background yes
use_xft yes
xftfont Droid Sans Mono:size=8
xftalpha 0.8
update_interval 1.0
total_run_times 0
own_window yes
#own_window_type normal
own_window_type normal
own_window_argb_visual yes
own_window_argb_value 0
#own_window_transparent yes
#own_window_color 4c4c4c
own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager
double_buffer yes
minimum_size 120 8
maximum_width 120
draw_shades no
draw_outline no
draw_borders no
draw_graph_borders yes
default_color white
default_shade_color black
alignment bottom_right
gap_x 0
gap_y 28
no_buffers yes
cpu_avg_samples 2
override_utf8_locale yes
uppercase no
text_buffer_size 768
color2 6ED6FF
color3 858783
if_up_strictness link
TEXT
${font :size=9}${color}${alignr}${time %A %d %b} ${color}${font}
${font}${color2}må ti on to fr lö sö${color3}
${color3}${execpi 60 DJS=`date +%_d`; cal | sed '1d' | sed '1d' | sed s/"$DJS"'\b'/'${color2}'"$DJS"'${color3}'/}
This is for my netbook obviously, I use the same setup but with a different colourscheme for my desktop, minus the system monitor.
Last edited by Zom (2011-01-26 05:54:04)
Offline
Would anyone have any idea how to add a CPU temp to Conky but have -8 degrees removed from the value?
I have a AMD k10 and the sensor is borked in a bunch of then and I figured out that 8 degrees below what sensors reports is close to right on the money.
Is this possible?
Offline
Just edit the source code.
I'm french, don't mind my mistakes in english.
Offline
My own version of .
# ~/.conkyrc # # conky configuration file. alignment top_right background yes #border_margin 0 #border_width 0 cpu_avg_samples 2 #color0 7d7d7d #color1 green #color2 ffffff double_buffer yes draw_shades no draw_outline no draw_borders no default_color black #draw_graph_borders no #default_shade_color cyan #default_outline_color cyan gap_x 10 gap_y 10 #mail_spool $MAIL #minimum_size 330 10 #maximum_width 330 no_buffers yes net_avg_samples 2 out_to_console no own_window yes own_window_type desktop own_window_transparent yes own_window_colour cyan own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager override_utf8_locale no stippled_borders 0 total_run_times 0 use_xft yes use_spacer right update_interval 1.0 uppercase no #wm_class_name Conky xftfont droid sans mono:size=9 xftalpha 0.8 TEXT SYSTEM ${hr} ${alignc 15}${font droid sans mono:size=14}${nodename}${font} ${font StyleBats:size=16}u${font} kernel: ${alignr}${kernel} ${font StyleBats:size=16}o${font} cpu: ${cpu cpu0}% ${alignr}${cpubar cpu0 8,60} ${font StyleBats:size=16}a$font} mem: ${memperc}% ${alignr}${membar 8,60} ${font StyleBats:size=16}p${font} bat: ${battery_percent}% ${alignr}${battery_bar 8,60} ${font StyleBats:size=16}q${font} uptime: ${alignr}${uptime} TIME ${hr} ${alignc 15}${font droid sans mono:size=14}${time %H:%M}${font} ${alignc}${time %a %d %b} HDD ${hr} ${alignc}${font StyleBats:size=16}Y${font} root: ${fs_used /} ${alignc}${fs_bar 8,60 /} NETWORK ${hr} ${if_existing /proc/net/route wlan0}${alignc}${wireless_essid wlan0} @ ${wireless_bitrate wlan0} ${alignc}${wireless_link_bar 8,60 wlan0} ${font PizzaDude Bullets:size=14}N${font} up: ${upspeedf wlan0} ${alignr}${upspeedgraph wlan0 8,60} ${font PizzaDude Bullets:size=14}T${font} down: ${downspeedf wlan0} ${alignr}${downspeedgraph wlan0 8,60}${else}${if_existing /proc/net/route eth0}${font PizzaDude Bullets:size=14}O${font} up: ${upspeedf eth0} ${alignr}${upspeedgraph eth0 8,60} ${font PizzaDude Bullets:size=14}U${font} down: ${downspeedf eth0} ${alignr}${downspeedgraph eth0 8,60}${else}${font PizzaDude Bullets:size=14}G${font} Network Unavailable${endif}${endif} PACKAGES ${hr} ARCH: ${alignr}${execpi 3600 paconky /home/ibnarrashid/scripts/shell/repos.paconky} AUR: ${alignr}${execpi 3600 paconky /home/ibnarrashid/scripts/shell/aur.paconky} # End of file.
awesome tnx
If it ain't broke, broke it then fix it.
Offline
I'm just not a one-conky kind of guy.
http://ompldr.org/vNzFseg
...
Hi everyone,
I'm trying to get work this part with clock and it's not going well. I get:
Conky: llua_do_call: function conky_main_rings execution failed: attempt to call a nil value
Any suggestions?
Offline
Zom wrote:I'm just not a one-conky kind of guy.
http://ompldr.org/vNzFseg
...Hi everyone,
I'm trying to get work this part with clock and it's not going well. I get:Conky: llua_do_call: function conky_main_rings execution failed: attempt to call a nil value
Any suggestions?
You need conky-lua from AUR.
Offline
You are wrong,
pacman -Qi conky-lua-nv
Name : conky-lua-nv
Version : 1.8.1-1
URL : http://conky.sourceforge.net/
Licenses : custom
Groups : None
Provides : conky
Depends On : alsa-lib libxml2 curl cairo wireless_tools libxft glib2
libxdamage imlib2 toluapp nvidia libxnvctrl
Optional Deps : None
Required By : None
Conflicts With : conky
Replaces : torsmo conky
Installed Size : 1172.00 K
Packager : Unknown Packager
Architecture : x86_64
Build Date : Mon 24 Jan 2011 08:59:30 PM CET
Install Date : Mon 24 Jan 2011 08:59:52 PM CET
Install Reason : Explicitly installed
Install Script : No
Description : An advanced system monitor for X based on torsmo with lua and
nvidia enabled
first i tried conky-lua next this one above nothing is working.
Perhaps this got something to do with line?
if conky_window==nil then return end
?
conky -v
Conky 1.8.1 compiled Mon Jan 24 20:58:49 CET 2011 for Linux 2.6.37-ARCH (x86_64)
Compiled in features:
System config file: /etc/conky/conky.conf
Package library path: /usr/lib/conky
X11:
* Xdamage extension
* XDBE (double buffer extension)
* Xft
* ARGB visual
Music detection:
* MPD
* MOC
General:
* math
* hddtemp
* portmon
* Curl
* RSS
* wireless
* support for IBM/Lenovo notebooks
* nvidia
* config-output
* Imlib2
* apcupsd
* iostats
* ncurses
* Lua
Lua bindings:
* Cairo
* Imlib2
Offline
You are wrong,
Then I don't know what to tell you. You could throw your conkyrc up somewhere so I could have a look and try spotting what could be wrong, but if you copied mine straight off then it should just work.
I'm using it on two different computers, 32- and 64-bit. I'm using conky-lua-old (1.8.0) though, since 1.8.1 messes up the weather script for some reason. Still, worked just fine while I was on 1.8.1 for a short period.
Last edited by Zom (2011-01-25 17:05:06)
Offline
I don't have any my own .conkyrc file. I'm using your clock config for conky, the one you posted in this topic
Clock (using a lua script to generate the rings):
...
System monitor:
conky -c ~/.conky/conkyclock
So, it seems we have a mystery
Offline
I don't have any my own .conkyrc file. I'm using your clock config for conky, the one you posted in this topic
So, it seems we have a mystery
And you have the clock script in the same .conky folder?
Else, you need to change this line:
lua_load ~/.conky/clock.lua
in your conkyrc.
(I think that would produce a different error though, hmm).
E: Hold on, I think I got it. Something must've messed with the indentation of the file. I'll paste a corrected one below:
--[[ RINGS with SECTORS widget
v1.0 by wlourf (08.08.2010)
this widget draws a ring with differents effects
http://u-scripts.blogspot.com/2010/08/rings-sectors-widgets.html
To call the script in a conky, use, before TEXT
lua_load /path/to/the/script/rings.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:
xc,yc - coordinates of the center of the ring,
default = middle of the conky window
radius - external radius of the ring, in pixels,
default = quarter of the width of the conky window
thickness - thickness of the ring, in pixels, default = 10 pixels
start_angle - starting angle of the ring, in degrees, value can be negative,
default = 0 degree
end_angle - ending angle of the ring, in degrees,
value must be greater than start_angle, default = 360 degrees
sectors - number of sectors in the ring, default = 10
gap_sectors - gap between two sectors, in pixels, default = 1 pixel
cap - the way to close a sector, available values are
"p" for parallel , default value
"r" for radial (follow the radius)
inverse_arc - if set to true, arc will be anticlockwise, default=false
border_size - size of the border, in pixels, default = 0 pixel i.e. no border
fill_sector - if set to true, each sector will be completely filled,
default=false, this parameter is inoperate if sectors=1
background - if set to false, background will not be drawn, default=true
foreground - if set to false, foreground will not be drawn, default=true
Colours tables below are defined into braces :
{position in the gradient (0 to 1), colour in hexadecimal, alpha (0 to 1)}
example for a single colour table :
{{0,0xFFAA00,1}} position parameter doesn't matter
example for a two-colours table :
{{0,0xFFAA00,1},{1,0x00AA00,1}} or {{0.5,0xFFAA00,1},{1,0x00AA00,1}}
example for a three-colours table :
{{0,0xFFAA00,1},{0.5,0xFF0000,1},{1,0x00AA00,1}}
bg_colour1 - colour table for background,
default = {{0,0x00ffff,0.1},{0.5,0x00FFFF,0.5},{1,0x00FFFF,0.1}}
fg_colour1 - colour table for foreground,
default = {{0,0x00FF00,0.1},{0.5,0x00FF00,1},{1,0x00FF00,0.1}}
bd_colour1 - colour table for border,
default = {{0,0xFFFF00,0.5},{0.5,0xFFFF00,1},{1,0xFFFF00,0.5}}
Seconds tables for radials gradients :
bg_colour2 - second colour table for background, default = no second colour
fg_colour2 - second colour table for foreground, default = no second colour
bd_colour2 - second colour table for border, default = no second colour
v1.0 (08 Aug. 2010) original release
]]
require 'cairo'
function conky_main_rings()
-- START PARAMETERS HERE
rings_settings={
{
--Ring 1 :hours
name="time",
arg="%I",
max=12,
xc=52,
yc=52,
radius=45,
thickness=6,
sectors=12,
gap_sectors=1,
fill_sector=true,
bg_colour1={{0,0x6ED6FF,0.05},{0.5,0x6ED6FF,0.05}, {1,0x6ED6FF,0.05}},
fg_colour1={{0,0x6ED6FF,0.5},{0.5,0x6ED6FF,0.6}, {1,0x6ED6FF,0.7}},
bd_colour1={{0,0X000000,0},{0.5,0x000000,0}, {1,0x000000,0}},
},
{
--Ring 1 :minutes
name="time",
arg="%M",
max=60,
xc=52,
yc=52,
radius=52,
thickness=6,
sectors=60,
gap_sectors=0,
fill_sector=true,
bg_colour1={{0,0x6ED6FF,0.05},{0.5,0x6ED6FF,0.05}, {1,0x6ED6FF,0.05}},
fg_colour1={{0,0x6ED6FF,0.5},{0.5,0x6ED6FF,0.4}, {1,0x6ED6FF,0.3}},
bd_colour1={{0,0X000000,0},{0.5,0x000000,0}, {1,0x000000,0}},
},
}
--END OF PARAMETERS HERE
--main function
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)
if tonumber(conky_parse('${updates}'))>3 then
for i in pairs(rings_settings) do
draw_ring(rings_settings[i])
end
end
cairo_destroy(cr)
end
function draw_ring(t)
local function rgba_to_r_g_b_a(tcolour)
colour,alpha=tcolour[2],tcolour[3]
return ((colour / 0x10000) % 0x100) / 255.,
((colour / 0x100) % 0x100) / 255., (colour % 0x100) / 255., alpha
end
local function calc_delta(tcol1,tcol2)
--calculate deltas P R G B A to table_colour 1
for x = 1, #tcol1 do
tcol1[x].dA = 0
tcol1[x].dP = 0
tcol1[x].dR = 0
tcol1[x].dG = 0
tcol1[x].dB = 0
if tcol2~=nil and #tcol1 == #tcol2 then
local r1,g1,b1,a1 = rgba_to_r_g_b_a(tcol1[x])
local r2,g2,b2,a2 = rgba_to_r_g_b_a(tcol2[x])
tcol1[x].dP = (tcol2[x][1]-tcol1[x][1])/t.sectors
tcol1[x].dR = (r2-r1)/t.sectors
tcol1[x].dG = (g2-g1)/t.sectors
tcol1[x].dB = (b2-b1)/t.sectors
tcol1[x].dA = (a2-a1)/t.sectors
end
end
return tcol1
end
--check values
local function setup(t)
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'")
print ("for name=" .. t.name)
print ("with arg=" .. t.arg)
return
end
if t.name==nil then t.name="" end
if t.arg==nil then t.arg="" end
if t.xc==nil then t.xc=conky_window.width/2 end
if t.yc==nil then t.yc=conky_window.height/2 end
if t.thickness ==nil then t.thickness = 10 end
if t.radius ==nil then t.radius =conky_window.width/4 end
if t.start_angle==nil then t.start_angle =0 end
if t.end_angle==nil then t.end_angle=360 end
if t.bg_colour1==nil then
t.bg_colour1={{0,0x00ffff,0.1},{0.5,0x00FFFF,0.5},{1,0x00FFFF,0.1}}
end
if t.fg_colour1==nil then
t.fg_colour1={{0,0x00FF00,0.1},{0.5,0x00FF00,1},{1,0x00FF00,0.1}}
end
if t.bd_colour1==nil then
t.bd_colour1={{0,0xFFFF00,0.5},{0.5,0xFFFF00,1},{1,0xFFFF00,0.5}}
end
if t.sectors==nil then t.sectors=10 end
if t.gap_sectors==nil then t.gap_sectors=1 end
if t.fill_sector==nil then t.fill_sector=false end
if t.sectors==1 then t.fill_sector=false end
if t.border_size==nil then t.border_size=0 end
if t.cap==nil then t.cap="p" end
--some checks
if t.thickness>t.radius then t.thickness=t.radius*0.1 end
t.int_radius = t.radius-t.thickness
--check colors tables
for i=1, #t.bg_colour1 do
if #t.bg_colour1[i]~=3 then t.bg_colour1[i]={1,0xFFFFFF,0.5} end
end
for i=1, #t.fg_colour1 do
if #t.fg_colour1[i]~=3 then t.fg_colour1[i]={1,0xFF0000,1} end
end
for i=1, #t.bd_colour1 do
if #t.bd_colour1[i]~=3 then t.bd_colour1[i]={1,0xFFFF00,1} end
end
if t.bg_colour2~=nil then
for i=1, #t.bg_colour2 do
if #t.bg_colour2[i]~=3 then t.bg_colour2[i]={1,0xFFFFFF,0.5} end
end
end
if t.fg_colour2~=nil then
for i=1, #t.fg_colour2 do
if #t.fg_colour2[i]~=3 then t.fg_colour2[i]={1,0xFF0000,1} end
end
end
if t.bd_colour2~=nil then
for i=1, #t.bd_colour2 do
if #t.bd_colour2[i]~=3 then t.bd_colour2[i]={1,0xFFFF00,1} end
end
end
if t.start_angle>=t.end_angle then
local tmp_angle=t.end_angle
t.end_angle= t.start_angle
t.start_angle = tmp_angle
-- print ("inversed angles")
if t.end_angle-t.start_angle>360 and t.start_angle>0 then
t.end_angle=360+t.start_angle
print ("reduce angles")
end
if t.end_angle+t.start_angle>360 and t.start_angle<=0 then
t.end_angle=360+t.start_angle
print ("reduce angles")
end
if t.int_radius<0 then t.int_radius =0 end
if t.int_radius>t.radius then
local tmp_radius=t.radius
t.radius=t.int_radius
t.int_radius=tmp_radius
print ("inversed radius")
end
if t.int_radius==t.radius then
t.int_radius=0
print ("int radius set to 0")
end
end
t.fg_colour1 = calc_delta(t.fg_colour1,t.fg_colour2)
t.bg_colour1 = calc_delta(t.bg_colour1,t.bg_colour2)
t.bd_colour1 = calc_delta(t.bd_colour1,t.bd_colour2)
end
--initialize table
setup(t)
--[[grid
h=conky_window.height
w=conky_window.width
cairo_set_source_rgba(cr,1,1,1,1)
cairo_set_line_width(cr,0.5)
cairo_move_to(cr,0,t.yc)
cairo_line_to(cr,w,t.yc)
cairo_stroke(cr)
cairo_move_to(cr,t.xc,0)
cairo_line_to(cr,t.xc,h)
cairo_stroke(cr)
cairo_move_to(cr,t.xc,t.yc)
cairo_line_to(cr,t.xc+200*math.sin(math.pi/4),t.yc-200*math.cos(math.pi/4))
cairo_stroke(cr)
cairo_move_to(cr,0,t.yc-t.radius)
cairo_line_to(cr,w,t.yc-t.radius)
cairo_stroke(cr)
cairo_move_to(cr,0,t.yc-t.int_radius)
cairo_line_to(cr,w,t.yc-t.int_radius)
cairo_stroke(cr)
cairo_move_to(cr,0,t.yc-t.gap_sectors)
cairo_line_to(cr,w,t.yc-t.gap_sectors)
cairo_stroke(cr)
cairo_set_source_rgba(cr,1,0,0,0.5)
cairo_arc(cr,t.xc,t.yc,t.radius,0,2*math.pi)
cairo_stroke(cr)
cairo_arc(cr,t.xc,t.yc,t.int_radius,0,2*math.pi)
cairo_stroke(cr)
cairo_set_source_rgba(cr,0,1,0,1)
cairo_move_to(cr,t.xc+t.gap_sectors,t.yc-t.gap_sectors)
cairo_line_to(cr,t.xc+400*math.sin(math.pi/4),t.yc-400*math.cos(math.pi/4))
cairo_stroke(cr)
--END GRID
]]
--initialize cairo context
cairo_save(cr)
cairo_translate(cr,t.xc,t.yc)
cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND)
cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND)
--get value
local value = 0
if t.name ~="" then
value = tonumber(conky_parse(string.format('${%s %s}', t.name, t.arg)))
else
value = tonumber(t.arg)
end
if value==nil then value =0 end
--initialize sectors
--angle of a sector :
angleA = ((t.end_angle-t.start_angle)/t.sectors)*math.pi/180
--value of a sector :
valueA = t.max/t.sectors
--first angle of a sector :
lastAngle = t.start_angle*math.pi/180
local function draw_sector(type_arc,angle0,angle,valpc, idx)
--this function draws a portion of arc
--type of arc, angle0 = strating angle, angle= angle of sector,
--valpc = percentage inside the sector, idx = sctor number #
if type_arc=="bg" then --background
if valpc==1 then return end
tcolor=t.bg_colour1
elseif type_arc=="fg" then --foreground
if valpc==0 then return end
tcolor=t.fg_colour1
elseif type_arc=="bd" then --border
tcolor=t.bd_colour1
end
--angles equivalents to gap_sector
local ext_delta=math.atan(t.gap_sectors/(2*t.radius))
local int_delta=math.atan(t.gap_sectors/(2*t.int_radius))
--angles of arcs
local ext_angle=(angle-ext_delta*2)*valpc
local int_angle=(angle-int_delta*2)*valpc
--define colours to use for this sector
if #tcolor==1 then
--plain color
local vR,vG,vB,vA = rgba_to_r_g_b_a(tcolor[1])
cairo_set_source_rgba(cr,vR+tcolor[1].dR*idx,
vG+tcolor[1].dG*idx,
vB+tcolor[1].dB*idx,
vA+tcolor[1].dA*idx )
else
--radient color
local pat=cairo_pattern_create_radial(0,0,t.int_radius,0,0,t.radius)
for i=1, #tcolor do
local vP,vR,vG,vB,vA = tcolor[i][1], rgba_to_r_g_b_a(tcolor[i])
cairo_pattern_add_color_stop_rgba (pat,
vP+tcolor[i].dP*idx,
vR+tcolor[i].dR*idx,
vG+tcolor[i].dG*idx,
vB+tcolor[i].dB*idx,
vA+tcolor[i].dA*idx )
end
cairo_set_source (cr, pat)
cairo_pattern_destroy(pat)
end
--start drawing
cairo_save(cr)
--x axis is parrallel to start of sector
cairo_rotate(cr,angle0-math.pi/2)
local ri,re = t.int_radius ,t.radius
--point A
local angle_a
if t.cap == "p" then
angle_a = int_delta
if t.inverse_arc and type_arc ~="bg" then
angle_a = angle-int_angle-int_delta
end
if not(t.inverse_arc) and type_arc =="bg" then
angle_a = int_delta+int_angle
end
else --t.cap=="r"
angle_a = ext_delta
if t.inverse_arc and type_arc~="bg" then
angle_a = angle-ext_angle-ext_delta
end
if not(t.inverse_arc) and type_arc=="bg" then
angle_a = ext_delta+ext_angle
end
end
local ax,ay = ri*math.cos(angle_a),ri*math.sin(angle_a)
--point B
local angle_b = ext_delta
if t.cap == "p" then
if t.inverse_arc and type_arc ~="bg" then
angle_b = angle-ext_angle-ext_delta
end
if not(t.inverse_arc) and type_arc=="bg" then
angle_b = ext_delta+ext_angle
end
else
if t.inverse_arc and type_arc ~="bg" then
angle_b = angle-ext_angle-ext_delta
end
if not(t.inverse_arc) and type_arc=="bg" then
angle_b = ext_delta+ext_angle
end
end
local bx,by = re*math.cos(angle_b),re*math.sin(angle_b)
-- EXTERNAL ARC B --> C
if t.inverse_arc then
if type_arc=="bg" then
b0,b1= ext_delta, angle-ext_delta-ext_angle
else
b0,b1= angle-ext_angle-ext_delta, angle-ext_delta
end
else
if type_arc=="bg" then
b0,b1= ext_delta+ext_angle, angle-ext_delta
else
b0,b1= ext_delta, ext_angle+ext_delta
end
end
---POINT D
local angle_c
if t.cap == "p" then
angle_d = angle-int_delta
if t.inverse_arc and type_arc=="bg" then
angle_d = angle-int_delta-int_angle
end
if not(t.inverse_arc) and type_arc~="bg" then
angle_d=int_delta+int_angle
end
else
angle_d = angle-ext_delta
if t.inverse_arc and type_arc=="bg" then
angle_d =angle-ext_delta-ext_angle
end
if not(t.inverse_arc) and type_arc~="bg" then
angle_d = ext_angle+ext_delta
end
end
local dx,dy = ri*math.cos(angle_d),ri*math.sin(angle_d)
-- INTERNAL ARC D --> A
if t.cap=="p" then
if t.inverse_arc then
if type_arc=="bg" then
d0,d1= angle-int_delta-int_angle,int_delta
else
d0,d1= angle-int_delta, angle- int_angle-int_delta
end
else
if type_arc=="bg" then
d0,d1= angle-int_delta, int_delta+int_angle
else
d0,d1= int_delta+int_angle, int_delta
end
end
else
if t.inverse_arc then
if type_arc=="bg" then
d0,d1= angle-ext_delta-ext_angle,ext_delta
else
d0,d1= angle-ext_delta, angle- ext_angle-ext_delta
end
else
if type_arc=="bg" then
d0,d1= angle-ext_delta,ext_delta+ext_angle
else
d0,d1= ext_angle+ext_delta, ext_delta
end
end
end
--draw sector
cairo_move_to(cr,ax,ay)
cairo_line_to(cr,bx,by)
cairo_arc(cr,0,0,re,b0,b1)
cairo_line_to(cr,dx,dy)
cairo_arc_negative(cr,0,0,ri,d0,d1)
cairo_close_path (cr);
--stroke or fill sector
if type_arc=="bd" then
cairo_set_line_width(cr,t.border_size)
cairo_stroke(cr)
else
cairo_fill(cr)
end
cairo_restore(cr)
end
--draw sectors
local n0,n1,n2 = 1,t.sectors,1
if t.inverse_arc then n0,n1,n2 = t.sectors,1,-1 end
local index = 0
for i = n0,n1,n2 do
index = index +1
local valueZ=1
local cstA, cstB = (i-1),i
if t.inverse_arc then cstA,cstB = (t.sectors-i), (t.sectors-i+1) end
if value>valueA *cstA and value<valueA*cstB then
if not t.fill_sector then
valueZ = (value-valueA*cstA)/valueA
end
else
if value<valueA*cstB then valueZ=0 end
end
local start_angle= lastAngle+(i-1)*angleA
if t.foreground ~= false then
draw_sector("fg",start_angle,angleA,valueZ, index)
end
if t.background ~= false then
draw_sector("bg",start_angle,angleA,valueZ, i)
end
if t.border_size>0 then draw_sector("bd",start_angle,angleA,1, i) end
end
cairo_restore(cr)
end
--[[END OF RING-SECTORS WIDGET]]
function axis(ctx,alpha)
cairo_set_line_width(ctx,1)
cairo_set_source_rgba(ctx,1,0,0,alpha)
cairo_move_to(ctx,0,0)
cairo_line_to(ctx,150,0)
cairo_stroke(ctx)
cairo_set_source_rgba(ctx,0,1,0,alpha)
cairo_move_to(ctx,0,0)
cairo_line_to(ctx,0,150)
cairo_stroke(ctx)
end
There, checked it myself, although I could've missed something (...again).
Hope this works!
Last edited by Zom (2011-01-25 18:35:58)
Offline
Oh yeah, this one works!
Offline
I was up until around 5:30 AM tinkering with this. Once I got going I couldn't stop. The idea hit me, and it had to be done:
background yes
use_xft yes
xftfont sans:size=8
xftalpha 0.8
override_utf8_locale yes
update_interval 2
own_window no
double_buffer yes
draw_shades no
stippled_borders no
#border_margin 0
border_width 0
default_color 03fef9
color0 00CD00
color1 00c3d0
default_shade_color black
alignment top_left
minimum_size 1920
gap_x 0
gap_y 0
no_buffers yes
##uppercase yes
short_units yes
pad_percents 2
text_buffer_size 1024
imlib_cache_size 0
##
##
TEXT
${GOTO 105}${if_mpd_playing}${mpd_artist} - ${mpd_title} - ${mpd_album}${endif}
${GOTO 105}${if_mpd_playing}${color1}${mpd_bar 5,170}${color}${endif}
${GOTO 105}${if_mpd_playing}${mpd_status}${GOTO 165}${mpd_elapsed}${GOTO 200}/${GOTO 215}${mpd_length}${endif}
${if_mpd_playing}${execi 5 /home/beelzebud/.conky-mpd}${image /tmp/mpd.jpg -s 100x100 -p 0,0}${endif}
${voffset 78}${GOTO 1390}CPU 1: ${color1}${cpu cpu0}% ${GOTO 1450}$running_processes/$processes${GOTO 1488}${cpubar cpu0 6,50}${color}
${GOTO 1390}CPU 2: ${color1}${cpu cpu1}% ${GOTO 1450}$running_processes/$processes${GOTO 1488}${cpubar cpu1 6,50}${color}
${GOTO 1390}CPU 3: ${color1}${cpu cpu2}% ${GOTO 1450}$running_processes/$processes${GOTO 1488}${cpubar cpu2 6,50}${color}
${GOTO 1390}CPU 4: ${color1}${cpu cpu3}% ${GOTO 1450}$running_processes/$processes${GOTO 1488}${cpubar cpu3 6,50}${color}
${voffset -2}${GOTO 435}RAM: ${color1}${memperc}% ${membar 6,50}${color}
${GOTO 435}SWAP: ${color1}${swapbar 6,70}${color}
${GOTO 435}Uptime: ${color1}$uptime_short${color}
${voffset 237}${GOTO 380}SDA: ${color1}${diskiograph sda 6,50}${color}
${GOTO 380}SDB: ${color1}${diskiograph sdb 6,50}${color}
${GOTO 380}/home: ${color1}${fs_free /home}${color}
${GOTO 380}/sys: ${color1}${fs_free /}${color}
${voffset 154}${GOTO 1375}Up: ${color1}${totalup eth0} ${upspeedgraph eth0 6,75} ${upspeed eth0}${color}
${GOTO 1375}Down: ${color1}${totaldown eth0} ${downspeedgraph eth0 6,75} ${downspeed eth0}${color}
${GOTO 1375}IP: ${color1}${addr eth0}${color}
and the mpd script:
#! /usr/bin/env python2
import sys,mpd,os,socket
musiclocation = '/mnt/sdb1/Music' #location of music
artlocation = '~/.covers' #where you want albumart storing
tmp_path = '/tmp/mpd.jpg' #location for temporary file so conky can find it
musiclocation = os.path.expanduser(musiclocation)
artlocation = os.path.expanduser(artlocation)
client = mpd.MPDClient()
try:
client.connect("localhost", 6600)
except socket.error:
sys.exit(1)
song = client.currentsong()
artist = song['artist']
album = song['album']
covername = os.path.join( artlocation, artist+'-'+album+'.jpg')
covername = covername.replace(' ','_')
if covername == os.path.realpath(tmp_path): # already have correct album cover
sys.exit(0)
try:
os.remove(tmp_path)
except OSError: pass
if os.path.basename(covername) in os.listdir(artlocation):
os.symlink(covername, tmp_path)
else:
from urllib import FancyURLopener
class MyOpener(FancyURLopener): version = ''
try:
s = MyOpener().open('http://www.amazon.com/gp/search/keywords=%s+%s'%
(artist.replace(' ','+'),album.replace(' ','+'))).read()
import re
link = re.findall('http://ecx.images-amazon.com\S*.jpg',s)[0]
pic = MyOpener().open(link).read()
open(covername ,'w').write(pic)
os.symlink(covername, tmp_path)
except IOError:
pass
Basically this is Gnome, using Avant Window Navigator instead of gnome-panels. I use Compiz for the window decorator and composition. Lines were added to the image using Gimp. When no music is playing the mpd entries, and album art, disappear.
The only thing I'm not happy with is the mpd script. It isn't very reliable for fetching some of my music, so I had to add some album art to the directory by hand, which is kind of tedious. I'm not a python guy, so I'm not sure the correct way to edit it to point to a more music orientated site than amazon.com. However this was the only working script I could find that would actually fetch queries, and use the /tmp/mpd.jpg file. The problem with Amazon is that their selection of music doesn't really jive with what I listen to. Anyone have any ideas on how to improve this mpd script to fetch from a more music orientated album art site?
Last edited by Beelzebud (2011-01-27 20:58:35)
Offline
@Beezlebud: that is freaking sweet. Love it. Now just try and map locations for typical brain functions to corresponding computer characteristics and it will be anatomically correct! Very cool idea!
Offline
Any reason for using GOTO instead of offset?
I'm french, don't mind my mistakes in english.
Offline
Any reason for using GOTO instead of offset?
goto is absolute positioning, offset is relative to where the previous text is. For something that changes (like, cpu goes between one number and 3, 0-100, or ESSID) it can make the positions of other stuff wonky.
It's got nothing to do with the old programmer term GOTO, just FYI.
Offline
Yup, but I was really wondering, I've always used offset, and never saw it was relative to previous text.
I'm french, don't mind my mistakes in english.
Offline
Less guess-work. If I have the screen set to 1920, I have an idea of where 1500 will place the line. It's just easier for me to visualize where things will go. The offset command can be tricky. The hardest part of this config was getting the voffset values correct.
Offline
Less guess-work. If I have the screen set to 1920, I have an idea of where 1500 will place the line. It's just easier for me to visualize where things will go. The offset command can be tricky. The hardest part of this config was getting the voffset values correct.
It still depends on where you place the conky though. Goto only counts the pixels inside the conky, not the screen itself.
E: Playing around with http://u-scripts.blogspot.com/2011/01/b … et_27.html
Quite decent result, imo.
Last edited by Zom (2011-01-28 18:12:45)
Offline