Δημοσιεύτηκε: 18 Απρ 2015, 11:34
από fog
@ taxiarchis Πολύ ωραίο, κάποια στιγμή πρέπει να δοκιμάσω τα bars, δεν τα έχω χρησιμοποιήσει μέχρι τώρα.

Ένα παλιότερο conky που χρησιμοποιεί σχεδόν όλη την επιφάνεια εργασίας, χειμωνιάτικο, βασισμένο στα -πολύ όμορφα- lua rings και cairo clock της Alison Pitt. Οι αλλαγές στις αρχικές ρυθμίσεις είναι η προσαρμογή σε οθόνη 1366x768, η προσθήκη ενός τρίτου conky που δείχνει το τραγούδι που παίζει στο exaile και η προσθήκη 2 ακόμη rings, μιας και υπήρχε χώρος στην οθόνη μου, για τη θερμοκρασία και το σήμα του wifi.



Τα αρχεία που το αποτελούν είναι:

clock.lua:

Spoiler: show
--[[
Air Clock by Alison Pitt (2009)

This clock is designed to look like KDE 4.3's "Air" clock, but from inside Conky.

You can adjust the clock's radius and placement, as well as the size and offset of the drop shadow. You can also choose whether to display the seconds hand. This clock updates every time Conky does, so if you want to show seconds, it is recommended that you set update_interval to no more than 0.5s. If you turn off seconds, you can set the update_interval to as long as 30s. The settings are in the "Settings" section, starting at Line 21.

Call this script in Conky using the following before TEXT (assuming you save this script to ~/scripts/clock.lua):
lua_load ~/scripts/clock.lua
lua_draw_hook_pre draw_clock
]]

require 'cairo'
function conky_draw_clock()
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)

-- Settings

-- What radius should the clock face (not including border) be, in pixels?

local clock_r=75

-- x and y coordinates, relative to the top left corner of Conky, in pixels

local xc=w/6
local yc=h/2

-- Extent of the shadow, in pixels

shadow_width=5

-- x and y offsets of the drop shadow, relative to the centre of the clock face, in pixels. Can be positive (downward) or negative (upward)

shadow_xoffset=0
shadow_yoffset=2

-- Do you want to show the second hand? Use this if you use a Conky update_interval > 1s. Can be true or false.

show_seconds=true

-- Grab time

local hours=os.date("%I")
local mins=os.date("%M")
local secs=os.date("%S")

secs_arc=(2*math.pi/60)*secs
mins_arc=(2*math.pi/60)*mins
hours_arc=(2*math.pi/12)*hours+mins_arc/12

-- Drop shadow

local ds_pat=cairo_pattern_create_radial(xc+shadow_xoffset,yc+shadow_yoffset,clock_r*1.25,xc+shadow_xoffset,yc+shadow_yoffset,clock_r*1.25+shadow_width)
cairo_pattern_add_color_stop_rgba(ds_pat,0,0,0,0,0.2)
cairo_pattern_add_color_stop_rgba(ds_pat,1,0,0,0,0)

cairo_move_to(cr,0,0)
cairo_line_to(cr,w,0)
cairo_line_to(cr,w,h)
cairo_line_to(cr,0,h)
cairo_new_sub_path(cr)
cairo_arc(cr,xc,yc,clock_r*1.25,0,2*math.pi)
cairo_set_source(cr,ds_pat)
cairo_set_fill_rule(cr,CAIRO_FILL_RULE_EVEN_ODD)
cairo_fill(cr)

-- Glassy border

cairo_arc(cr,xc,yc,clock_r*1.25,0,2*math.pi)
cairo_set_source_rgba(cr,0.5,0.5,0.5,0.2)
cairo_set_line_width(cr,1)
cairo_stroke(cr)

local border_pat=cairo_pattern_create_linear(xc,yc-clock_r*1.25,xc,yc+clock_r*1.25)

