Awesome find. ):P
It's getting harder and harder to answer some questions today as conky acts so differently on different systems.
Printable View
This actually took a few days to do, life kept getting in the way. So to relax, I worked on a conky.
On the left is the default conky that comes with 1d1_Accuweather_INT_Images, by TeoBigusGeekus, you'll need the script, on the right a new layout.
Both are set to use General Urquiza, CABA, Argentina.
http://t.imgbox.com/abxF0dOy.jpg
The conky:
Teo_Weather_Clock.lua - the 24 hour clock adapted for Teo's scripts.Code:# killall conky && conky -c /media/5/Conky/Accuweather/Teo_Clock_Gen_Urquiza_AccuW.conky &
#
# Thank you:
# Chronograph LUA - mrpeachy (originally 4 clocks - tweaked by Sector11)
# v9000 LUA weather - mrpeachy
# background - londonali1010, mrpeachy, dk75
# TeoBigusGeekus - for the weather scripts
### Begin Window Settings ##################################################
# Create own window instead of using desktop (required in nautilus)
own_window yes
own_window_type normal
own_window_transparent yes
own_window_hints undecorated,below,skip_taskbar,skip_pager
own_window_class Conky
own_window_title Teo Weather Clock General Urquiza
# Use the Xdbe extension? (eliminates flicker)
# It is highly recommended to use own window with this one
# so double buffer won't be so big.
double_buffer yes
### ARGB can be used for real transparency
### NOTE that a composite manager is required for real transparency.
### This option will not work as desired (in most cases) in conjunction with
### own_window_type normal
# own_window_argb_visual yes
### When ARGB visuals are enabled, this use this to modify the alpha value
### Use: own_window_type normal
### Use: own_window_transparent no
### Valid range is 0-255, where 0 is 0% opacity, and 255 is 100% opacity.
# own_window_argb_value 0
#minimum_size 420 420 ## width, height
#maximum_width 420 ## width
### For use with The-Clock.lua
minimum_size 300 0 ## width, height
maximum_width 300 ## width
gap_x 10 #15 ### left &right
gap_y 10 ### up & down
### alignment values or top_left, bottom_right, etc
# tl, tm, tr
# ml, mm, mr
# bl, bm, br
alignment top_right
#################################################### End Window Settings ###
### Font Settings ##########################################################
# Use Xft (anti-aliased font and stuff)
use_xft yes
#xftfont CorporateMonoExtraBold:size=9
xftfont monofur:bold:size=11
# X font when Xft is disabled, you can pick one with program xfontsel
#font 5x7
#font 6x10
#font 7x13
#font 8x13
#font 9x15
#font *mintsmild.se*
#font -*-*-*-*-*-*-34-*-*-*-*-*-*-*
# Alpha of Xft font. Must be a value at or between 1 and 0 ###
xftalpha 1
# Force UTF8? requires XFT ###
override_utf8_locale yes
uppercase no
###################################################### End Font Settings ###
### Color Settings #########################################################
draw_shades no
default_shade_color black
draw_outline no # amplifies text if yes
default_outline_color black
default_color DCDCDC #220 220 220 Gainsboro
color0 8FBC8F #143 188 143 DarkSeaGreen
#color1 C2CCFF # Not a clue - a blue #778899 #119 136 153 LightSlateGray
color1 AFEEEE #175 238 238 PaleTurquoise
color2 FF8C00 #255 140 0 DarkOrange
color3 7FFF00 #127 255 0 Chartreuse
color4 FFA07A #255 160 122 LightSalmon
color5 FFDEAD #255 222 173 NavajoWhite
color6 00BFFF # 0 191 255 DeepSkyBlue
color7 00FFFF # 0 255 255 Cyan
color8 FFFF00 #255 255 0 Yellow
color9 B22222 #178 34 34 FireBrick
##################################################### End Color Settings ###
### Borders Section ########################################################
draw_borders no
# Stippled borders?
stippled_borders 0
# border margins
border_inner_margin 5
border_outer_margin 0
# border width
border_width 0
# graph borders
draw_graph_borders yes #no
#default_graph_size 15 40
##################################################### End Borders Secton ###
### Miscellaneous Section ##################################################
# Boolean value, if true, Conky will be forked to background when started.
background yes
# Adds spaces around certain objects to stop them from moving other things
# around, this only helps if you are using a mono font
# Options: right, left or none
use_spacer none
# Default and Minimum size is 256 - needs more for single commands that
# "call" a lot of text IE: bash scripts
text_buffer_size 256
# Subtract (file system) buffers from used memory?
no_buffers yes
# change GiB to G and MiB to M
short_units yes
# Like it says, ot pads the decimals on % values
# doesn't seem to work since v1.7.1
pad_percents 2
# If enabled, values which are in bytes will be printed in human readable
# format (i.e., KiB, MiB, etc). If disabled, bytes is printed instead
format_human_readable yes
# Shortens units to a single character (kiB->k, GiB->G, etc.). Default is off.
short_units yes
imlib_cache_size 0
# Maximum size of user text buffer, i.e. layout below TEXT line in config file
# (default is 16384 bytes)
# max_user_text 16384
# Desired output unit of all objects displaying a temperature. Parameters are
# either "fahrenheit" or "celsius". The default unit is degree Celsius.
# temperature_unit Fahrenheit
## default bar size
default_bar_size 200 20
############################################## End Miscellaneous Section ###
### LUA Settings ###########################################################
## draw-bg.lua - Above and After TEXT - requires a composite manager.
##
lua_load /media/5/Conky/LUA/draw-bg.lua
#TEXT
# ${lua conky_draw_bg 125 0 0 0 0 0x000000 0.3}
#
# ----------------------------------------------------------------------------
## OR Both above TEXT - No composite manager required.
#
#lua_load ~/Conky_WeatherCom_metric/LUA/draw-bg.lua
#lua_draw_hook_pre draw_bg 20 0 0 0 0 0x000000 0.3
#
# TEXT
### Teo Weather Clock ########################################################
lua_load /media/5/Conky/LUA/Teo_Weather_Clock.lua
lua_draw_hook_post main
############################## End LUA Settings ###
# The all important - How often conky refreshes.
# If you have a "Crey" try: 0.2 - smokin' - but watch the CPU useage go UP!
update_interval 1
TEXT
${lua conky_draw_bg 10 0 0 0 0 0x000000 0.4}\
${lua conky_draw_bg 123 30 30 246 246 0xffffff 0.2}\
${texeci 500 bash /media/5/Conky/Accuweather/acc_int_images}\
${font monofur:size=24}${color7}${execi 600 sed -n '29p' /media/5/Conky/Accuweather/curr_cond}°${alignr}${color5}${execi 600 sed -n '30p' /media/5/Conky/Accuweather/curr_cond}°${font}
${color7}Temp${alignr 15}${color5}±${font}
${image /media/5/Conky/Accuweather/cc.png -p 102,120 -s 90x54}
${color}Today${alignr}${color1}Tonight${color}
${color5}↑ ${color2}${execi 600 sed -n '26p' /media/5/Conky/Accuweather/first_days}°${alignr}${color5}↓ ${color7}${execi 600 sed -n '31p' /media/5/Conky/Accuweather/first_days}°
${image /media/5/Conky/Accuweather/tod.png -p 0,280 -s 120x72}${image /media/5/Conky/Accuweather/ton.png -p 180,280 -s 120x72}
${color5}± ${execi 600 sed -n '27p' /media/5/Conky/Accuweather/first_days}°${alignr}± ${execi 600 sed -n '32p' /media/5/Conky/Accuweather/first_days}°
${goto 60} ${color5}SUN${goto 100}${color}↑ ${execi 600 sed -n '39p' /media/5/Conky/Accuweather/curr_cond}${goto 180}${color1}↓ ${execi 600 sed -n '40p' /media/5/Conky/Accuweather/curr_cond}
${goto 60}${color5}MOON ${goto 100}${color}↑ ${execi 600 sed -n '41p' /media/5/Conky/Accuweather/curr_cond}${goto 180}${color1}↓ ${color1}${execi 600 sed -n '42p' /media/5/Conky/Accuweather/curr_cond}
${color5}Humidity ${color7}${execi 600 sed -n '33p' /media/5/Conky/Accuweather/curr_cond}${alignr 5}${color5}Dew Point ${color7}${execi 600 sed -n '37p' /media/5/Conky/Accuweather/curr_cond}°${color}
${color5}Pressure ${color7}${execi 600 sed -n '34p' /media/5/Conky/Accuweather/curr_cond}${alignr 5}${color5}UV Index ${color7}${execi 600 sed -n '36p' /media/5/Conky/Accuweather/curr_cond}
${color5}Wind ${color7}${execi 600 sed -n '31p' /media/5/Conky/Accuweather/curr_cond} ${execi 600 sed -n '32p' /media/5/Conky/Accuweather/curr_cond}\
${alignr 5}${color5}Cloud Cover ${color7}${execi 600 sed -n '35p' /media/5/Conky/Accuweather/curr_cond}
${alignc}${color5}Visibility ${color7}${execi 600 sed -n '38p' /media/5/Conky/Accuweather/curr_cond}
${color1}${stippled_hr 5 1}
${color5}${execi 600 sed -n '5p' /media/5/Conky/Accuweather/first_days}${goto 113}${execi 600 sed -n '10p' /media/5/Conky/Accuweather/first_days}${goto 217}${execi 600 sed -n '15p' /media/5/Conky/Accuweather/first_days}
${image /media/5/Conky/Accuweather/6.png -p 0,475 -s 90x54}${image /media/5/Conky/Accuweather/11.png -p 110,475 -s 90x54}${image /media/5/Conky/Accuweather/16.png -p 210,475 -s 90x54}
↑ ${color2}${execi 600 sed -n '8p' /media/5/Conky/Accuweather/first_days}${goto 55}${color5}↓ ${color1}${execi 600 sed -n '9p' /media/5/Conky/Accuweather/first_days}\
${goto 111}↑ ${color2}${execi 600 sed -n '13p' /media/5/Conky/Accuweather/first_days}${goto 160}${color5}↓ ${color1}${execi 600 sed -n '14p' /media/5/Conky/Accuweather/first_days}\
${goto 215}↑ ${color2}${execi 600 sed -n '18p' /media/5/Conky/Accuweather/first_days}${goto 264}${color5}↓ ${color1}${execi 600 sed -n '19p' /media/5/Conky/Accuweather/first_days}
${color5}${execi 600 sed -n '20p' /media/5/Conky/Accuweather/first_days}${goto 113}${execi 600 sed -n '1p' /media/5/Conky/Accuweather/last_days}${goto 217}${execi 600 sed -n '6p' /media/5/Conky/Accuweather/last_days}
${image /media/5/Conky/Accuweather/21.png -p 0,565 -s 90x54}${image /media/5/Conky/Accuweather/last_2.png -p 106,565 -s 90x54}${image /media/5/Conky/Accuweather/last_7.png -p 210,565 -s 90x54}
↑ ${color2}${execi 600 sed -n '23p' /media/5/Conky/Accuweather/first_days}${goto 55}${color5}↓ ${color1}${execi 600 sed -n '24p' /media/5/Conky/Accuweather/first_days}\
${goto 111}↑ ${color2}${execi 600 sed -n '4p' /media/5/Conky/Accuweather/last_days}${goto 160}${color5}↓ ${color1}${execi 600 sed -n '5p' /media/5/Conky/Accuweather/last_days}\
${goto 215}↑ ${color2}${execi 600 sed -n '9p' /media/5/Conky/Accuweather/last_days}${goto 264}${color5}↓ ${color1}${execi 600 sed -n '10p' /media/5/Conky/Accuweather/last_days}
${color5}${execi 600 sed -n '11p' /media/5/Conky/Accuweather/last_days}${goto 113}${execi 600 sed -n '16p' /media/5/Conky/Accuweather/last_days}${goto 217}${execi 600 sed -n '21p' /media/5/Conky/Accuweather/last_days}
${image /media/5/Conky/Accuweather/last_12.png -p 0,655 -s 90x54}${image /media/5/Conky/Accuweather/last_17.png -p 106,655 -s 90x54}${image /media/5/Conky/Accuweather/last_22.png -p 210,655 -s 90x54}
↑ ${color2}${execi 600 sed -n '14p' /media/5/Conky/Accuweather/last_days}${goto 55}${color5}↓ ${color1}${execi 600 sed -n '15p' /media/5/Conky/Accuweather/last_days}\
${goto 111}↑ ${color2}${execi 600 sed -n '19p' /media/5/Conky/Accuweather/last_days}${goto 160}${color5}↓ ${color1}${execi 600 sed -n '20p' /media/5/Conky/Accuweather/last_days}\
${goto 215}↑ ${color2}${execi 600 sed -n '24p' /media/5/Conky/Accuweather/last_days}${goto 264}${color5}↓ ${color1}${execi 600 sed -n '25p' /media/5/Conky/Accuweather/last_days}
${color1}${stippled_hr 5 1}
${color3}With ${color}${nodename} ${color3}for the past: ${color}${uptime_short}
${color3}Kernel: ${color}${kernel}
${color3}CPU ${color7}1: ${color}${if_match ${cpu cpu1}<10} ${cpu cpu1}\
${else}${if_match ${cpu cpu1}<100} ${cpu cpu1}\
${else}${cpu cpu1}\
${endif}${endif} %\
${color7}2: ${color}${if_match ${cpu cpu2}<10} ${cpu cpu2}\
${else}${if_match ${cpu cpu2}<100} ${cpu cpu2}\
${else}${cpu cpu2}\
${endif}${endif} %\
${color7}3: ${color}${if_match ${cpu cpu3}<10} ${cpu cpu3}\
${else}${if_match ${cpu cpu3}<100} ${cpu cpu3}\
${else}${cpu cpu3}\
${endif}${endif} %\
${color7}Avg: ${color}${if_match ${cpu cpu0}<10} ${cpu cpu0}\
${else}${if_match ${cpu cpu0}<100} ${cpu cpu0}\
${else}${cpu cpu0}\
${endif}${endif} %
${color3}CPU: ${color}${platform f71882fg.2560 temp 1}°${goto 90}${color3}SDA: ${color}${execi 15 hddtemp -n /dev/sda}°${goto 167}${color3}GPU: ${color}${nvidia temp}°${goto 245}${color3}MB: ${color}${platform f71882fg.2560 temp 2}°
${color3}RAM: ${color}${mem} / ${memmax} / ${memperc}% ${alignr 5}${color3}Swap: ${color}${swap} ${color}/ ${color}${swapmax}
${color3}eth-0 ${color7}Down: ${color}${downspeedf eth0}${goto 200}${color7}Up: ${color}${upspeedf eth0}
${color1}${stippled_hr 5 1}
draw-bg.luaCode:--[[ multiple analogue clocks by mrpeachy - 18 Jun 2012
21 Jun 2012 - Chronograph modifications by Sector11
22 Jun 2012 - again with mrpeachy's help day names, numbers and month names
12 Nov 2012 - memory leak plugged - mrpeachy
14 Nov 2012 - Personnalisation - Didier-T (forum Ubuntu.fr)
26 Nov 2012 - The Clock - Sector11 (small version)
use in conkyrc
lua_load /path/Chronograph.lua
lua_draw_hook_pre main
TEXT
-- INDEX use search|find with: -- ### sonething ###
-- ### CLOCK POSITION - AND DEFAULTS ###
-- ### SET BORDER OPTIONS FOR "CLOCKS" ### -- I don't know how to remove this - NOT NEEDED
-- See lines 39 to 41 for overall size changes
-- ### START DIAL B ### Day Names Dial ###
-- See Lines 77 - 79 and 145 for changes
-- ### START DIAL C ### Month Names Dial ###
-- See Lines 143 -145 and 192 for changes
-- ### START DIAL D ### Day Numbers Dial ###
-- See Lines 226 & 257 for changes
-- ### START CLOCK A ###
-- See Lines & and 456 & 483 changes
-- MARKS AROUND CLOCK A -- Large Main 24 HR Clock
-- CLOCK A HOUR HAND
-- CLOCK A MINUTE HAND SETUP
-- CLOCK A SECOND HAND SETUP
-- PART SECOND HAND Lines: 503 519, 531
NOTE: Putting ### CLOCK A ### last insures that it's functions are written
over the other dials.
]]
require 'cairo'
-- ### CLOCK POSITION - AND DEFAULTS ##########################################
local init={
center_x=153, --from 135 = +40
center_y=153, --from 135
radius=140,
lang="English", -- English French Greek Spanish
hour=24, -- 12 | 24
second=true, --true | false - Seconds: dots and numbers IF 12HR
line=true, -- true | false - Part Second Hand
handday=false, -- DAY NAME hand - true or false
--handdaynum=false, -- DAY NUMBER hand - true or false
handmonth=false, -- MONTH NAME hand - true or false
color=0xFF0000, --color for day, day number and month IF NO SECOND HAND
alpha=1 --alpha for day, day number and month IF NO SECOND HAND
}
-- ONLY NEED ONE COPY OF THIS FUNCTION
function rgb_to_r_g_b(col,alp)
return ((col / 0x10000) % 0x100) / 255, ((col / 0x100) % 0x100) / 255, (col % 0x100) / 255, alp
end
local colr, colg, colb, cola=rgb_to_r_g_b(init.color,init.alpha)
function conky_main()
if conky_window == nil then return end
local cs = cairo_xlib_surface_create(conky_window.display, conky_window.drawable, conky_window.visual, conky_window.width, conky_window.height)
cr = cairo_create(cs)
local extents=cairo_text_extents_t:create()
tolua.takeownership(extents)
-- ### CLOCK 12|24 HR SELECTOR ############################
local clock_type_A=init.hour
-- ############################ CLOCK 12|24 HR SELECTOR ###
-- ### SET BORDER OPTIONS FOR "CLOCKS" ####################
--local clock_border_width=0
-- set color and alpha for clock border
--local cbr,cbg,cbb,cba=1,1,1,1 -- full opaque white
-- gap from clock border to minute marks
local b_to_m=0
-- #################### SET BORDER OPTIONS FOR "CLOCKS" ###
-- ### START DIAL B ### Day Names Dial ####################
-- DIAL POSITION
local center_x=init.center_x
local center_y=init.center_y
local radius=42
-- FONT
cairo_select_font_face (cr, "monofur", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cr, 14)
-- TABLE OF TEXT -- in order
if init.lang == "English" then text_days={"Sun","Mon","Tue","Wed","Thr","Fri","Sat",} end
if init.lang == "French" then text_days={"dim","lun","mar","mer","jeu","ven","sam",} end
if init.lang == "Greek" then text_days={"ΔΕΥ","ΤΡΙ","ΤΕΤ","ΠΕΜ","ΠΑΡ","ΣΑΒ","ΚΥΡ",} end
if init.lang == "Spanish" then text_days={"dom","lun","mar","mie","jue","vie","sab",} end
local day_number=tonumber(os.date("%w"))
if init.handday == true then
for i=1,7 do
-- work out points
local point=(math.pi/180)*((360/7)*(i-1))
local x=0+radius*(math.sin(point))
local y=0-radius*(math.cos(point))
-- CALCULATE CENTRE OF TEXT
local text=text_days[i]--gets text from table
cairo_text_extents(cr,text,extents)
local width=extents.width
local height=extents.height
cairo_move_to(cr,center_x+x-(width/2),center_y+y+(height/2))
cairo_show_text (cr, text)
cairo_stroke (cr)
end
else
for i=1,7 do -- working out points
if day_number == i-1 then
cairo_set_source_rgba (cr,0,1,1,1) -- active colour
else
cairo_set_source_rgba (cr,1,1,1,0.07) -- non-active day names
end
local point=(math.pi/180)*((360/7)*(i-1))
local x=0+radius*(math.sin(point))
local y=0-radius*(math.cos(point))
-- CALCULATE CENTRE OF TEXT
local text=text_days[i]--gets text from table
cairo_text_extents(cr,text,extents)
local width=extents.width
local height=extents.height
cairo_move_to(cr,center_x+x-(width/2),center_y+y+(height/2))
cairo_show_text (cr, text)
cairo_stroke (cr)
end
-- INNER POINTS POSITION, radius smaller than text circle
local radius=27
for i=1,7 do
if day_number == i-1 then
cairo_set_source_rgba (cr,0,1,1,1) -- active colour
else
cairo_set_source_rgba (cr,1,1,1,0.07) -- non-active
end
local point=(math.pi/180)*((360/7)*(i-1))
local x=0+radius*(math.sin(point))
local y=0-radius*(math.cos(point))
cairo_arc (cr,center_x+x,center_y+y,1,0,2*math.pi)
cairo_stroke (cr)
end
end
-- ######################################### END DIAL B ###
-- ### START DIAL C ### Month Names Dial ##################
-- DIAL POSITION
local center_x=init.center_x --(+85)
local center_y=init.center_y
local radius=73
-- FONT
cairo_select_font_face (cr, "monofur", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cr, 14)
-- TABLE OF TEXT -- in order
if init.lang == "English" then text_days={"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec",} end
if init.lang == "French" then text_days={"jan","fév","mar","avr","mai","jui","jul","aôu","sep","oct","nov","déc",} end
if init.lang == "Greek" then text_days={"ΙΑΝ","ΦΕΒ","ΜΑΡ","ΑΠΡ","ΜΑΙ","ΙΟΥ","ΙΟΥ","ΑΥΓ","ΣΕΠ","ΟΚΤ","ΝΟΕ","ΔΕΚ",} end
if init.lang == "Spanish" then text_days={"ene","feb","mar","abr","may","jun","jul","ago","sep","oct","nov","dic",} end
local this_month=tonumber(os.date("%m"))
if init.handmonth == true then
for i=1,12 do
-- OUTER POINTS POSTION FOR -- ### START DIAL C ## TEXT
local point=(math.pi/180)*((360/12)*(i-1))
local x=0+radius*(math.sin(point))
local y=0-radius*(math.cos(point))
-- CALCULATE CENTRE OF TEXT
local text=text_days[i]--gets text from table
cairo_text_extents(cr,text,extents)
local width=extents.width
local height=extents.height
cairo_move_to(cr,center_x+x-(width/2),center_y+y+(height/2))
cairo_show_text (cr, text)
cairo_stroke (cr)
end
else
for i=1,12 do
if this_month == i then
cairo_set_source_rgba (cr,0,1,1,1) -- active month colour
else
cairo_set_source_rgba (cr,1,1,1,0.07) -- non-active month names
end
-- OUTTER POINTS POSTION FOR TEXT
local point=(math.pi/180)*((360/12)*(i-1))
local x=0+radius*(math.sin(point))
local y=0-radius*(math.cos(point))
-- CALCULATE CENTRE OF TEXT
local text=text_days[i]--gets text from table
cairo_text_extents(cr,text,extents)
local width=extents.width
local height=extents.height
cairo_move_to(cr,center_x+x-(width/2),center_y+y+(height/2))
cairo_show_text (cr, text)
cairo_stroke (cr)
end
-- INNER POINTS POSITION, radius smaller than text circle
local radius=58
for i=1,12 do
if this_month == i then
cairo_set_source_rgba (cr,0,1,1,1) -- active colour
else
cairo_set_source_rgba (cr,1,1,1,0.07) -- non-active month names
end
local point=(math.pi/180)*((360/12)*(i-1))
local x=0+radius*(math.sin(point))
local y=0-radius*(math.cos(point))
cairo_arc (cr,center_x+x,center_y+y,1,0,2*math.pi)
cairo_stroke (cr)
end
end
-- ######################################### END DIAL C ###
-- ### START DIAL D ### Day Numbers Dial ##################
-- GET NUMBER OF DAYS IN CURRENT MONTH
-- calculate Feb, then set up table
year4num=os.date("%Y")
t1=os.time({year=year4num,month=03,day=01,hour=00,min=0,sec=0});
t2=os.time({year=year4num,month=02,day=01,hour=00,min=0,sec=0});
if init.hour == 12 then
febdaynum=tonumber((os.difftime(t1,t2))/(12*60*60))
else
febdaynum=tonumber((os.difftime(t1,t2))/(24*60*60))
end
-- MONTH TABLE to get number of days
monthdays={31,febdaynum,31,30,31,30,31,31,30,31,30,31}
this_month=tonumber(os.date("%m"))
number_days=monthdays[this_month]
-- TEXT positioning DAY #'s
local center_x=init.center_x
local center_y=init.center_y
local radius=105
cairo_select_font_face (cr, "Liquid Crystal", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
cairo_set_font_size (cr, 20)
local this_day=tonumber(os.date("%d"))
for i=1,number_days do
-- OUTTER POINTS POSTION FOR TEXT
local point=(math.pi/180)*((360/number_days)*(i-1))
local x=0+radius*(math.sin(point))
local y=0-radius*(math.cos(point))
-- CALCULATE CENTRE OF TEXT
--only print even numbers
if math.mod(i, 2) == 0 and math.mod(this_day, 2)==0 then
text=string.format("%02d",i) --formats numbers to double digits
elseif math.mod(i, 2) ~= 0 and math.mod(this_day, 2)~=0 then
text=string.format("%02d",i) --formats numbers to double digits
else
text=""
end --odd even matching
cairo_text_extents(cr,text,extents)
local width=extents.width
local height=extents.height
if i==this_day then
cairo_set_source_rgba (cr,0,1,1,1) -- active colour
else
cairo_set_source_rgba (cr,1,1,1,0.35) -- dim inactive numbers
end
cairo_move_to(cr,center_x+x-(width/2),center_y+y+(height/2))
cairo_show_text (cr, text)
cairo_stroke (cr)
end
-- INNER POINTS POSITION, radius smaller than text circle
local radius=90
for i=1,number_days do
local point=(math.pi/180)*((360/number_days)*(i-1))
local x=0+radius*(math.sin(point))
local y=0-radius*(math.cos(point))
if i==this_day then
cairo_set_source_rgba (cr,0,1,1,1) -- active colour
else
cairo_set_source_rgba (cr,1,1,1,0.35) -- dim the points
end
cairo_arc (cr,center_x+x,center_y+y,1,0,2*math.pi)
cairo_stroke (cr)
end
-- ######################################### END DIAL D ###
-- ### START CLOCK A ######################################
-- SET MARKS ###
-- MARKS AROUND CLOCK A -- Large Main 24 HR Clock
local number_marks_A=init.hour
-- set mark length
local m_length_A=0 -- doesn't work but can't delete
-- set mark width
local m_width_A=0 -- doesn't work but can't delete
-- set mark line cap type
local m_cap=CAIRO_LINE_CAP_ROUND
-- set mark color and alpha,red blue green alpha
local mr,mg,mb,ma=1,1,1,0 -- opaque white -- doesn't work but can't delete
-- SETUP HOUR HANDS ###
-- CLOCK A HOUR HAND
hh_length_A=90
-- set hour hand width
hh_width_A=4
-- set hour hand line cap
hh_cap=CAIRO_LINE_CAP_ROUND
-- set hour hand color
-- hhr,hhg,hhb,hha=1,0,1,0 -- fully opaque white --doesn't work
-- SETUP MINUTE HANDS ###
-- CLOCK A MINUTE HAND SETUP
-- set length of minute hand
mh_length_A=123
-- set minute hand width
mh_width_A=2
-- set minute hand line cap
mh_cap=CAIRO_LINE_CAP_ROUND
-- set minute hand color
--mhr,mhg,mhb,mha=1,1,1,0.5 -- fully opaque white --doesn't work
-- SETUP SECOND HAND ###
-- CLOCK A SECOND HAND SETUP -- DOESN'T WORK - Why ???????????????????????????
-- set length of seconds hand -- yes I know it is commented out!
--sh_length_A=150
-- set hour hand width
--sh_width_A=2
-- set hour hand line cap
--sh_cap=CAIRO_LINE_CAP_ROUND
-- set seconds hand color
--shr,shg,shb,sha=1,0,0,1 -- fully opaque red
-- PART SECOND HAND
--position
--get seconds value
local seconds=tonumber(os.date("%S"))
--calculate rotation of second hand in degrees
if init.line == true then
local arc=(math.pi/180)*((360/60)*seconds)
--calculate point 1
local radius1=120
local x1=0+radius1*math.sin(arc)
local y1=0-radius1*math.cos(arc)
--calculate point 2
local radius2=130
local x2=0+radius2*math.sin(arc)
local y2=0-radius2*math.cos(arc)
--draw line connecting points
cairo_move_to (cr, center_x+x1,center_y+y1)
cairo_line_to (cr, center_x+x2, center_y+y2)
cairo_set_source_rgba (cr,255/255,0/255,0/255,1) -- PART SECOND HAND
cairo_stroke (cr)
end
-- CLOCK A ### 12 HR TIME ###
-- CLOCK SETTINGS
clock_radius=0 --does not work
clock_centerx=init.center_x -- centre of Clock hands
clock_centery=init.center_y -- centre of Clock hands
-- DRAWING CODE
-- DRAW MARKS
-- stuff that can be moved outside of the loop, needs only be set once
-- calculate end and start radius for marks
m_end_rad=clock_radius-b_to_m
m_start_rad=m_end_rad-m_length_A -- WHAT IS THIS??
-- set line cap type
cairo_set_line_cap (cr, m_cap)
-- set line width
cairo_set_line_width (cr,m_width_A)
-- set color and alpha for marks
cairo_set_source_rgba (cr,mr,mg,mb,ma)
-- START LOOP FOR HOUR MARKS
for i=1,number_marks_A do
-- drawing code using the value of i to calculate degrees
-- calculate start point for 12/24 hour mark
radius=m_start_rad
point=(math.pi/180)*((i-1)*(360/number_marks_A))
x=0+radius*(math.sin(point))
y=0-radius*(math.cos(point))
-- set start point for line
cairo_move_to (cr,clock_centerx+x,clock_centery+y)
-- calculate end point for 12/24 hour mark
radius=m_end_rad
point=(math.pi/180)*((i-1)*(360/number_marks_A))
x=0+radius*(math.sin(point))
y=0-radius*(math.cos(point))
-- set path for line
cairo_line_to (cr,clock_centerx+x,clock_centery+y)
-- draw the line
cairo_stroke (cr)
end -- of for loop
-- HOUR MARKS -- ???????????????????????????????????????????????????????????????
-- TIME CALCULATIONS CLOCK A
if clock_type_A==12 then
hours=tonumber(os.date("%I"))
-- convert hours to seconds
h_to_s=hours*60*60
elseif clock_type_A==24 then
hours=tonumber(os.date("%H"))
-- convert hours to seconds
h_to_s=hours*60*60
end
minutes=tonumber(os.date("%M"))
-- convert minutes to seconds
m_to_s=minutes*60
-- get current seconds
seconds=tonumber(os.date("%S"))
-- DRAW HOUR HAND ###
-- get hours minutes seconds as just seconds
hsecs=h_to_s+m_to_s+seconds
-- calculate degrees for each second
hsec_degs=hsecs*(360/(60*60*clock_type_A)) -- use equation ~ eliminate decimals
-- set radius to calculate hand points
radius=hh_length_A
-- set start line coordinates, the center of the circle
cairo_move_to (cr,clock_centerx,clock_centery)
-- calculate coordinates for end of hour hand
point=(math.pi/180)*hsec_degs
x=0+radius*(math.sin(point))
y=0-radius*(math.cos(point))
-- describe the line we will draw
cairo_line_to (cr,clock_centerx+x,clock_centery+y)
-- set up line attributes and draw line
cairo_set_line_width (cr,hh_width_A)
cairo_set_source_rgba (cr,0,1,1,0.7) -- active colour Hour Hand ================
cairo_set_line_cap (cr, hh_cap)
cairo_stroke (cr)
-- DRAW MINUTE HAND
-- get minutes and seconds just as seconds
msecs=m_to_s+seconds
-- calculate degrees for each second
msec_degs=msecs*0.1
-- set radius to calculate hand points
radius=mh_length_A
-- set start line coordinates, the center of the circle
cairo_move_to (cr,clock_centerx,clock_centery)
-- calculate coordinates for end of minute hand
point=(math.pi/180)*msec_degs
x=0+radius*(math.sin(point))
y=0-radius*(math.cos(point))
-- describe the line we will draw
cairo_line_to (cr,clock_centerx+x,clock_centery+y)
-- set up line attributes and draw line
cairo_set_line_width (cr,mh_width_A)
cairo_set_source_rgba (cr,0,1,1,0.7) -- active colour Minute Hand ==============
cairo_set_line_cap (cr, mh_cap)
cairo_stroke (cr)
-- ### CLOCK A ###
local center_x=init.center_x -- Centre of the HR / Min Numbers
local center_y=init.center_y -- Centre of the HR / Min Numbers
local radius=init.radius -- 12/24 HR CLOCK Hours/Minutes radius -- seeline 42
cairo_select_font_face (cr, "DS-Digital", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
cairo_set_font_size (cr, 22)
cairo_set_source_rgba (cr,1,1,1,1.0) -- HR Clock numbers
-- TABLE OF TEXT -- in order
if init.hour == 12 then
text_days={"12","01","02","03","04","05","06","07","08","09","10","11",}
for i=1,12 do
-- OUTTER POINTS POSTION FOR TEXT
local point=(math.pi/180)*((360/12)*(i-1))
local x=0+radius*(math.sin(point))
local y=0-radius*(math.cos(point))
-- CALCULATE CENTRE OF TEXT
local text=text_days[i]--gets text from table
cairo_text_extents(cr,text,extents)
local width=extents.width
local height=extents.height
cairo_move_to(cr,center_x+x-(width/2),center_y+y+(height/2))
cairo_show_text (cr, text)
cairo_set_source_rgba (cr,1,1,1,1.0) -- colour of HR Numbers
cairo_stroke (cr)
end
-- INNER POINTS POSITION, radius smaller than text circle
local radius=124 -- 12 HR Clock
for i=1,12 do
local point=(math.pi/180)*((360/12)*(i-1))
local x=0+radius*(math.sin(point))
local y=0-radius*(math.cos(point))
cairo_arc (cr,center_x+x,center_y+y,1,0,2*math.pi)
cairo_set_source_rgba (cr,1,1,1,0.50)
cairo_stroke (cr)
end
end
if init.hour == 24 then
text_days={"00","01","02","03","04","05","06","07","08","09","10","11","12","13","14","15","16","17","18","19","20","21","22","23",}
for i=1,24 do
-- OUTTER POINTS POSTION FOR TEXT
local point=(math.pi/180)*((360/24)*(i-1))
local x=0+radius*(math.sin(point))
local y=0-radius*(math.cos(point))
-- CALCULATE CENTRE OF TEXT
local text=text_days[i]--gets text from table
cairo_text_extents(cr,text,extents)
local width=extents.width
local height=extents.height
cairo_move_to(cr,center_x+x-(width/2),center_y+y+(height/2))
cairo_show_text (cr, text)
cairo_stroke (cr)
end
-- INNER POINTS POSITION, radius smaller than text circle
local radius=124 -- 24 HR Clock
for i=1,24 do
local point=(math.pi/180)*((360/24)*(i-1))
local x=0+radius*(math.sin(point))
local y=0-radius*(math.cos(point))
cairo_arc (cr,center_x+x,center_y+y,1,0,2*math.pi)
cairo_set_source_rgba (cr,1,1,1,0.4)
cairo_stroke (cr)
end
end
-- ############################################################################
-- POSITION FOR TEXT HOUR NUMBERS
if init.hour == 12 and init.second == true then
text_days={"","01","02","03","04","","06","07","08","09","","11","12","13","14","","16","17","18","19","","21","22","23","24","","26","27","28","29","","31","32","33","34","","36","37","38","39","","41","42","43","44","","46","47","48","49","","51","52","53","54","","56","57","58","59","",}
-- INNER POINTS POSITION, radius smaller than text circle
cairo_set_source_rgba (cr,1,1,1,0.07) -- does not work -- settings moved
cairo_select_font_face (cr, "monofur", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
for i=1,60 do
local radius=124 -- dots for seconds Clock A (12 dial)
local point=(math.pi/180)*((360/60)*(i-1))
local x=0+radius*(math.sin(point))
local y=0-radius*(math.cos(point))
if seconds == i-1 then
cairo_set_source_rgba (cr,255/255,0/255,0/255,0.07) -- does not work - settings moved
else
if i-1 == 0 or i-1 == 5 or i-1 == 10 or i-1 == 15 or i-1 == 25 or i-1 == 30 or i-1 == 35 or i-1 == 40 or i-1 == 45 or i-1 == 50 or i-1 == 55 then
cairo_set_source_rgba (cr,0,1,1,1) -- active colour
else
cairo_set_source_rgba (cr,0,1,1,0.0) -- dots for seconds A Clock
end
end
cairo_arc (cr,center_x+x,center_y+y,1/2,0,2*math.pi)
cairo_stroke (cr)
end
radius=radius-3
cairo_set_font_size (cr, 10)
for i=1,60 do
-- OUTTER POINTS POSTION FOR TEXT
local point=(math.pi/180)*((360/60)*(i-1))
local x=0+radius*(math.sin(point))
local y=0-radius*(math.cos(point))
-- CALCULATE CENTRE OF TEXT
local text=text_days[i]--gets text from table
if seconds == tonumber(text) then
cairo_set_source_rgba (cr,0,1,1,1.0) -- active colour
else
cairo_set_source_rgba (cr,1,1,1,0.15) -- seconds numbers
end
cairo_text_extents(cr,text,extents)
local width=extents.width
local height=extents.height
cairo_move_to(cr,center_x+x-(width/2),center_y+y+(height/2))
cairo_show_text (cr, text)
cairo_stroke (cr)
end
end
-- ############################################################################
cairo_stroke (cr)
cairo_destroy(cr)
cairo_surface_destroy(cs)
cr=nil
end -- end main function
--[[ mrpeachy wrote:
the numbers are drawn using a for loop somewhere, like this
for i=1,12 do
calculate position of number
move_to(x,y)
show_text(i)
end
change it to something like this
for i=1,12 do
calculate position of number
if i==month_number then
move_to(x,y)
show_text(month_number)
else
move_to(x,y)
show_text(i)
end
end ]]
Code:--[[Background originally by londonali1010 (2009)
ability to set any size for background mrpeachy 2011
ability to set variables for bg in conkyrc dk75
the change is that if you set width and/or height to 0
then it assumes the width and/or height of the conky window
so:
Above and After TEXT (requires a composite manager or it blinks!)
lua_load ~/wea_conky/draw_bg.lua
TEXT
${lua conky_draw_bg 10 0 0 0 0 0x000000 0.4}
OR Both above TEXT (no composite manager required - no blinking!)
@Mr Peachy
lua_load ~/wea_conky/draw_bg.lua
lua_draw_hook_pre draw_bg 10 0 0 0 0 0x000000 0.5
TEXT
Note
${lua conky_draw_bg 20 0 0 0 0 0x000000 0.4}
See below: 1 2 3 4 5 6 7
${lua conky_draw_bg corner_radius x_position y_position width height color alpha}
covers the whole window and will change if you change the minimum_size setting
1 = 20 corner_radius
2 = 0 x_position
3 = 0 y_position
3 = 0 width
5 = 0 height
6 = 0x000000 color
7 = 0.4 alpha
######### calendar function ##################################################
then to use it, you activate the calendar function BELOW TEXT like this
${lua luacal {settings}}
#${lua luacal {x=,y=,tf="",tfs=,tc=,ta=,bf="",bfs=,bc=,ba=,hf="",hfs=,hc=,ha=,sp="",gh=,gt=,gv=,sd=}}
# x=x position top left
# y=y position top left
# tf=title font, eg "mono" must be in quotes
# tfs=title font size
# tc=title color
# ta=title alpha
# bf=body font, eg "mono" must be in quotes
# bfs=body font size
# bc=body color
# ba=body alpha
# hf=highlight font, eg "mono" must be in quotes
# hfs=highlight font size
# hc=highlight color
# ha=highlight alpha
# sp=spacer, eg " " or sp="0"... 0,1 or 2 spaces can help with positioning of non-monospaced fonts
# gt=gap from title to body
# gh=gap horizontal between columns
# gv=gap vertical between rows
# sd=start day, 0=Sun, 1=Mon
# hstyle = heading style, 0=just days, 1=date insert
# tdf=title date font, eg "mono" must be in quotes
# tdfs=title date font size
# tdc=title date color
# tda=title date alpha
# test line
-- ${lua luacal {x=10,y=100,tf="Purisa",tfs=24,tc=0xf67e16,ta=1,bf="First Order",bfs=26,bc=0xecd32a,ba=1,hf="Purisa",hfs=18,hc=0xf67e16,ha=1,sp=" ",gh=40,gt=25,gv=20,sd=0,hstyle=1,tdf="First Order",tdfs=28,tdc=0xff0000,tda=1}}
]]
require 'cairo'
local cs, cr = nil
function rgb_to_r_g_b(colour,alpha)
return ((colour / 0x10000) % 0x100) / 255., ((colour / 0x100) % 0x100) / 255., (colour % 0x100) / 255., alpha
end
function conky_draw_bg(r,x,y,w,h,color,alpha)
if conky_window == nil then return end
if cs == nil then cairo_surface_destroy(cs) end
if cr == nil then cairo_destroy(cr) end
local cs = cairo_xlib_surface_create(conky_window.display, conky_window.drawable, conky_window.visual, conky_window.width, conky_window.height)
local cr = cairo_create(cs)
w=w
h=h
if w=="0" then w=tonumber(conky_window.width) end
if h=="0" then h=tonumber(conky_window.height) end
cairo_set_source_rgba (cr,rgb_to_r_g_b(color,alpha))
--top left mid circle
local xtl=x+r
local ytl=y+r
--top right mid circle
local xtr=(x+r)+((w)-(2*r))
local ytr=y+r
--bottom right mid circle
local xbr=(x+r)+((w)-(2*r))
local ybr=(y+r)+((h)-(2*r))
--bottom right mid circle
local xbl=(x+r)
local ybl=(y+r)+((h)-(2*r))
-----------------------------
cairo_move_to (cr,xtl,ytl-r)
cairo_line_to (cr,xtr,ytr-r)
cairo_arc(cr,xtr,ytr,r,((2*math.pi/4)*3),((2*math.pi/4)*4))
cairo_line_to (cr,xbr+r,ybr)
cairo_arc(cr,xbr,ybr,r,((2*math.pi/4)*4),((2*math.pi/4)*1))
cairo_line_to (cr,xbl,ybl+r)
cairo_arc(cr,xbl,ybl,r,((2*math.pi/4)*1),((2*math.pi/4)*2))
cairo_line_to (cr,xtl-r,ytl)
cairo_arc(cr,xtl,ytl,r,((2*math.pi/4)*2),((2*math.pi/4)*3))
cairo_close_path(cr)
cairo_fill (cr)
------------------------------------------------------------
cairo_surface_destroy(cs)
cairo_destroy(cr)
return ""
end
-- ###### calendar function ##################################################
function conky_luacal(caltab) -- {x=,y=,tf="",tfs=,tc=,ta=,bf="",bfs=,bc=,ba=,hf="",hfs=,hc=,ha=,sp="",gt=,gh=,gv=,sd=,hstyle=,tdf=,tdfs=,tdc=,tda=}
if conky_window == nil then return end
local cs = cairo_xlib_surface_create(conky_window.display, conky_window.drawable, conky_window.visual, conky_window.width, conky_window.height)
local cr = cairo_create(cs)
--############################################################################
if caltab.x==nil then
caltab=loadstring("return" .. caltab)()
end
local cal_x=caltab.x
local cal_y=caltab.y
local tfont=caltab.tf or "mono"
local tfontsize=caltab.tfs or 12
local tc=caltab.tc or 0xffffff
local ta=caltab.ta or 1
local bfont=caltab.bf or "mono"
local bfontsize=caltab.bfs or 12
local bc=caltab.bc or 0xffffff
local ba=caltab.ba or 1
local hfont=caltab.hf or "mono"
local hfontsize=caltab.hfs or 12
local hc=caltab.hc or 0xff0000
local ha=caltab.ha or 1
local spacer=caltab.sp or " "
local gaph=caltab.gh or 20
local gapt=caltab.gt or 15
local gapl=caltab.gv or 15
local sday=caltab.sd or 0
local hstyle=caltab.hstyle or 0
--convert colors
--local font=string.gsub(font,"_"," ")
local tred,tgreen,tblue,talpha=rgb_to_r_g_b(tc,ta)
--main body text color
local bred,bgreen,bblue,balpha=rgb_to_r_g_b(bc,ba)
--highlight text color
local hred,hgreen,hblue,halpha=rgb_to_r_g_b(hc,ha)
--############################################################################
--calendar calcs
local year=os.date("%G")
local today=tonumber(os.date("%d"))
local t1 = os.time( { year=year,month=03,day=01,hour=00,min=0,sec=0} );
local t2 = os.time( { year=year,month=02,day=01,hour=00,min=0,sec=0} );
local feb=(os.difftime(t1,t2))/(24*60*60)
local monthdays={ 31, feb, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }
local day=tonumber(os.date("%w"))+1-sday
local day_num = today
local remainder=day_num % 7
local start_day=day-(day_num % 7)
if start_day<0 then start_day=7+start_day end
local month=os.date("%m")
local mdays=monthdays[tonumber(month)]
local x=mdays+start_day
local dnum={}
local dnumh={}
if mdays+start_day<36 then
dlen=35
plen=29
else
dlen=42
plen=36
end
for i=1,dlen do
if i<=start_day then
dnum[i]=" "
else
dn=i-start_day
if dn=="nil" then dn=0 end
if dn<=9 then dn=(spacer .. dn) end
if i>x then dn="" end
dnum[i]=dn
dnumh[i]=dn
if dn==(spacer .. today) or dn==today then
dnum[i]=""
end
if dn==(spacer .. today) or dn==today then
dnumh[i]=dn
place=i
else dnumh[i]=" "
end
end
end--for
cairo_select_font_face (cr, tfont, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cr, tfontsize);
cairo_set_source_rgba (cr,tred,tgreen,tblue,talpha)
local extents=cairo_text_extents_t:create()
tolua.takeownership(extents)
if hstyle==0 then
if tonumber(sday)==0 then
dys={"SU","MO","TU","WE","TH","FR","SA"}
else
dys={"MO","TU","WE","TH","FR","SA","SU"}
end
--draw calendar titles
elseif hstyle==1 then
if tonumber(sday)==0 then
dys={"SU","MO"," "," "," ","FR","SA"}
cairo_text_extents(cr,"MO",extents)
local s=extents.x_advance+gaph
local f=gaph*5
local tdfont=caltab.tdf or "mono"
local tdfontsize=caltab.tdfs or 12
local tdc=caltab.tdc or 0xffffff
local tda=caltab.tda or 1
cairo_select_font_face (cr, tdfont, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cr, tdfontsize);
local tdred,tdgreen,tdblue,tdalpha=rgb_to_r_g_b(tdc,tda)
cairo_set_source_rgba (cr,tdred,tdgreen,tdblue,tdalpha)
local insert=os.date("%b %y")
cairo_text_extents(cr,insert,extents)
local w=extents.x_advance
cairo_move_to (cr, cal_x+((s+f)/2)-(w/2), cal_y)
cairo_show_text (cr,insert)
cairo_stroke (cr)
else
dys={"MO","TU"," "," "," ","SA","SU"}
cairo_text_extents(cr,"TU",extents)
local s=extents.x_advance+gaph
local f=gaph*5
local tdfont=caltab.tdf or "mono"
local tdfontsize=caltab.tdfs or 12
local tdc=caltab.tdc or 0xffffff
local tda=caltab.tda or 1
cairo_select_font_face (cr, tdfont, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cr, tdfontsize);
local tdred,tdgreen,tdblue,tdalpha=rgb_to_r_g_b(tdc,tda)
cairo_set_source_rgba (cr,tdred,tdgreen,tdblue,tdalpha)
local insert=os.date("%b %y")
cairo_text_extents(cr,insert,extents)
local w=extents.x_advance
cairo_move_to (cr, cal_x+((s+f)/2)-(w/2), cal_y)
cairo_show_text (cr,insert)
cairo_stroke (cr)
end
end
--draw calendar titles
for i=1,7 do
cairo_select_font_face (cr, tfont, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cr, tfontsize);
cairo_set_source_rgba (cr,tred,tgreen,tblue,talpha)
cairo_move_to (cr, cal_x+(gaph*(i-1)), cal_y)
cairo_show_text (cr, dys[i])
cairo_stroke (cr)
end
--draw calendar body
cairo_select_font_face (cr, bfont, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cr, bfontsize);
cairo_set_source_rgba (cr,bred,bgreen,bblue,balpha)
for i=1,plen,7 do
local fn=i
for i=fn,fn+6 do
cairo_move_to (cr, cal_x+(gaph*(i-fn)),cal_y+gapt+(gapl*((fn-1)/7)))
cairo_show_text (cr, dnum[i])
cairo_stroke (cr)
end
end
--highlight
cairo_select_font_face (cr, hfont, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cr, hfontsize);
cairo_set_source_rgba (cr,hred,hgreen,hblue,halpha)
for i=1,plen,7 do
local fn=i
for i=fn,fn+6 do
cairo_move_to (cr, cal_x+(gaph*(i-fn)),cal_y+gapt+(gapl*((fn-1)/7)))
cairo_show_text (cr, dnumh[i])
cairo_stroke (cr)
end
end
--############################################################################
caltab=nil
dlen=nil
plen=nil
cairo_destroy(cr)
cairo_surface_destroy(cs)
cr=nil
return ""
end-- end main function#######################################################
Your Conky looks good as usual.
Yeah I've been tweaking my Conky (along with other customizations) a lot over the holidays and after work to unwind. I keep adding features and then a day later removing them. I've been learning more about the "grep" command to use it more efficiently, however "awk" still confounds me and I can't find anything online that really explains how to use it to do the things I want in Conky (I am making a little progress with it through trial and error though).
Aside from Conky I've also been working a lot on getting my ROM (N64 & SNES emulators) files to appear independently in my Unity Dash so that they be launched as stand alone game apps. Been having to learn a little about how unity works and how to use gimp to add transparency to my custom icons.
I did find my Conky "Public IP Address" display did not function correctly when my laptop is logged on to the network at work. I might look into why that is at some point. I believe I use the code
I suspect my work network blocks access to that web address.Code:pre_exec wget -O - http://ip.tupeux.com | tail
@ Petro Dawg
Thanks for the compliment. Funny thing is most conkys I do just get archived and end there. They may or may not become a base for the next 'generation' if you will. But I enjoy it, that's the mane thing. Once I get something really like it usually stays on my desktop for a 6-8 months to a year then I change it "just because".
I know what you mean about grep and awk, and for me, you can toss sed in the pot as well. It all looks like some sort of secret Enigma Code, and when someone uses all three together ... I'm like a sailboat in a Sargasso Sea! :lolflag:
RE the Public IP ... could that be because of a firewall? (I'm like a fish out of water with this, I only have a desktop and have never had a laptop)
AWK is like GREP and SED together and more.
First, you must understand AWK logic, then any site with functions list will be enough.
AWK either reads a file or reads STDIN, and process everything line by line. If for example CURL spill result in one line then both GREP and AWK will be useless.
By default, AWK uses space char as delimiter. Delimiter is part that split lines into a data chunks, that could be accessed as numbered variables: $0 for full line, $1 for first data chunk, $2 for second data chunk and so on.
It differs from CUT because AWK use any number of this delimiter char as splitter while CUT uses only one character.
So, for AWK, stringhave two data chunks, "Hey" for $1 and "Ho" for $2, while for CUT, you have 11 data chunks with 9 spaces in between "Hey" and "Ho".Code:"Hey Ho"
That was delimiter, "-F" operator. You could use any char for that... for example "H":
Then, any command must be between single quote clause (').Code:echo "Hey Ho" | awk -F"H" '{print "#"$1"#"$2"#"$3"#"}'
First, you must chose a line of text to process, like with GREP.
You either use REGEX for that ("//") or, if need to use variables, compare pattern/variable to variable $0:
both will print lines where "temp1" pattern exists.Code:echo -e "temp0 0.0°F\ntemp1 666.0°F\ntemp2 -100.0°F" | awk '/temp1/'
echo -e "temp0 0.0°F\ntemp1 666.0°F\ntemp2 -100.0°F" | awk '$0 ~ "temp1"'
Now, if we have GREP part done, we must chose which data chunk to print:
Code:echo -e "temp0 0.0°F\ntemp1 666.0°F\ntemp2 -100.0°F" | awk '/temp1/ {print $1}'
echo -e "temp0 0.0°F\ntemp1 666.0°F\ntemp2 -100.0°F" | awk '/temp1/ {print $2}'
Now, we can add some string manipulation functions (as like SED).
You can manipulate whole line or specific data chunk only.
For example "gsub" function, to replace pattern.
When we want to change "F" to "C" in temperatures then:
There might be more capital "F" in line, so you must be more specific as to in which data chunk to do it:Code:echo -e "temp0 0.0°F\ntemp1 666.0°F\ntemp2 -100.0°F" | awk '/temp1/ {gsub(/F/,"C"); print}'
As you see, "gsub" function uses regex to search for a pattern, so some chars are registered as a special characters (command characters). In that cases, if you search for that specific character it must be escaped by "\" character.Code:echo -e "temp0 0.0°F\ntemp1 666.0°F\ntemp2 -100.0°F" | awk '/temp1/ {gsub(/F/,"C",$2); print}'
For example, let's search for dot and zero and remove them from string:
regexp "\.." search for dot character ("\.") and for any single character thereafter ("."), and then it replaces them with "" (empty string).Code:echo -e "temp0 0.0°F\ntemp1 666.0°F\ntemp2 -100.0°F" | awk '/temp1/ {gsub(/\../,"",$2); print}'
Want to convert Fahrenheit to Celsius?
Code:echo -e "temp0 0.0°F\ntemp1 666.0°F\ntemp2 -100.0°F" | awk '/temp1/ {sub(/.F/, "", $2); $2=($2-32)*(5/9); sub(/\..+/, "", $2); print $0"°C"}'
- /temp1/ - chose line with "temp1" in it
- sub - replaces pattern to a string once ("gsub" do it to the end of line)
- /.F/ - "sub" search for a "any single character and capital F"
- "" - "sub" replaces pattern with empty string
- $2 - whole operation done on $2 data chunk
- $2=($2-32)*(5/9) - mathematical conversion of clean number inside of $2, from Fahrenheit to Celsius (result in floating point number)
- sub - clearing floating point
- /\..+/ - search for "dot and any character after"
- "" - replace with empty string
- $2 - operation done on $2 data chunk
- print - print the result
- $0 - print whole line ($2 is inside whole line, and was changed by previous string manipulation functions)
- "°C" - "degree Celsius" string to print
@ dk75
Thanks a lot for the simple English explanation of awk. I bookmarked this page of the tread so I refer to it later when I'm working on my Conky. I will try to incorporate it into my Conky this weekend.
@dk75, I cut and pasted this! Great info. If you decide to do a howto, I'd definitely read it
I couldn't wait until this weekend to start using the new tricks I learned from dk75's explanation of AWK. I updated my code and replace most of the "grep" with "awk".
I still have an instance where I think grep is the better choice as I want to limit device names plugged in to my USB ports to just 10 characters so their memory displays don't get pushed off the edge of Conky if they happen to have very long names. But with Conky (and Linux in general), I am sure there are many different ways to accomplish that goal.
Here's the my latest and greatest configuration.
http://farm9.staticflickr.com/8512/8...1dc1843f_m.jpg
My right (laptop) monitor gets down to business with just about anything I might need through out the day and a Conky that displays just about all the important system information I can think to display.
My left monitor now proudly displays all my favorite SNES and N64 games (as well as a few native Linux gems). It took a while to make .sh files for all my roms and get them linked to icons (some custom made) and searchable by Unity Dash.
Code:############################################################################################
# #
# .conkyrc (version 1.07) #
# A clean, simple, yet useful configuration code for conky #
# #
# Written by Petro Dawg (aka Greg): #
# Last updated on 1/4/13 (version 1.07) #
# > Added available sytem update fields #
# > Added router name and signal strength field #
# > Changed most of the grep commands to awk #
# Updated on 12/30/12 (version 1.06) #
# > Changed to grey and orange color scheme #
# > revamped fonts, reverted many changes made in last version #
# > Added date field -later removed- #
# > adjusted position and width #
# Updated on 12/24/12 (version 1.05) #
# > Changed color scheme to neon #
# > Added fonts for Ubuntu symbol and CPU bar numbers #
# Updated on 9/14/12 (version 1.04) #
# > Added MAC and Public IP addresses to output #
# > USB output will disappear from Conky when USB drive is ejected #
# Updated on 9/2/12 (version 1.03) #
# > Made USB file system output read any USB drive reguardless of name. Supports up to #
# three USB drives. Displays names of each USB drive and memory_used/memory_total #
# > Added more color control #
# > Changed override_utf8_locale value from 'no' to 'yes' (stopped 12.04-3D flashing) #
# > Changed font Ubuntu:bold:size=11 to xftfont Ubuntu:bold:size=11 #
# > Changed no_buffers value from 'no' to 'yes' (fixed ram graph output) #
# > Added degree symbol to temperature output #
# Updated on 8/31/12 (version 1.02) #
# > Deleted redundant outputs and adjusted format to make the display more concise. #
# Updated on 8/26/12 (version 1.01) #
# > Based on source code from http://lonelymachines.org/2012/08/16/simple-conky-config/ #
# > This version has been significately modified to meet my needs and reorganized to #
# add clarity for anyone wanting to modify the code further to meet their own needs. #
# #
# Displays the following PC information on the Desktop within an embedded window: #
# > Operating System details #
# > Number of available system updates #
# > CPU temp #
# > CPU operating speed #
# > Individual core usage #
# > Top 3 processes using CPU resources #
# > Total RAM #
# > Active RAM amount #
# > Top 3 processes using RAM resources #
# > Root folder size and memory used #
# > Home folder size and memory used #
# > USB drive size and memory used (when attached) #
# > Private and Public IP Addresses #
# > Wireless MAC address #
# > Download speed and data Received #
# > Upload speed and data Sent #
# #
# Requires installation of: #
# > conky (available in software center) #
# > lm-sensors (available in software center) #
# #
# Additional information and resources: #
# > To run conky at startup, create an empty file in your home folder, name it #
# ".conky-startup.sh" and copy the following 2 lines in it: #
# !/bin/bash #
# sleep 15 && conky ; #
# Add the path to the .conky-startup.sh file within Startup Applications. #
# > http://conky.sourceforge.net/ #
# > http://www.graphviz.org/doc/info/colors.html #
# > http://www.december.com/html/spec/colorhex.html #
# > Save fonts to .fonts folder in home screen
# > To load fonts into Conky after font installation run the following in terminal: #
# fc-cache -fv #
# then reboot system if needed #
# #
############################################################################################
#conky performance settings
update_interval 3.0
total_run_times 0
cpu_avg_samples 4
no_buffers yes
double_buffer yes
override_utf8_locale yes
#overall position of conky window
alignment top_right
gap_x 15
gap_y 200
minimum_size 180
maximum_width 150
#overall appearance of conky window
own_window yes
own_window_type normal
own_window_transparent yes
own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager
draw_borders no
#default text apperance
use_xft yes
xftalpha 0.9
xftfont Alfios:bold:size=10
default_color grey
draw_shades yes
draw_outline no
default_shade_color black
default_outline_color black
uppercase no
#border around graphs
draw_graph_borders yes
#colors
color1 orange
############################################################################################
# #
# The code below 'TEXT' will control what is displayed by conky: #
# -> In the interest of clarity, the system outputs are divided into four related groups #
# (i.e. all code related to the CPU is in one grouping of adjacent lines while code #
# related to RAM is in another grouping of adjacent lines). Each group is hereafter #
# refered to as a 'TEXT code block'. #
# -> To best fit your screen, adjust the overall vertical length of the display by #
# adding or deleting empty lines either before or after the TEXT code blocks below. #
# #
############################################################################################
TEXT
# TEXT code block 1: START
############################################################################################
# #
# The first TEXT code block displays operating system information #
# -> 'Updates Available' displays total updates avaible from all software sources #
# activated in the update manager #
# -> 'Security Updates' displays the number those available updates which are related #
# to system security #
# #
############################################################################################
${outlinecolor}${color1}${font Alfios:bold:size=12}${alignc}${execp lsb_release -d | awk '/Description/ {print $2, $3, $4}'}${outlinecolor}${color}${font}
${sysname}:${alignr}${kernel}
${font Alfios:size=9}Updates Available:${alignr}${execp /usr/lib/update-notifier/apt-check --human-readable | awk '/can/ {print $1}'}
Security Updates:${alignr}${execp /usr/lib/update-notifier/apt-check --human-readable | awk '/are/ {print $1}'} ${font}
# TEXT code block 1: END
# TEXT code block 2: START
############################################################################################
# #
# The second TEXT code block displays CPU information #
# -> Temperature displayed is the PCI Adapter temp1 output on same line as 'high' output #
# -> Requires the installation of lm-sensors to work: sudo apt-get lm-sensors #
# -> After installation run: sensors-detect (answer yes to all) #
# -> Run 'sensors' in terminal to determine which line needs grep & which columns #
# needs to be cut. #
# -> Replace: ${cpubar cpu1 5} with ${cpugraph cpu1 FFFF00 FF0000} to change to graph #
# output of CPU1 usage. #
# -> 'FFFF00' and 'FF0000' are HEX color codes and can be replaced with whatever colors #
# you like. Goto www.graphviz.org/doc/info/colors.html for color information (hold #
# mouse over color to see HEX code for that color). #
# -> Add % use outputs for cores by adding the following line: #
# Core '#': ${alignr}${cpu cpu'#'}% #
# (repeat for each additional core up to the total number of cores in the system) #
# (replace each '#' with the number of the core (i.e. 3 or 4)) #
# #
############################################################################################
Core Temp: ${alignr}${execp sensors k10temp-pci-00c3 | awk '/temp1/ {gsub(/\+/, ""); print $2}'}
CPU Speed: ${alignr}${freq}MHz
${outlinecolor black}${color1}${cpubar cpu1 5, 73}${alignr}${cpubar cpu2 5,73}${outlinecolor}${color}
${font Alfios:size=9}${top name 1}${alignr}${top cpu 1}
${font Alfios:size=9}${top name 2}${alignr}${top cpu 2}
${font Alfios:size=9}${top name 3}${alignr}${top cpu 3} ${font}
# TEXT code block 2: END
# TEXT code block 3: START
############################################################################################
# #
# Third TEXT code block displays RAM information: #
# -> Replace ${membar 10} with ${memgraph FFFF00 FF0000} to change to graph output of #
# RAM usage. (I did not find this very useful as RAM usage is usually fairly steady #
# on my sytem.) #
# #
############################################################################################
RAM Total: ${alignr}$memmax
${outlinecolor black}${color1}${membar 5}${outlinecolor}${color}
${font Alfios:size=9}${top_mem name 1}${alignr}${top_mem mem 1}
${font Alfios:size=9}${top_mem name 2}${alignr}${top_mem mem 2}
${font Alfios:size=9}${top_mem name 3}${alignr}${top_mem mem 3} ${font}
# TEXT code block 3: END
# TEXT code block 4: START
############################################################################################
# #
# Fourth TEXT code block displays Filesystem information: #
# -> The USB information is specific to the USB drive settings on my computer (i.e. my #
# 1st USB mounts at /dev/sdb1). Run 'df' in terminal to determine location of drives. #
# -> To make conky display correctly the cut locations for sdb1, sdc1, sdd1, & sdc may #
# need to be adjusted. #
# #
############################################################################################
Root: ${alignr}${fs_used /} / ${fs_size /}
${outlinecolor black}${color1}${fs_bar 5 /}${outlinecolor}${color}
Home: ${alignr}${fs_used /home} / ${fs_size /home}
${outlinecolor black}${color1}${fs_bar 5 /home}${outlinecolor}${color}${if_existing /dev/sdb1}
${execp df -H | grep 'sdb1' | cut -c46-56}:${alignr}${execp df -H | awk '/sdb1/ {print $3, "/", $2}'}${else}${endif}${if_existing /dev/sdc1}
${execp df -H | grep 'sdc1' | cut -c46-56}:${alignr}${execp df -H | awk '/sdc1/ {print $3, "/", $2}'}${else}${endif}${if_existing /dev/sdd1}
${execp df -H | grep 'sdd1' | cut -c46-56}:${alignr}${execp df -H | awk '/sdd1/ {print $3, "/", $2}'}${else}${endif}
# TEXT code block 4: END
# TEXT code block 5: START
############################################################################################
# #
# Fith TEXT code block displays Network information: #
# -> A graphical output of download information can be displayed by adding the following #
# line of code: #
# ${color2}${downspeedgraph wlan0 FFFF00 FF0000}${color} #
# -> A graphical output of upload information can be displayed by adding the following #
# line of code: #
# ${color2}${upspeedgraph wlan0 FFFF00 FF0000}${color} #
# -> 'FFFF00' and 'FF0000' are HEX color codes and can be replaced with whatever colors #
# you like. Goto www.graphviz.org/doc/info/colors.html for color information (hold #
# mouse over color to see HEX code for that color). ifconfig -a #
# #
############################################################################################
${outlinecolor black}${color1}${font Heydings Icons:size=8}R${font}${color} ${wireless_essid wlan0}${alignr}${wireless_link_qual_perc wlan0}%
#${outlinecolor black}${color1}${wireless_link_bar 4 wlan0}${outlinecolor}${color}
Private IP:${alignr}${addr wlan0}
Public IP:${alignr}${pre_exec wget -O - http://ip.tupeux.com | tail}
MAC:${alignr}${wireless_ap wlan0}
${outlinecolor black}${color1}${font Heydings Icons:bold:size=8}d${outlinecolor}${color}${font Alfios:size=9} ${downspeed wlan0}/s${alignr}${totaldown wlan0}
${outlinecolor black}${color1}${font Heydings Icons:bold:size=8}u${outlinecolor}${color}${font Alfios:size=9} ${upspeed wlan0}/s${alignr}${totalup wlan0}
# TEXT code block 5: END