suite de cette discussion
/viewtopic.php?id=426625
Bonjour à tous,
Tout d'abord, merci à Didier-T & Los Tintinos (conky meteo2.lua) et Despot77 (clock-rings.lua) pour leurs contributions qui m'ont permis la construction de mon conky, mais aussi à
Clapico grâce auquel j'ai découvert
Earthwallpaper et les conkies
clock-rings.lua et
Météo HTC.
Voici donc le fruit de mes adaptations :
Le dossier conky-meteo avec meteo2.lua 1.06 & recmeteo.py 1.20 (de Didier-T) a été installé dans le répertoire .conky de mon dossier personnel.
Le fichier clock_rings.lua (de Despot77) a subi quelques modifications pour inclure mes 4 CPU et changer la disposition initiale :
--[[
Clock Rings by Linux Mint (2011) reEdited by despot77
This script draws percentage meters as rings, and also draws clock hands if you want! It is fully customisable; all options are described in the script. This script is based off a combination of my clock.lua script and my rings.lua script.
IMPORTANT: if you are using the 'cpu' function, it will cause a segmentation fault if it tries to draw a ring straight away. The if statement on line 145 uses a delay to make sure that this doesn't happen. It calculates the length of the delay by the number of updates since Conky started. Generally, a value of 5s is long enough, so if you update Conky every 1s, use update_num>5 in that if statement (the default). If you only update Conky every 2s, you should change it to update_num>3; conversely if you update Conky every 0.5s, you should use update_num>10. ALSO, if you change your Conky, is it best to use "killall conky; conky" to update it, otherwise the update_num will not be reset and you will get an error.
To call this script in Conky, use the following (assuming that you save this script to ~/scripts/rings.lua):
lua_load ~/scripts/clock_rings.lua
lua_draw_hook_pre clock_rings
Changelog:
+ v1.0 -- Original release (30.09.2009)
v1.1p -- Jpope edit londonali1010 (05.10.2009)
*v Mint-lua -- reEdit despot77 (18.02.2011)
]]
settings_table = {
{
-- Edit this table to customise your rings.
-- You can create more rings simply by adding more elements to settings_table.
-- "name" is the type of stat to display; you can choose from 'cpu', 'memperc', 'fs_used_perc', 'battery_used_perc'.
name='time',
-- "arg" is the argument to the stat type, e.g. if in Conky you would write ${cpu cpu0}, 'cpu0' would be the argument. If you would not use an argument in the Conky variable, use ''.
arg='%I.%M',
-- "max" is the maximum value of the ring. If the Conky variable outputs a percentage, use 100.
max=12,
-- "bg_colour" is the colour of the base ring.
bg_colour=0xffffff,
-- "bg_alpha" is the alpha value of the base ring.
bg_alpha=0.1,
-- "fg_colour" is the colour of the indicator part of the ring.
fg_colour=0x339900,
-- "fg_alpha" is the alpha value of the indicator part of the ring.
fg_alpha=0.2,
-- "x" and "y" are the x and y coordinates of the centre of the ring, relative to the top left corner of the Conky window.
x=100, y=150,
-- "radius" is the radius of the ring.
radius=50,
-- "thickness" is the thickness of the ring, centred around the radius.
thickness=5,
-- "start_angle" is the starting angle of the ring, in degrees, clockwise from top. Value can be either positive or negative.
start_angle=0,
-- "end_angle" is the ending angle of the ring, in degrees, clockwise from top. Value can be either positive or negative, but must be larger than start_angle.
end_angle=360
},
{
name='time',
arg='%M.%S',
max=60,
bg_colour=0xffffff,
bg_alpha=0.1,
fg_colour=0x339900,
fg_alpha=0.4,
x=100, y=150,
radius=56,
thickness=5,
start_angle=0,
end_angle=360
},
{
name='time',
arg='%S',
max=60,
bg_colour=0xffffff,
bg_alpha=0.1,
fg_colour=0x339900,
fg_alpha=0.6,
x=100, y=150,
radius=62,
thickness=5,
start_angle=0,
end_angle=360
},
{
name='time',
arg='%d',
max=31,
bg_colour=0xffffff,
bg_alpha=0.1,
fg_colour=0x339900,
fg_alpha=0.8,
x=100, y=150,
radius=70,
thickness=5,
start_angle=-90,
end_angle=90
},
{
name='time',
arg='%m',
max=12,
bg_colour=0xffffff,
bg_alpha=0.1,
fg_colour=0x339900,
fg_alpha=1,
x=100, y=150,
radius=76,
thickness=5,
start_angle=-90,
end_angle=90
},
{
name='cpu',
arg='cpu0',
max=100,
bg_colour=0xffffff,
bg_alpha=0.3,
fg_colour=0x339900,
fg_alpha=0.8,
x=21, y=282,
radius=25,
thickness=5,
start_angle=-45,
end_angle=225
},
{
name='cpu',
arg='cpu1',
max=100,
bg_colour=0xffffff,
bg_alpha=0.3,
fg_colour=0x339900,
fg_alpha=0.8,
x=71, y=282,
radius=25,
thickness=5,
start_angle=-45,
end_angle=225
},
{
name='cpu',
arg='cpu2',
max=100,
bg_colour=0xffffff,
bg_alpha=0.3,
fg_colour=0x339900,
fg_alpha=0.8,
x=121, y=282,
radius=25,
thickness=5,
start_angle=-45,
end_angle=225
},
{
name='cpu',
arg='cpu3',
max=100,
bg_colour=0xffffff,
bg_alpha=0.3,
fg_colour=0x339900,
fg_alpha=0.8,
x=171, y=282,
radius=25,
thickness=5,
start_angle=-45,
end_angle=225
},
{
name='memperc',
arg='',
max=100,
bg_colour=0xffffff,
bg_alpha=0.3,
fg_colour=0x339900,
fg_alpha=0.8,
x=96, y=339,
radius=25,
thickness=5,
start_angle=-45,
end_angle=225
},
{
name='fs_used_perc',
arg='/',
max=100,
bg_colour=0xffffff,
bg_alpha=0.3,
fg_colour=0x339900,
fg_alpha=0.8,
x=146, y=339,
radius=25,
thickness=5,
start_angle=-45,
end_angle=225
},
{
name='downspeedf',
arg='eth1',
max=1200,
bg_colour=0xffffff,
bg_alpha=0.3,
fg_colour=0x339900,
fg_alpha=0.8,
x=121, y=396,
radius=25,
thickness=4,
start_angle=-45,
end_angle=225
},
{
name='upspeedf',
arg='eth1',
max=150,
bg_colour=0xffffff,
bg_alpha=0.3,
fg_colour=0xef8c25,
fg_alpha=0.8,
x=121, y=396,
radius=20,
thickness=4,
start_angle=-45,
end_angle=225
},
}
-- Use these settings to define the origin and extent of your clock.
clock_r=65
-- "clock_x" and "clock_y" are the coordinates of the centre of the clock, in pixels, from the top left of the Conky window.
clock_x=100
clock_y=150
show_seconds=true
require 'cairo'
function rgb_to_r_g_b(colour,alpha)
return ((colour / 0x10000) % 0x100) / 255., ((colour / 0x100) % 0x100) / 255., (colour % 0x100) / 255., alpha
end
function draw_ring(cr,t,pt)
local w,h=conky_window.width,conky_window.height
local xc,yc,ring_r,ring_w,sa,ea=pt['x'],pt['y'],pt['radius'],pt['thickness'],pt['start_angle'],pt['end_angle']
local bgc, bga, fgc, fga=pt['bg_colour'], pt['bg_alpha'], pt['fg_colour'], pt['fg_alpha']
local angle_0=sa*(2*math.pi/360)-math.pi/2
local angle_f=ea*(2*math.pi/360)-math.pi/2
local t_arc=t*(angle_f-angle_0)
-- Draw background ring
cairo_arc(cr,xc,yc,ring_r,angle_0,angle_f)
cairo_set_source_rgba(cr,rgb_to_r_g_b(bgc,bga))
cairo_set_line_width(cr,ring_w)
cairo_stroke(cr)
-- Draw indicator ring
cairo_arc(cr,xc,yc,ring_r,angle_0,angle_0+t_arc)
cairo_set_source_rgba(cr,rgb_to_r_g_b(fgc,fga))
cairo_stroke(cr)
end
function draw_clock_hands(cr,xc,yc)
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
-- Draw hour hand
xh=xc+0.7*clock_r*math.sin(hours_arc)
yh=yc-0.7*clock_r*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,1.0,1.0,1.0,1.0)
cairo_stroke(cr)
-- Draw minute hand
xm=xc+clock_r*math.sin(mins_arc)
ym=yc-clock_r*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)
-- Draw seconds hand
if show_seconds then
xs=xc+clock_r*math.sin(secs_arc)
ys=yc-clock_r*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
end
function conky_clock_rings()
local function setup_rings(cr,pt)
local str=''
local value=0
str=string.format('${%s %s}',pt['name'],pt['arg'])
str=conky_parse(str)
value=tonumber(str)
pct=value/pt['max']
draw_ring(cr,pct,pt)
end
-- Check that Conky has been running for at least 5s
if conky_window==nil then return end
local cs=cairo_xlib_surface_create(conky_window.display,conky_window.drawable,conky_window.visual, conky_window.width,conky_window.height)
local cr=cairo_create(cs)
local updates=conky_parse('${updates}')
update_num=tonumber(updates)
if update_num>5 then
for i in pairs(settings_table) do
setup_rings(cr,settings_table[i])
end
end
draw_clock_hands(cr,clock_x,clock_y)
end
Enfin mon fichier .conkyrc (basé sur celui lié à clock-rings.lua), enregistré dans mon dossier personnel, a été adapté pour intégrer la météo :
# Conky settings #
background no
update_interval 1
cpu_avg_samples 2
net_avg_samples 2
override_utf8_locale yes
double_buffer yes
no_buffers yes
text_buffer_size 2048
# Window specifications #
own_window yes
own_window_type normal
own_window_transparent yes
own_window_hints undecorate,sticky,skip_taskbar,skip_pager,below
border_inner_margin 0
border_outer_margin 0
minimum_size 200 250
maximum_width 200
alignment tr
gap_x 10
gap_y 10
# Graphics settings #
draw_shades no
draw_outline no
draw_borders no
draw_graph_borders yes
# Text settings #
use_xft yes
xftfont caviar dreams:bold:size=8
xftalpha 0.5
uppercase no
temperature_unit celsius
default_color FFFFFF
# -- Déclaration template -- #
template0 ${image ~/.conky/conky-meteo/meteo/images/\1 -p \2 -s \3} # -- images fond -- #
template1 ${lua Meteo_\1 \2 \3 \4 \5 \6} # -- gestion météo --#
template2 ${lua_parse Meteo_\1 \2 \3 \4 60 \5} # -- icônes météo -- \2=répertoire icônes \3=position \4=taille \5=jour (pour les prévisions) #
template3 ${lua Lune_\1}
template4 ${lua_parse Images_\1 \2 \3 60 \4} # -- Appelle image -- \2=position \3=taille \4=jour (pour les prévisions) #
# Lua Load #
lua_load ~/.conky/clock_rings.lua
lua_draw_hook_pre clock_rings
lua_load ~/.conky/conky-meteo/meteo_lua_2/scripts/meteo2.lua
lua_startup_hook init ~/.conky/conky-meteo/meteo/meteo.cfg
TEXT
# Date #
${voffset 8}${color a5cb92}${font caviar dreams:bold:size=16}${time %A}${font}${voffset -8}${alignr 50}${color FFFFFF}${font caviar dreams:size=38}${time %e}${font}
${voffset -30}${font caviar dreams:size=18}${time %b}${font}${voffset -3} ${color a5cb92}${font caviar dreams:size=20}${time %Y}${font}${color a5cb92}${hr}
# Département & température #
${voffset 135}${font caviar dreams:bold:size=10}${alignr}Gwada${font}
${font caviar dreams:bold:size=12}${color FFFFFF}${alignr}${weather http://weather.noaa.gov/pub/data/observations/metar/stations/ TFFR temperature temperature 30}°C${font}
# Image horloge #
${image ~/.conky/linux-mint1-300x300a.png -p 4,53 -s 192x192}
# CPU, RAM, Disk & Net #
${color FFFFFF}${goto 5}${voffset 5}${cpu cpu0}%${goto 55}${cpu cpu1}%${goto 105}${cpu cpu2}%${goto 155}${cpu cpu3}%
${color a5cb92}${goto 5}CPU1${goto 55}CPU2${goto 105}CPU3${goto 155}CPU4
${color FFFFFF}${voffset 31}${goto 80}${memperc}%${goto 130}${fs_used_perc /}%
${color a5cb92}${goto 80}RAM${goto 130}Disk
${voffset 30}${color 339900}${font caviar dreams:bold:size=7}Download :${goto 65}${color FFFFFF}${downspeed eth1}
${color ef8c25}Upload :${goto 65}${color FFFFFF}${upspeed eth1}
${color a5cb92}${voffset -18}${goto 110}${font caviar dreams:bold:size=8}Net
# Infos diverses ordinateur #
${voffset 30}${color a5cb92}${font caviar dreams:bold:size=8}Allumé depuis : ${color FFFFFF}${uptime_short}
${color a5cb92}Processus : ${color FFFFFF}${processes}
${color a5cb92}En cours : ${color FFFFFF}${running_processes}
${color ffffff}${alignr}${nodename}
${color a5cb92}${alignr}${pre_exec cat /etc/issue.net} ${color ffffff}$machine
${color a5cb92}${alignr}Kernel : ${color ffffff}${kernel}
${voffset 2}${color a5cb92}${font caviar dreams:bold:size=10}Météo${font} ${voffset -3}${hr}
#### Lancement du script récupérant les données météo ####
${template1 Maj}
#${template1 horsligne}
#### Premier cadre ####
##### température actuelle #####
${voffset -3}${goto 62}${font caviar dreams:bold:size=14}${color a5cb92}${template1 TempAct}°
##### ville #####
${voffset -37}${color ffffff}${font caviar dreams:bold:size=8}${template1 Ville}
##### Affichage infos vent ######
${voffset -13}${color a5cb92}${font caviar dreams:bold:size=8}${goto 145}${template1 VentDirP}
${voffset 1}${color FFFFFF}${font caviar dreams:bold:size=8}${goto 145}${template1 VentForce} km/h
##### Affichage conditions météo #####
${voffset 6}${font caviar dream:bold:size=7}${color ffffff}${alignc}${template1 CondMeteo}
#### Second cadre ####
##### Affichage temperature & probabilité de précipitations Jour/Nuit #####
${voffset 27}${color a5cb92}${font caviar dreams:bold:size=7}${goto 34}${template1 Jour_Temp 1}° / ${template1 Jour_ProbPrec 1}%${goto 124}${template1 Nuit_Temp 1}° / ${template1 Nuit_ProbPrec 1}%
##### Affichage conditions météo #####
#${voffset 26}${font caviar dreams:size=6}${color ffffff}${goto 10}${template1 AM_CondMeteo1 1}${goto 100} ${template1 Noct_CondMeteo1 1}
##### Affichage lunaison #####
${voffset 53}${font caviar dreams:bold:size=7}${color ffffff}${alignc}${template3 ephemerides1} ${template3 ephemerides2}
#### troisieme cadre ####
##### Affichage Date #####
${voffset 7}${font caviar dreams:bold:size=7}${color a5cb92}${goto 6}${template1 Jour %a_%d 2}${goto 56}${template1 Jour %a_%d 3}${goto 106}${template1 Jour %a_%d 4}${goto 156}${template1 Jour %a_%d 5}
##### Affichage précipitations #####
${voffset 3}${font caviar dreams:size=6}${color ffffff}${goto 32}${template1 Jour_ProbPrec 2}%${goto 82}${template1 Jour_ProbPrec 3}%${goto 132}${template1 Jour_ProbPrec 4}%${goto 182}${template1 Jour_ProbPrec 5}%
##### Affichage temperature #####
${voffset 18}${goto 8}${font caviar dreams:bold:size=7}${color a5cb92}${template1 Nuit_Temp 2}°/${template1 Jour_Temp 2}°${goto 58}${template1 Nuit_Temp 3}°/${template1 Jour_Temp 3}°${goto 108}${template1 Nuit_Temp 4}°/${template1 Jour_Temp 4}°${goto 158}${template1 Nuit_Temp 5}°/${template1 Jour_Temp 5}°
##### Affichage vitesse du vent #####
${voffset 22}${font caviar dreams:bold:size=7}${color ffffff}${goto 9}${template1 Jour_VentForce 2}${font caviar dreams:bold:size=5} km/h${goto 59}${voffset -2}${font caviar dreams:bold:size=7}${template1 Jour_VentForce 3}${font caviar dreams:bold:size=5} km/h${goto 109}${voffset -2}${font caviar dreams:bold:size=7}${template1 Jour_VentForce 4}${font caviar dreams:bold:size=5} km/h${goto 159}${voffset -2}${font caviar dreams:bold:size=7}${template1 Jour_VentForce 5}${font caviar dreams:bold:size=5} km/h
#### quatrième cadre ####
##### Heure mise à jour #####
${voffset 30}${alignc}${font caviar dreams:bold:size=7}${color a5cb92}MàJ :
${alignc}${color ffffff}${template1 Heure}h${template1 Minute}
#### Affichage des cadres utilisés dans le conky ####
#### icônes premier cadre ####
${template2 IconeM ~/.conky/conky-meteo/meteo_lua_2/icones 67,571 66x40}
${template2 IconeV ~/.conky/conky-meteo/meteo_lua_2/icones/vent 114,528 28x28}
#### icônes Second cadre ####
${template2 AM_IconeM ~/.conky/conky-meteo/meteo_lua_2/icones 23,610 66x40 1}
${template2 Noct_IconeM ~/.conky/conky-meteo/meteo_lua_2/icones 113,610 66x40 1}
${image /tmp/lune.png -p 85,635 -s 30x30 -f 60}
#### fond troisième cadre ####
${template0 base.png 0,684 200x115}
#### icônes troisième cadre ####
${template2 AM_IconeM ~/.conky/conky-meteo/meteo_lua_2/icones 4,707 43x26 2}
${template2 AM_IconeM ~/.conky/conky-meteo/meteo_lua_2/icones 54,707 43x26 3}
${template2 AM_IconeM ~/.conky/conky-meteo/meteo_lua_2/icones 104,707 43x26 4}
${template2 AM_IconeM ~/.conky/conky-meteo/meteo_lua_2/icones 154,707 43x26 5}
${template2 Noct_IconeM ~/.conky/conky-meteo/meteo_lua_2/icones 4,740 43x26 2}
${template2 Noct_IconeM ~/.conky/conky-meteo/meteo_lua_2/icones 54,740 43x26 3}
${template2 Noct_IconeM ~/.conky/conky-meteo/meteo_lua_2/icones 104,740 43x26 4}
${template2 Noct_IconeM ~/.conky/conky-meteo/meteo_lua_2/icones 154,740 43x26 5}
${template2 Jour_IconeR ~/.conky/conky-meteo/meteo_lua_2/icones/vent 14,774 22x22 2}
${template2 Jour_IconeR ~/.conky/conky-meteo/meteo_lua_2/icones/vent 64,774 22x22 3}
${template2 Jour_IconeR ~/.conky/conky-meteo/meteo_lua_2/icones/vent 114,774 22x22 4}
${template2 Jour_IconeR ~/.conky/conky-meteo/meteo_lua_2/icones/vent 164,774 22x22 5}
# Krostons #
${image ~/.conky/Kroston_01.png -p 20,793 -s 63x71}${image ~/.conky/Kroston_02.png -p 0,178 -s 68x71}${image ~/.conky/Kroston_03.png -p 141,390 -s 59x75}
Les deux dernières lignes (pour l'insertion des Krostons) peuvent être supprimées sans problème...
Voili, voilà pour ma modeste contribution (ce post a été modifié le 21 mars pour tenir compte des modifications apportées par Didier-T sur le conky meteo2.lua).
Cordialement