cairo_pattern_add_color_stop_rgba(border_pat,0,1,1,1,0.7)
cairo_pattern_add_color_stop_rgba(border_pat,0.3,1,1,1,0)
cairo_pattern_add_color_stop_rgba(border_pat,0.5,1,1,1,0)
cairo_pattern_add_color_stop_rgba(border_pat,0.7,1,1,1,0)
cairo_pattern_add_color_stop_rgba(border_pat,1,1,1,1,0.7)
cairo_set_source(cr,border_pat)
cairo_arc(cr,xc,yc,clock_r*1.125,0,2*math.pi)
cairo_close_path(cr)
cairo_set_line_width(cr,clock_r*0.25)
cairo_stroke(cr)

-- Set clock face

cairo_arc(cr,xc,yc,clock_r,0,2*math.pi)
cairo_close_path(cr)

local face_pat=cairo_pattern_create_radial(xc,yc-clock_r*0.75,0,xc,yc,clock_r)

cairo_pattern_add_color_stop_rgba(face_pat,0,1,1,1,0.5)
cairo_pattern_add_color_stop_rgba(face_pat,0.5,1,1,1,0.5)
cairo_pattern_add_color_stop_rgba(face_pat,1,0.9,0.9,0.9,0.5)
cairo_set_source(cr,face_pat)
cairo_fill_preserve(cr)
cairo_set_source_rgba(cr,0.5,0.5,0.5,0.2)
cairo_set_line_width(cr, 1)
cairo_stroke (cr)

-- 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,0,0,0,0.5)
cairo_stroke(cr)

-- Draw minute hand

xm=xc+0.9*clock_r*math.sin(mins_arc)
ym=yc-0.9*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+0.9*clock_r*math.sin(secs_arc)
ys=yc-0.9*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


conky_widgets.lua:

