Linux MintThis forum is for the discussion of Linux Mint.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
--[[
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 between "cr = cairo_create(cs)" and "cairo_destroy(cr)" at the end of the script:
NAME_OF_FUNCTION(cr, OPTIONS)
+ 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.1 -- Simplified calls to widgets by implementing a global drawing surface, and included imlib2 by default (03.11.2009)
+ v1.0 -- Original release (17.10.2009)
]]
require 'cairo'
require 'imlib2'
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, xc, yc, size)
cairo_destroy(cr)
end
--[[ AIR CLOCK WIDGET ]]
--[[ Options (xc, yc, size):
"xc" and "yc" are the x and y coordinates of the centre of the clock, in pixels, relative to the top left of the Conky window
"size" is the total size of the widget, in pixels ]]
function air_clock(cr, xc, yc, size)
local offset = 0
shadow_width = size * 0.03
shadow_xoffset = 0
shadow_yoffset = size * 0.01
if shadow_xoffset >= shadow_yoffset then
offset = shadow_xoffset
else offset = shadow_yoffset
end
local clock_r = (size - 2 * offset) / (2 * 1.25)
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,conky_window.width,0)
cairo_line_to(cr,conky_window.width, conky_window.height)
cairo_line_to(cr,0,conky_window.height)
cairo_close_path(cr)
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.9)
cairo_pattern_add_color_stop_rgba(face_pat,0.5,1,1,1,0.9)
cairo_pattern_add_color_stop_rgba(face_pat,1,0.9,0.9,0.9,0.9)
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
--[[ END AIR CLOCK WIDGET ]]
the file is conky_widgets-v1.1.lua
i made a script folder in / and moved the file into it
then i put the following command
lua_load ~/scripts/conky_widgets.lua
at terminal and got
lua_load: command not found
---------------------------
what to now ?
Last edited by linuxwhacko; 03-01-2011 at 11:46 PM.
Reason: update
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.