ubuntuusers.de

Conky - lua Script laden

Status: Ungelöst | Ubuntu-Version: Ubuntu 9.10 (Karmic Koala)
Antworten |

Za

Anmeldungsdatum:
30. November 2009

Beiträge: 48

Halli hallo, ich versuche momentan ein tolles lua script mit conky zu laden, allerdings klappt es irgendwie nicht ;(

http://londonali1010.deviantart.com/art/Clock-Hands-Widget-141966282 Uhrzeiger lua Skript

dazu benötigt man wohl, soweit ich es verstanden habe http://londonali1010.deviantart.com/art/Conky-Widgets-Script-141963883 dieses skript bin nun wie in der Anleitung angegeben vorgegangen und hab mir zuerst mal mein conky_widgets.lua skript zusammengebaut

--[[
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'
--[[ CLOCK HANDS WIDGET ]]
--[[ Options (xc, yc, colour, alpha, show_secs, size):
	"xc" and "yc" are the x and y coordinates of the centre of the clock hands, in pixels, relative to the top left corner of the Conky window
	"colour" is the colour of the clock hands, in OxFFFFFF formate
	"alpha" is the alpha of the hands, between 0 and 1
	"show_secs" is a boolean; set to TRUE to show the seconds hand, otherwise set to FALSE
	"size" is the total size of the widget (e.g. twice the length of the minutes hand), in pixels ]]

function clock_hands(cr, xc, yc, colour, alpha, show_secs, size)
	local function rgb_to_r_g_b(colour,alpha)
		return ((colour / 0x10000) % 0x100) / 255., ((colour / 0x100) % 0x100) / 255., (colour % 0x100) / 255., alpha
	end
	
	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

	xh=xc+0.4*size*math.sin(hours_arc)
	yh=yc-0.4*size*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(colour,alpha))
	cairo_stroke(cr)

	xm=xc+0.5*size*math.sin(mins_arc)
	ym=yc-0.5*size*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)

	if show_secs then
		xs=xc+0.5*size*math.sin(secs_arc)
		ys=yc-0.5*size*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 CLOCK HANDS 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)
	clock_hands(cr, 100,100,OxFFFFFF,1,true,20)
	cairo_destroy(cr)
end

Und nun kommt mein Problem. Bei mir fehlte die conky.rc im homeverzeichnis deshalb hab ich mir einfach mal die Version aus dem wiki gezogen. Welche auch einwandfrei startet. Nun soll ich ja vor dem TEXT teil

lua_load ~/scripts/conky_widgets.lua
	lua_draw_hook_pre widgets

einfügen.