Spoiler: show
--[[
Conky Widgets by londonali1010 (2009)

This script is meant to be a "shell" to hold a suite of widgets for use in Conky.

To configure:
+ Copy the widget's code block (will be framed by --(( WIDGET NAME )) and --(( END WIDGET NAME )), with "[" instead of "(") somewhere between "require 'cairo'" and "function conky_widgets()", ensuring not to paste into another widget's code block
+ To call the widget, add the following just before the last "end" of the entire script:
cr = cairo_create(cs)
NAME_OF_FUNCTION(cr, OPTIONS)
cairo_destroy(cr)
+ Replace OPTIONS with the options for your widget (should be specified in the widget's code block)

Call this script in Conky using the following before TEXT (assuming you save this script to ~/scripts/conky_widgets.lua):
lua_load ~/scripts/conky_widgets.lua
lua_draw_hook_pre widgets

Changelog:
+ v1.0 -- Original release (17.10.2009)
]]

require 'cairo'

--[[ RING WIDGET ]]
--[[ Options (name, arg, max, bg_colour, bg_alpha, xc, yc, radius, thickness, start_angle, end_angle):
"name" is the type of stat to display; you can choose from 'cpu', 'memperc', 'fs_used_perc', 'battery_used_perc'.
"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 ''.
"max" is the maximum value of the ring. If the Conky variable outputs a percentage, use 100.
"bg_colour" is the colour of the base ring.
"bg_alpha" is the alpha value of the base ring.
"fg_colour" is the colour of the indicator part of the ring.
"fg_alpha" is the alpha value of the indicator part of the ring.
"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.
"radius" is the radius of the ring.
"thickness" is the thickness of the ring, centred around the radius.
"start_angle" is the starting angle of the ring, in degrees, clockwise from top. Value can be either positive or negative.
"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 (e.g. more clockwise) than start_angle. ]]

function ring(cr, name, arg, max, bgc, bga, fgc, fga, xc, yc, r, t, sa, ea)
local function rgb_to_r_g_b(colour,alpha)
return ((colour / 0x10000) % 0x100) / 255., ((colour / 0x100) % 0x100) / 255., (colour % 0x100) / 255., alpha
end

-- left rings filled from the bottom
-- local function draw_ring(pct)
-- local angle_0=sa*(2*math.pi/360)-math.pi/2
-- local angle_f=ea*(2*math.pi/360)-math.pi/2
-- local pct_arc=pct*(angle_f-angle_0)

-- Draw background ring

-- cairo_arc(cr,xc,yc,r,angle_0,angle_f)
-- cairo_set_source_rgba(cr,rgb_to_r_g_b(bgc,bga))
-- cairo_set_line_width(cr,t)
-- cairo_stroke(cr)

-- Draw indicator ring

-- cairo_arc(cr,xc,yc,r,angle_0,angle_0+pct_arc)
-- cairo_set_source_rgba(cr,rgb_to_r_g_b(fgc,fga))
-- cairo_stroke(cr)
-- end

--left rings fillem from the top
local function draw_ring(pct)
local angle_0= sa * (math.pi / 180) - math.pi/2
local angle_f= ea * (math.pi / 180) - math.pi/2
local pct_arc= pct * (angle_f - angle_0)

-- Draw background ring

cairo_arc(cr,xc,yc,r,angle_0,angle_f)
cairo_set_source_rgba(cr,rgb_to_r_g_b(bgc,bga))
cairo_set_line_width(cr,t)
cairo_stroke(cr)

-- Draw indicator ring

if sa == 0 then
cairo_arc(cr,xc,yc,r,angle_0,angle_0+pct_arc)
else
cairo_arc_negative(cr,xc,yc,r,angle_0-math.pi,angle_0-math.pi-pct_arc)
end
cairo_set_source_rgba(cr,rgb_to_r_g_b(fgc,fga))
cairo_stroke(cr)
end

local function setup_ring()
local str = ''
local value = 0

str = string.format('${%s %s}', name, arg)
str = conky_parse(str)
if name == "wireless_bitrate" then
value = tonumber(string.sub(str,0,-6))
else
value = tonumber(str)
end -- if name == "wireless_bitrate"

if value == nil then value = 0 end
pct = value/max

draw_ring(pct)
end

local updates=conky_parse('${updates}')
update_num=tonumber(updates)

if update_num>5 then setup_ring() end
end

--[[ END RING WIDGET ]]

function conky_widgets()
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)
-- air_clock(cr, 120, 120, 200) -- options: xc, yc, size
-- cairo_destroy(cr)

cr = cairo_create(cs)
ring(cr, 'cpu', 'CPU0', 100, 0xFFFFFF, 0.2, 0xFFFFFF, 0.5, 220, 100, 50, 10, 0, 180) -- options: name, arg, max, bg_colour, bg_alpha, fg_colour, fg_alpha, xc, yc, radius, thickness, start_angle, end_angle
cairo_destroy(cr)

cr = cairo_create(cs)
ring(cr, 'memperc', '', 100, 0xFFFFFF, 0.2, 0xFFFFFF, 0.5, 220, 200, 50, 10, 180, 360) -- options: name, arg, max, bg_colour, bg_alpha, fg_colour, fg_alpha, xc, yc, radius, thickness, start_angle, end_angle
cairo_destroy(cr)

cr = cairo_create(cs)
ring(cr, 'fs_used_perc', '/', 100, 0xFFFFFF, 0.2, 0xFFFFFF, 0.5, 220, 300, 50, 10, 0, 180) -- options: name, arg, max, bg_colour, bg_alpha, fg_colour, fg_alpha, xc, yc, radius, thickness, start_angle, end_angle
cairo_destroy(cr)

cr = cairo_create(cs)
ring(cr, 'battery_percent', 'BAT1', 100, 0xFFFFFF, 0.2, 0xFFFFFF, 0.5, 220, 400, 50, 10, 180, 360) -- options: name, arg, max, bg_colour, bg_alpha, fg_colour, fg_alpha, xc, yc, radius, thickness, start_angle, end_angle
cairo_destroy(cr)

cr = cairo_create(cs)
ring(cr, 'acpitemp', '', 100, 0xFFFFFF, 0.2, 0xFFFFFF, 0.5, 220, 500, 50, 10, 0, 180) -- options: name, arg, max, bg_colour, bg_alpha, fg_colour, fg_alpha, xc, yc, radius, thickness, start_angle, end_angle
cairo_destroy(cr)

cr = cairo_create(cs)
ring(cr, 'wireless_link_qual_perc', 'wlan0', 100, 0xFFFFFF, 0.2, 0xFFFFFF, 0.5, 220, 600, 50, 10, 180, 360) -- options: name, arg, max, bg_colour, bg_alpha, fg_colour, fg_alpha, xc, yc, radius, thickness, start_angle, end_angle
cairo_destroy(cr)
end


AirRings:

Spoiler: show
#Screenshot: http://irenegr.wordpress.com/2012/12/18 ... onk-woman/
# -- 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
imlib_cache_size 0

# -- 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 300 750
maximum_width 300

alignment tr
gap_x 5
gap_y 60

# -- Graphics settings -- #
draw_shades no
draw_outline no
draw_borders no
draw_graph_borders no

# -- Text settings -- #
use_xft yes
xftfont Sans:size=12
xftalpha 0.7

uppercase no

default_color gray75

# -- Lua Load -- #
lua_load ~/.conky/air_clock/conky_widgets.lua
lua_draw_hook_pre widgets

TEXT

${goto 180}${voffset 70}CPU ${cpu}%
${alignr 30}${voffset 80}MEM ${memperc}%
${goto 180}${voffset 80}HDD ${fs_used_perc /}%
${alignr 30}${voffset 80}BAT ${battery_percent BAT1}%
${goto 180}${voffset 80}TMP ${acpitemp}°C
${alignr 30}${voffset 80}SGN ${wireless_link_qual_perc wlan0}%


Clock:

Spoiler: show
background yes
update_interval 1

cpu_avg_samples 2
net_avg_samples 2
temperature_unit celsius

double_buffer yes
no_buffers yes
text_buffer_size 2048

gap_x 60 #left-right
gap_y 50
minimum_size 750 200
maximum_width 850
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
alignment tl

draw_shades no
draw_outline no
draw_borders no
draw_graph_borders no

override_utf8_locale yes
use_xft yes
xftfont Santana:size=8
xftalpha 0.8
uppercase no



lua_load ~/.conky/air_clock/clock.lua
lua_draw_hook_pre draw_clock

##############################################
# Output
##############################################
default_color grey75
TEXT


${goto 230}${voffset 32}${font Santana:size=28}${time %A, %d %B %Y}
${goto 230}${voffset -20}${hr 2}


Exaile:

Spoiler: show
alignment top_left
background no
#border_margin 5
border_width 5
default_color d7d7d7
double_buffer yes
draw_borders no
draw_graph_borders no
draw_outline no
draw_shades no
gap_x 300
gap_y 160
maximum_width 1100
minimum_size 40
no_buffers yes
override_utf8_locale yes
own_window yes
own_window_title normal
own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager
own_window_transparent yes
own_window_type normal ## normal /override /desktop
text_buffer_size 8000
total_run_times 0
update_interval 1
uppercase no
use_xft yes
xftalpha 0.9
xftfont Santana:size=12
default_color grey90

TEXT
${execi 10 exaile --get-title} - ${execi 10 exaile --get-artist} / ${execi 10 exaile --get-album}


Φροντίζουμε όπου υπάρχουν διαδρομές αρχείων να ανταποκρίνονται στις διαδρομές που τα έχουμε αποθηκεύσει. Για να τα ξεκινήσουμε όλα μαζί φτιάχνουμε ένα script όπως το παρακάτω και το βάζουμε στις start up εφαρμογές:

Spoiler: show
sleep 1 &&
conky -d -c /home/fog/.conky/air_clock/AirRings &
sleep 1 &&
conky -d -c /home/fog/.conky/air_clock/Clock &
sleep 2 &&
conky -d -c /home/fog/.conky/air_clock/Exaile &