Bem-vindo: Sex, 22 de Novembro 2024, 23:33 Pesquisa avançada
--[[
Ring Meters by londonali1010 (2009)
This script draws percentage meters as rings. It is fully customisable; all options are described in the 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/rings-v1.2.1.lua
lua_draw_hook_pre ring_stats
Changelog:
+ v1.2.1 -- Fixed minor bug that caused script to crash if conky_parse() returns a nil value (20.10.2009)
+ v1.2 -- Added option for the ending angle of the rings (07.10.2009)
+ v1.1 -- Added options for the starting angle of the rings, and added the "max" variable, to allow for variables that output a numerical value rather than a percentage (29.09.2009)
+ v1.0 -- Original release (28.09.2009)
]]
settings_table = {
{
name='cpu',
arg='cpu0',
max=100,
bg_colour=0xffffff,
bg_alpha=0.0,
fg_colour=0x660099,
fg_alpha=1.0,
x=35, y=35,
radius=29,
thickness=7,
start_angle=0,
end_angle=360
},
{
name='hwmon',
arg='temp 1',
max=100,
bg_colour=0xffffff,
bg_alpha=0.0,
fg_colour=0xFF00D9,
fg_alpha=1.0,
x=35, y=135,
radius=29,
thickness=7,
start_angle=0,
end_angle=360
},
{
name='memperc',
arg='',
max=100,
bg_colour=0xffffff,
bg_alpha=0.0,
fg_colour=0x47B13E,
fg_alpha=1.0,
x=35, y=235,
radius=29,
thickness=7,
start_angle=0,
end_angle=360
},
{
name='upspeedf',
--arg='eth0',
arg='wlan0',
max=33,
bg_colour=0xffffff,
bg_alpha=0.0,
fg_colour=0xFF9401,
fg_alpha=1.0,
x=35, y=335,
radius=29,
thickness=7,
start_angle=0,
end_angle=360
},
{
name='downspeedf',
--arg='eth0',
arg='wlan0',
max=65,
bg_colour=0xffffff,
bg_alpha=0.0,
fg_colour=0x6948FF,
fg_alpha=1.0,
x=35, y=435,
radius=29,
thickness=7,
start_angle=0,
end_angle=360
},
{
name='fs_used_perc',
arg='/',
max=100,
bg_colour=0xffffff,
bg_alpha=0.0,
fg_colour=0xFF2C34,
fg_alpha=1.0,
x=35, y=535,
radius=29,
thickness=7,
start_angle=0,
end_angle=360
},
{
name='fs_used_perc',
arg='/home',
max=100,
bg_colour=0xffffff,
bg_alpha=0.0,
fg_colour=0x996600,
fg_alpha=1.0,
x=35, y=635,
radius=29,
thickness=7,
start_angle=0,
end_angle=360
},
}
settings_t = {
}
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_ring_cc(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_negative(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_negative(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 conky_ring_stats()
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)
if value == nil then value = 0 end
pct=value/pt['max']
draw_ring(cr,pct,pt)
end
local function setup_rings_cc(cr,pt)
local str=''
local value=0
str=string.format('${%s %s}',pt['name'],pt['arg'])
str=conky_parse(str)
value=tonumber(str)
if value == nil then value = 0 end
pct=value/pt['max']
draw_ring_cc(cr,pct,pt)
end
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
for i in pairs(settings_t) do
setup_rings_cc(cr,settings_t[i])
end
end
end
require 'imlib2'
function init_drawing_surface()
imlib_set_cache_size(4096 * 1024)
imlib_context_set_dither(1)
end
function draw_image()
init_drawing_surface()
--you'll need to change the path here (keep it absolute!)
image = imlib_load_image(os.getenv("HOME") .."/.conky/conky.png")
if image == nil then return end
imlib_context_set_image(image)
imlib_render_image_on_drawable(0,0)
imlib_free_image()
end
function conky_start()
if conky_window == nil then return end
draw_image()
end
# -- Conky settings -- #
background yes
update_interval 1
cpu_avg_samples 2
net_avg_samples 2
override_utf8_locale yes
short_units 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 pie/ring-chart + text
border_inner_margin 0
border_outer_margin 0
minimum_size 70 700
alignment tr
gap_x 30
gap_y 160
# -- Graphics settings -- #
draw_shades no
draw_outline no
default_color cccccc
draw_borders no
draw_graph_borders no
use_xft yes
xftfont Aller:Bold:size=10
xftalpha 0.5
color2 000000
# -- Lua load -- #
lua_load ~/.conky/.lua.lua
lua_draw_hook_pre ring_stats
lua_draw_hook_post start
#at least one line (empty or not) after TEXT
TEXT
${color2}${goto 22}${voffset 27}CPU
${color2}${goto 19}${voffset 83}TEMP
${color2}${goto 22}${voffset 83}RAM
${color2}${goto 27}${voffset 83}UP
${color2}${goto 16}${voffset 83}DOWN
${color2}${goto 18}${voffset 83}ROOT
${color2}${goto 17}${voffset 83}HOME
Ainda não tem o Ubuntu instalado? Veja:
|
Dicas para melhorar o Ubuntu:
|
|
gap_x 30
gap_y 0
alignment middle_right
update_interval 1
use_xft yes
xftfont cantarell:size=7
own_window yes
own_window_type normal
own_window_transparent no
own_window_colour 000000
own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager
own_window_argb_visual yes
own_window_argb_value 128
double_buffer yes
draw_shades no
draw_graph_borders no
uppercase yes
default_bar_size 0 4
default_graph_size 0 12
border_inner_margin 10
default_color ccc
color0 fff
TEXT
${color0}${font cantarell:size=8:bold}system ${hr 2}${font}${color}
${alignc}'${nodename}'
${alignc}linux ${kernel}
${color0}${font cantarell:size=8:bold}processor ${hr 2}${font}${color}
${alignc}${exec lscpu | grep -i "model name" | cut -c 24-}
${alignc}${freq}MHz
${alignc}${processes} threads
cpu${alignr}${cpu cpu0}%
${cpugraph cpu0}
${cpubar cpu0}
${font cantarell:size=7:bold}cpu usage${alignr} %${font}
${top name 1}${alignr}${top cpu 1}
${top name 2}${alignr}${top cpu 2}
${top name 3}${alignr}${top cpu 3}
${top name 4}${alignr}${top cpu 4}
total${alignr}${cpu}%
${color0}${font cantarell:size=8:bold}memory ${hr 2}${font}${color}
${memgraph}
${membar}
${memperc}%
${font cantarell:size=7:bold}ram usage${alignr} %${font}
${top_mem name 1}${alignr}${top_mem mem 1}
${top_mem name 2}${alignr}${top_mem mem 2}
${top_mem name 3}${alignr}${top_mem mem 3}
${top_mem name 4}${alignr}${top_mem mem 4}
total${alignr}${memperc}%
${alignr}(${mem})
${color0}${font cantarell:size=8:bold}disks ${hr 2}${font}${color}
/${alignr}${fs_size /}
${fs_bar /}
${fs_used_perc /}%(${fs_used /})
/home${alignr}${fs_size /home}
${fs_bar /home}
${fs_used_perc /home}%(${fs_used /home})
${color0}${font cantarell:size=8:bold}network ${hr 2}${font}${color}
down ${downspeed wlan0}${alignr}up ${upspeed wlan0}
${downspeedgraph wlan0 32, 96}${alignr}${upspeedgraph wlan0 32, 96}
total ${totaldown wlan0}${alignr}total ${totalup wlan0}
Ainda não tem o Ubuntu instalado? Veja:
|
Dicas para melhorar o Ubuntu:
|
|
Ainda não tem o Ubuntu instalado? Veja:
|
Dicas para melhorar o Ubuntu:
|
|
# Use Xft?
use_xft yes
xftfont AvantGarde LT ExtraLight:bold:size=8
xftalpha 0.8
text_buffer_size 2048
# Update interval in seconds
update_interval 1
# This is the number of times Conky will update before quitting.
# Set to zero to run forever.
total_run_times 0
# Create own window instead of using desktop (required in nautilus)
own_window_class Conky
own_window yes
own_window_type normal
own_window_transparent yes
own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager
# Use double buffering (reduces flicker, may not work for everyone)
double_buffer yes
# Stippled borders?
stippled_borders 0
# border margins
border_inner_margin 0
border_outer_margin 0
border_width 0
border_margin 5
draw_outline no
draw_borders no
draw_shades no
draw_graph_borders no
# Text alignment, other possible values are commented
#alignment top_left
#alignment top_right
#alignment bottom_left
alignment top_right
# Gap between borders of screen and text
# same thing as passing -x at command line
gap_x 30
gap_y 35
default_color ffffff #4D4D4D
color0 333333 # discret color
color1 ffffff # comon color
color2 E65A07 # emphasis color
imlib_cache_size 0
minimum_size 350 350
maximum_width 1024
# -- Lua Load -- #
lua_load ~/.nsclock/.crings_ns.lua
lua_draw_hook_pre clock_rings
color1 6ED801 #green
color2 41A0FE #blue
color3 D76B00 #orange
color4 FF6F6F #pink
TEXT
${image ~/.nsclock/ring.png -p 45,45}
--[[
Clock Rings by londonali1010 (2009)
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 near the end of the script 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-v1.1.1.lua
lua_draw_hook_pre clock_rings
Changelog:
+ v1.1.1 -- Fixed minor bug that caused the script to crash if conky_parse() returns a nil value (20.10.2009)
+ v1.1 -- Added colour option for clock hands (07.10.2009)
+ v1.0 -- Original release (30.09.2009)
]]
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=0x000000,
-- "bg_alpha" is the alpha value of the base ring.
bg_alpha=0,
-- "fg_colour" is the colour of the indicator part of the ring.
fg_colour=0x000000,
-- "fg_alpha" is the alpha value of the indicator part of the ring.
fg_alpha=0,
-- "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=175, y=175,
-- "radius" is the radius of the ring.
radius=30,
-- "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,
fg_colour=0xffffff,
fg_alpha=0,
x=175, y=175,
radius=56,
thickness=5,
start_angle=0,
end_angle=360
},
{
name='time',
arg='%S',
max=60,
bg_colour=0x0000ff,
bg_alpha=0,
fg_colour=0x0000ff,
fg_alpha=0,
x=175, y=175,
radius=62,
thickness=5,
start_angle=0,
end_angle=360
},
}
-- Use these settings to define the origin and extent of your clock.
clock_r=125
-- "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=175
clock_y=175
-- Colour & alpha of the clock hands
clock_colour=0xffffff
clock_colourS=0x2A60B3
clock_alpha=0.9
-- Do you want to show the seconds hand?
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.5*clock_r*math.sin(hours_arc)
yh=yc-0.5*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,rgb_to_r_g_b(clock_colour,clock_alpha))
cairo_stroke(cr)
-- Draw minute hand
xm=xc+0.7*clock_r*math.sin(mins_arc)
ym=yc-0.7*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.6*clock_r*math.sin(secs_arc)
ys=yc-0.6*clock_r*math.cos(secs_arc)
cairo_move_to(cr,xc,yc)
cairo_line_to(cr,xs,ys)
cairo_set_source_rgba(cr,rgb_to_r_g_b(clock_colourS,clock_alpha))
cairo_set_line_width(cr,2)
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)
if value == nil then value = 0 end
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
#!/bin/bash
sleep 2 &&
conky -c ~/.nsclock/.conkyrc_ns
Ainda não tem o Ubuntu instalado? Veja:
|
Dicas para melhorar o Ubuntu:
|
|
Thiago Frazão (09-07-2013, 14:52) escreveu:Houve algo de errado, veja:
Como pode ver, os ponteiros não funcionam
lua_load ./.crings_ns.lua
lua_load ~/.nsclock/.crings_ns.lua
Ainda não tem o Ubuntu instalado? Veja:
|
Dicas para melhorar o Ubuntu:
|
|
Usuários navegando neste fórum: Nenhum usuário registrado e 11 visitantes