background yes
use_xft yes
xftfont Bitstream Vera Sans Mono:size=9
xftalpha 0.8
update_interval 1.0
total_run_times 0
own_window yes
own_window_type normal
own_window_transparent yes
own_window_colour black
own_window_hints undecorated,skip_pager,skip_taskbar
double_buffer yes
minimum_size 260 5
draw_shades no
draw_outline no
draw_borders no
draw_graph_borders no
stippled_borders 0
border_margin 4
border_width 0
default_color white
default_shade_color black
default_outline_color black
alignment top_left
gap_x 12
gap_y 12
no_buffers yes
uppercase no
cpu_avg_samples 1
net_avg_samples 1
override_utf8_locale no
use_spacer yes
mpd_host localhost
mpd_portPort 6060
#mpd_password 
lua_load ~/scripts/conky_widgets.lua
lua_draw_hook_pre widgets
TEXT
${font Verdana:style=Bold:size=16}${color #009bf9}${alignc}${time %a %d. %b %k:%M}
$font$color${alignc}Feisty Fawn $kernel
${color #009bf9}$stippled_hr
${color lightgrey}Processes:$color $processes  ${color grey}Running:$color $running_processes ${color lightgrey}Up:$color $uptime

${color #009bf9}CPU: $cpu% ${cpubar}
${color}Name              PID     CPU%   MEM%
${font Monospace:size=8}${color lightgrey}${top name 1}     ${top pid 1}  ${top cpu 1}  ${top mem 1}
${color lightgrey}${top name 2}     ${top pid 2}  ${top cpu 2}  ${top mem 2}
${color lightgrey}${top name 3}     ${top pid 3}  ${top cpu 3}  ${top mem 3}
${cpugraph 48,300 009bf9 ffffff}

$font${color #009bf9}RAM: $mem/$memmax - $memperc% ${membar}
${color lightgrey}Swap: $swap/$swapmax - $swapperc% ${swapbar}
${color}Name              PID     CPU%   MEM%
${font Monospace:size=8}${color lightgrey}${top_mem name 1}     ${top_mem pid 1}  ${top_mem cpu 1}  ${top_mem mem 1}
${color lightgrey}${top_mem name 2}     ${top_mem pid 2}  ${top_mem cpu 2}  ${top_mem mem 2}
${color lightgrey}${top_mem name 3}     ${top_mem pid 3}  ${top_mem cpu 3}  ${top_mem mem 3}


$font${color #009bf9}Connections${alignr}${color #009bf9}In:$color ${tcp_portmon 1 32767 count}  ${color #009bf9}Out:$color ${tcp_portmon 32768 61000 count}   ${color #009bf9}ALL:$color ${tcp_portmon 1 65535 count}
${color lightgrey}$stippled_hr
${color lightgrey}Down:$color ${downspeed eth0} k/s${color lightgrey} ${offset 80}Up:$color ${upspeed eth0} k/s
${downspeedgraph eth0 32,120 009bf9 ffffff} ${offset 40} ${upspeedgraph eth0 32,120 009bf9 ffffff}
${color #009bf9}IPs:$color ${addr eth0} ${offset 20} ${execi 7200 ~/.conky/publicip.sh}
${color lightgrey}$stippled_hr
${color #009bf9}Inbound Connection ${alignr} Local Service/Port$color
${font Monospace:size=8} ${tcp_portmon 1 32767 rhost 0} ${alignr} ${tcp_portmon 1 32767 lservice 0}
 ${tcp_portmon 1 32767 rhost 1} ${alignr} ${tcp_portmon 1 32767 lservice 1}
 ${tcp_portmon 1 32767 rhost 2} ${alignr} ${tcp_portmon 1 32767 lservice 2}
 ${tcp_portmon 1 32767 rhost 3} ${alignr} ${tcp_portmon 1 32767 lservice 3}
 ${tcp_portmon 1 32767 rhost 4} ${alignr} ${tcp_portmon 1 32767 lservice 4}
 ${tcp_portmon 1 32767 rhost 5} ${alignr} ${tcp_portmon 1 32767 lservice 5}
$font${color #009bf9}Outbound Connection ${alignr} Remote Service/Port$color
${font Monospace:size=8} ${tcp_portmon 32768 61000 rhost 0} ${alignr} ${tcp_portmon 32768 61000 rservice 0}
 ${tcp_portmon 32768 61000 rhost 1} ${alignr} ${tcp_portmon 32768 61000 rservice 1}
 ${tcp_portmon 32768 61000 rhost 2} ${alignr} ${tcp_portmon 32768 61000 rservice 2}
 ${tcp_portmon 32768 61000 rhost 3} ${alignr} ${tcp_portmon 32768 61000 rservice 3}
 ${tcp_portmon 32768 61000 rhost 4} ${alignr} ${tcp_portmon 32768 61000 rservice 4}
 ${tcp_portmon 32768 61000 rhost 5} ${alignr} ${tcp_portmon 32768 61000 rservice 5}
$font${color #009bf9}$stippled_hr
${color lightgrey}hda:  ${fs_used /}/${fs_size /}  ${fs_bar /}
${color lightgrey}sda: ${fs_used /media/big}/${fs_size /media/big} ${fs_bar /media/big}
${font Monospace:size=8}${color lightgrey}usb:  ${fs_used /media/disk}/${fs_size /media/disk}  ${color lightgrey}${alignr}usb-1:  ${fs_used /media/disk-1}/${fs_size /media/disk-1}

ist dann die neue conky.rc Allerdings lädt conky dann nur das Beispiel, nicht aber das lua skript. Was mache ich verkehrt? Und schmeißt mir diesen fehler aus

lua_do_call: function conky_widgets execution failed: /home/sascha/scripts/conky_widgets.lua:47: attempt to perform arithmetic on local 'size' (a nil value)

Grüße und schonmal ein riesen Danke im vorraus 😉 Za

3lement4ry

Avatar von 3lement4ry

Anmeldungsdatum:
1. November 2009

Beiträge: Zähle...

tipp mal conky -v in die Shell und such dir oben den Pfad zu der conky.conf rauß. Dann gehst du in diese config und setzt vor TEXT noch diese beiden Zeilen ein (sofern das lua script eben in ~/scripts liegt):

	lua_load ~/scripts/conky_widgets.lua
	lua_draw_hook_pre widgets

das ganze speichern und conky starten ☺

Za

(Themenstarter)

Anmeldungsdatum:
30. November 2009

Beiträge: 48

leider bleibt der fehler weiterhin bestehen ☹

DrXXXunic

Anmeldungsdatum:
2. März 2020

Beiträge: Zähle...

Bei mir das selbe Problem. Habe conky angelegt und die lua File. Die conky lädt und funktioniert aber die lua lädt nicht. Raspberrypi 4b und Debian buster.

Antworten |