Lua Scripts

I hate to post such a seemingly mundane question but I can't seem to find my answer anywhere. I've tried other forums and I've tried google. I was hoping there was a conky specific thread here but I couldn't find one so I posted here.
Anyway, I've been revamping my conky and I copy/pasted one I found online as a model for me to modify. It has circle graphs and a large analog clock so it obviously has lua scripts associated with it. The lua parts aren't showing up. To be safe I've made sure that lua is installed as well as all dependecies. I installed all conky dependencies too just for the hell of it. I've also made sure that I'm calling the lua scripts from the right directory, and yes, I've restarted conky many times. Here are the files:
Conky
# 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
temperature_unit fahrenheit
# Window specifications #
own_window yes
own_window_type override
own_window_transparent #000000
own_window_transparent yes
own_window_hints undecorate,sticky,skip_taskbar,skip_pager,below
border_inner_margin 0
border_outer_margin 5
minimum_size 250 300
maximum_width 250
alignment tr
gap_x 10
gap_y 0
# Graphics settings #
draw_shades no
draw_outline no
draw_borders no
draw_graph_borders yes
# Text settings #
use_xft yes
xftfont caviar dreams:size=8
xftalpha 0.5
uppercase no
temperature_unit celsius
default_color FFFFFF
# Lua Load #
lua_load ~/.openbox/conky/conky_blue/clock_rings.lua
lua_draw_hook_pre clock_rings
TEXT
# Time and date
${voffset 7}${font Radio Space:size=16}${color 0ABFFF}${time %A}${font}$color${font Radio Space:size=38}${goto 167}${voffset -8} ${time %e}${font}
${font Radio Space:size=18}${voffset -30}${time %b}${font}${voffset -3} ${font Radio Space:size=20}${time %Y}${font}${color 0ABFFF} ${hr 1}
# Battery Circle
${color FFFFFF}${goto 209}${voffset 34}${battery_percent}%
${color 0ABFFF}${goto 202}${voffset 25}Battery
# CPU usage
${color #0ABFFF}${hr 1}$color
${color #0ABFFF}${voffset 6}Temp: $color ${acpitemp}°C
${color #0ABFFF}${voffset 6}Processes:$color $processes
${color #0ABFFF}${voffset 6}Running: $color $running_processes${goto 116}${voffset 8}${cpu cpu0}% ${color 0ABFFF}${goto 116}${voffset 13}CPU1$color${goto 191}${voffset -12}${cpu cpu1}% ${color 0ABFFF}${goto 191}${voffset 12}CPU2$color
${color #0ABFFF}${voffset -12}FREQ:$color ${freq}MHz
${color #0ABFFF}${voffset 6}Load:$color ${loadavg}
# Network
${color 0ABFFF}${voffset 2}${hr 1}
${color 0ABFFF}essid: $color$alignr${wireless_essid wlan0}
${color 0ABFFF}wlan0: $color$alignr${addr wlan0}
${color 0ABFFF}Current: $color${alignr}${execi 10 /sbin/iwconfig wlan0|grep Rate|cut -d"M" -f1|cut -b20-24} Mbits/sec
${color 0ABFFF}eth0: $color$alignr${addr eth0}
${color #0ABFFF}Down: $color${downspeed wlan0} k/s ${alignr}${color #0ABFFF}Up:$color ${upspeed wlan0} k/s
${downspeedgraph wlan0 30,120 000000 0ABFFF} ${alignr}${upspeedgraph wlan0 30,120 000000 0ABFFF}$color
${color #0ABFFF}Total:$color ${totaldown wlan0} ${alignr}${color #0ABFFF}Total:$color ${totalup wlan0}
# DISK/RAM/SWAP usage
${color 0ABFFF}${voffset 2}${hr 1}
${color FFFFFF}${goto 7}${voffset 39}${fs_used_perc /}%
${color 0ABFFF}${goto 7}DISK
${color FFFFFF}${goto 102}${voffset -27}${memperc}%
${color 0ABFFF}${goto 102}RAM
# Running processes
${color 0ABFFF}${voffset 2} ${hr 1}
${color #0ABFFF}${voffset 5}NAME${goto 122}PID${goto 163}CPU%${goto 210}MEM%$color${voffset 5}
${top name 1}${goto 115}${top pid 1}${goto 160}${top cpu 1}${goto 205}${top mem 1}
${top name 2}${goto 115}${top pid 2}${goto 160}${top cpu 2}${goto 205}${top mem 2}
${top name 3}${goto 115}${top pid 3}${goto 160}${top cpu 3}${goto 205}${top mem 3}
${top name 4}${goto 115}${top pid 5}${goto 160}${top cpu 5}${goto 205}${top mem 5}
# Computer info
${color 0ABFFF}${voffset 2}${hr 1}${voffset 5}
${color 0ABFFF}Hostname:$color${alignr}${nodename}
${color 0ABFFF}OS:$color${alignr}${pre_exec cat /etc/issue.net} $machine
${color 0ABFFF}Kernel:$color${alignr}${kernel}$color
${color 0ABFFF}${font Radio Space:size=20}ARCH${color FFFFFF}LINUX
${color 0ABFFF}${voffset -10}${hr 1}
Lua
# Clock Rings by Linux Mint (2012) reEdited by Altin.
# 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 324 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 in your conkyrc:
# lua_load ~/.fluxbox/conky/conky_blue/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)
# * vX 2011mint --> reEdit despot77 (18.02.2011)
# * vX 2012 --> Altin reEdit (22.07.2012)
# * Added weather function (Accu Weather)
# * Added battery monitoring
# * Syslog monitoring
# * Running processes monitoring
# * Rearanged rings
# * Exctra network functions/monitoring
# * Changed Fonts
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.15,
-- "fg_colour" is the colour of the indicator part of the ring.
fg_colour=0x0ABFFF,
-- "fg_alpha" is the alpha value of the indicator part of the ring.
fg_alpha=0.3,
-- "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=175,
-- "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='battery_percent',
arg='',
max=100,
bg_colour=0xffffff,
bg_alpha=0.2,
fg_colour=0x0ABFFF,
fg_alpha=0.8,
x=222, y=110,
radius=27,
thickness=5,
start_angle=-90,
end_angle=270
name='time',
arg='%M.%S',
max=60,
bg_colour=0xffffff,
bg_alpha=0.1,
fg_colour=0x0ABFFF,
fg_alpha=0.4,
x=100, y=175,
radius=66,
thickness=5,
start_angle=0,
end_angle=360
name='time',
arg='%S',
max=60,
bg_colour=0xffffff,
bg_alpha=0.1,
fg_colour=0x0ABFFF,
fg_alpha=0.6,
x=100, y=175,
radius=72,
thickness=5,
start_angle=0,
end_angle=360
name='time',
arg='%d',
max=31,
bg_colour=0xffffff,
bg_alpha=0.1,
fg_colour=0x0ABFFF,
fg_alpha=0.8,
x=100, y=175,
radius=80,
thickness=5,
start_angle=-90,
end_angle=90
name='time',
arg='%m',
max=12,
bg_colour=0xffffff,
bg_alpha=0.1,
fg_colour=0x0ABFFF,
fg_alpha=1,
x=100, y=175,
radius=86,
thickness=5,
start_angle=-90,
end_angle=90
name='cpu',
arg='cpu0',
max=100,
bg_colour=0xffffff,
bg_alpha=0.3,
fg_colour=0x0ABFFF,
fg_alpha=0.8,
x=145, y=337,
radius=25,
thickness=5,
start_angle=-90,
end_angle=180
name='cpu',
arg='cpu1',
max=100,
bg_colour=0xffffff,
bg_alpha=0.3,
fg_colour=0x0ABFFF,
fg_alpha=0.8,
x=220, y=337,
radius=25,
thickness=5,
start_angle=-90,
end_angle=180
name='fs_used_perc',
arg='/',
max=100,
bg_colour=0xffffff,
bg_alpha=0.2,
fg_colour=0x0ABFFF,
fg_alpha=0.8,
x=35, y=590,
radius=25,
thickness=5,
start_angle=-90,
end_angle=180
name='memperc',
arg='',
max=100,
bg_colour=0xffffff,
bg_alpha=0.2,
fg_colour=0x0ABFFF,
fg_alpha=0.8,
x=130, y=590,
radius=25,
thickness=5,
start_angle=-90,
end_angle=180
name='swapperc',
arg='',
max=100,
bg_colour=0xffffff,
bg_alpha=0.2,
fg_colour=0x0ABFFF,
fg_alpha=0.8,
x=220, y=590,
radius=25,
thickness=5,
start_angle=-90,
end_angle=172
-- 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=175
show_seconds=true -- Change to true if you want the seconds hand
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 window_background(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.76*clock_r*math.sin(hours_arc)
yh=yc-0.72*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+0.98*clock_r*math.sin(mins_arc)
ym=yc-1.02*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+1.1*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
To be honest I'm not even sure what to look for. I'm not sure that it's a problem with the code because as I've said, I copy/pasted as a template for modifying. Thanks for reading.
EDIT: I've been starting conky from a different directory instead of starting it with ~/.conkyrc and I just copied the conky I'm using to ~/.conkyrc and killed/restarted it and noticed this error:
Conky: /home/'user'/.conkyrc: 53: no such configuration: 'lua_load'
Conky: /home/'user'/.conkyrc: 54: no such configuration: 'lua_draw_hook_pre'
cat: /etc/issue.net: No such file or directory
Conky: desktop window (c1) is root window
Conky: window type - override
Conky: drawing to created window (0x1000001)
Conky: drawing to double buffer
The top two lines seem to be the most relevant but I'm not sure what to do about it.
Last edited by xworld (2012-12-28 01:06:01)

::facepalm::
No I didn't. Although I just tried now and it failed. It said I needed toluapp before I could install conky-lua. The trouble is that when I try to install toluapp it fails. I looked in the AUR page and it shows that it's out of date. Is there a workaround for this?
EDIT: Here's the error if it helps.
==> Making package: toluapp 1.0.93-5 (Thu Dec 27 21:23:18 UTC 2012)
==> Checking runtime dependencies...
==> Checking buildtime dependencies...
==> Retrieving Sources...
-> Downloading tolua++-1.0.93.tar.bz2...
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 160k 100 160k 0 0 80172 0 0:00:02 0:00:02 --:--:-- 88576
-> Found config_linux.py
==> Validating source files with md5sums...
tolua++-1.0.93.tar.bz2 ... Passed
config_linux.py ... Passed
==> Extracting Sources...
-> Extracting tolua++-1.0.93.tar.bz2 with bsdtar
==> Starting build()...
scons: Reading SConscript files ...
scons: warning: The Options class is deprecated; use the Variables class instead.
File "/home/lucid/conf/pkgs/tmp/toluapp/src/tolua++-1.0.93/SConstruct", line 19, in <module>
('********* tolua is ', 'bin/tolua++_bootstrap')
scons: warning: The env.Copy() method is deprecated; use the env.Clone() method instead.
File "/home/lucid/conf/pkgs/tmp/toluapp/src/tolua++-1.0.93/src/tests/SCsub", line 2, in <module>
scons: done reading SConscript files.
scons: Building targets ...
gcc -o src/bin/tolua.o -c -O2 -ansi -Wall -fPIC -Iinclude src/bin/tolua.c
src/bin/tolua.c: In function 'add_extra':
src/bin/tolua.c:70:2: warning: implicit declaration of function 'luaL_getn' [-Wimplicit-function-declaration]
gcc -o src/bin/toluabind_default.o -c -O2 -ansi -Wall -fPIC -Iinclude src/bin/toluabind_default.c
gcc -o src/lib/tolua_event.o -c -O2 -ansi -Wall -fPIC -Iinclude src/lib/tolua_event.c
src/lib/tolua_event.c: In function 'storeatubox':
src/lib/tolua_event.c:26:3: warning: implicit declaration of function 'lua_getfenv' [-Wimplicit-function-declaration]
src/lib/tolua_event.c:31:4: warning: implicit declaration of function 'lua_setfenv' [-Wimplicit-function-declaration]
gcc -o src/lib/tolua_is.o -c -O2 -ansi -Wall -fPIC -Iinclude src/lib/tolua_is.c
gcc -o src/lib/tolua_map.o -c -O2 -ansi -Wall -fPIC -Iinclude src/lib/tolua_map.c
src/lib/tolua_map.c: In function 'tolua_bnd_setpeer':
src/lib/tolua_map.c:266:2: warning: implicit declaration of function 'lua_setfenv' [-Wimplicit-function-declaration]
src/lib/tolua_map.c: In function 'tolua_bnd_getpeer':
src/lib/tolua_map.c:274:2: warning: implicit declaration of function 'lua_getfenv' [-Wimplicit-function-declaration]
src/lib/tolua_map.c: In function 'tolua_usertype':
src/lib/tolua_map.c:398:2: warning: passing argument 2 of 'tolua_newmetatable' discards 'const' qualifier from pointer target type [enabled by default]
src/lib/tolua_map.c:28:12: note: expected 'char *' but argument is of type 'const char *'
src/lib/tolua_map.c: In function 'tolua_beginmodule':
src/lib/tolua_map.c:414:19: error: 'LUA_GLOBALSINDEX' undeclared (first use in this function)
src/lib/tolua_map.c:414:19: note: each undeclared identifier is reported only once for each function it appears in
src/lib/tolua_map.c: In function 'tolua_module':
src/lib/tolua_map.c:448:19: error: 'LUA_GLOBALSINDEX' undeclared (first use in this function)
src/lib/tolua_map.c: In function 'tolua_dobuffer':
src/lib/tolua_map.c:699:36: warning: value computed is not used [-Wunused-value]
scons: *** [src/lib/tolua_map.o] Error 1
scons: building terminated because of errors.
==> ERROR: A failure occurred in build().
Aborting...
Last edited by xworld (2012-12-28 03:24:41)

Similar Messages

  • Help with LUA script

    I need some help regarding the LUA scripting for the authentication of a vpn client. I am currently able to get the CN information from the certificate, but it comes in the form of last.first.middle.id#. what I need to do is write a script that isolates the id# which is a 10 digit number and then add a @mil to it. For instance if the certificate is returning ( smith.joe.chris.1111111111 ) I need to change that to 1111111111@mil. Thank you for your help in advance.

    So all of this is just to set the column widths to the sizes pre-defined in a paragraph style, i.e., always the same?
    I feel like I almost could do that in VB!
    But in Javascript, all it needs is sth in the ilk of
    var myWidths = [ 10, 50, 100, 50, 12 ]; // in whatever units you fancy
    var myTable = app.activeDocument.stories[0].tables[0];  // (just grabbing some table)
    for (i=0; i<myTable.columns.length; i++)
    myTable.columns[i].width = myWidths[i % myWidths.length];
    .. and the most interesting thing here (written from top of my head) is the "myWidths" lookup: it doesn't matter how many columns there are in this table, 'cause the widths array wraps around. (But you won't need this because you know all of your widths in advance.)

  • [SOLVED] Conky lua problem (transparency)

    Hi,
    I'm trying to transfer my conky from Ubuntu to Arch: below is a screenshot of the Ubuntu version (what it should look like).  On Arch I have a solid black background.   If it's relevant, I'm running Archbang rather than pure Arch, so with Openbox.
    My main issue at the moment is the semi-transparency (and I'd like to have the rounded corners too).   I understand that conky 1.8.0 can do transparency, but only with a compositor, and I'd rather keep my system as light as possible.  So I've replaced my conky with 1.7.2 conky-lua from AUR and (don't know if this was necessary) installed cairo and lua from the repos.   Unfortunately the lua script I used on Ubuntu isn't working; when I run conky in the terminal I get the message ".conkyrc: 121: config file error".  At lines 120 and 121 I have my
    lua_load ~/scripts/draw_bg.lua
            lua_draw_hook_pre
    My .conkyrc and lua script are below.  Thanks for looking!
    # conky configuration
    # edited by Mark Buck (Kaivalagi) <[email protected]>
    # set to yes if you want Conky to be forked in the background
    background no
    # X font when Xft is disabled, you can pick one with program xfontsel
    #font 5x7
    #font 6x10
    #font 7x13
    #font 8x13
    #font 9x15
    #font *mintsmild.se*
    #font -*-*-*-*-*-*-34-*-*-*-*-*-*-*
    # Use Xft?
    use_xft yes
    # Xft font when Xft is enabled
    xftfont Bitstream Vera Sans Mono:size=9
    # Text alpha when using Xft
    xftalpha 0.8
    # Update interval in seconds
    update_interval 1.0
    # This is the number of times Conky will update before quitting.
    # Set to zero to run forever.
    total_run_times 0
    # Use double buffering (reduces flicker, may not work for everyone)
    double_buffer yes
    # Minimum size of text area
    minimum_size 200 700
    maximum_width 200
    # Draw shades?
    draw_shades yes
    # Draw outlines?
    draw_outline no
    # Draw borders around text
    draw_borders no
    draw_graph_borders yes
    # Stippled borders?
    stippled_borders 8
    # border margins
    border_inner_margin 2
    border_outer_margin 2
    # border width
    border_width 1
    # Default colors and also border colors
    default_color white
    default_shade_color black
    default_outline_color white
    # own window options
    own_window yes
    own_window_type desktop
    #own_window_hints undecorated,skip_taskbar
    # Text alignment, other possible values are commented
    #alignment top_left
    alignment top_right
    #alignment bottom_left
    #alignment bottom_right
    # Gap between borders of screen and text
    # same thing as passing -x at command line
    gap_x 5
    gap_y 35
    # Subtract file system buffers from used memory?
    no_buffers yes
    # set to yes if you want all text to be in uppercase
    uppercase no
    # number of cpu samples to average
    # set to 1 to disable averaging
    cpu_avg_samples 2
    # number of net samples to average
    # set to 1 to disable averaging
    net_avg_samples 2
    # Force UTF8? note that UTF8 support required XFT
    override_utf8_locale yes
    # Add spaces to keep things from moving about? This only affects certain objects.
    use_spacer right
    # colours
    color1 white
    # light blue
    color2 6892C6
    color3 6892C6
    # green
    color4 78BF39
    # red
    color5 CC0000
    color6 88ff88
    text_buffer_size 2048
    # variable is given either in format $variable or in ${variable}. Latter
    # allows characters right after the variable and must be used in network
    # stuff because of an argument
    # stuff after 'TEXT' will be formatted on screen
    lua_load ~/scripts/draw_bg.lua
    lua_draw_hook_pre
    TEXT
    ${offset -5}${font StyleBats:style=CleanCut:size=12}q ${voffset -2}${font Bitstream Vera Sans Mono:style=Bold:size=11}Weather${font} ${hr}${color1}
    ${execpi 1800 conkyForecast --location=MZXX0003 --template=/home/mark/conky/conkyForecast.template}
    ${goto 25}${color1}${font Bitstream Vera Sans Mono:size=14}${execi 1800 conkyForecast --location=MZXX0003 --datatype=CT}${font}
    ${goto 20}${font ConkyWeather:style=Bold:size=30}${execi 1800 conkyForecast --location=MZXX0003 --datatype=WF} ${goto 120}${font ConkyWindNESW:size=30}${execi 1800 conkyForecast --location=MZXX0003 --datatype=BS}${font}
    ${goto 10}${execi 1800 conkyForecast --location=MZXX0003 --datatype=HT --centeredwidth=4}/${execi 1800 conkyForecast --location=MZXX0003 --datatype=LT --centeredwidth=4} ${goto 100}${execi 1800 conkyForecast --location=MZXX0003 --datatype=WS --imperial} - ${execi 1800 conkyForecast --location=MZXX0003 --datatype=WD}
    $if_mpd_playing${offset -5}${font StyleBats:style=CleanCut:size=12}q ${voffset -2}${font Bitstream Vera Sans Mono:style=Bold:size=11}Music${font} ${hr}${color1}
    ${font Bitstream Vera Sans:size=9}${color2}MPD:${color6} $mpd_status
    ${color}${texeci 10 /home/mark/conky/composer.sh}
    ${font Bitstream Vera Sans:size=9}$color$mpd_artist
    ${font Bitstream Vera Sans:size=9}$mpd_album
    ${font Bitstream Vera Sans:size=9}$mpd_title
    ${color #ccddff} ${mpd_bar 5, 100}
    $endif
    ${offset -5}${font StyleBats:style=CleanCut:size=12}q ${voffset -2}${font Bitstream Vera Sans Mono:style=Bold:size=11}${color1}System${font} ${hr}${color1}
    ${color2}CPU Temp: ${color}${acpitemp}${color}°${font Bitstream Vera Sans Mono:size=9}
    $color2}CPU1: $color${cpu cpu1}% ${cpubar cpu1 4,65}${font Bitstream Vera Sans Mono:size=9}
    $color2}CPU2: $color${cpu cpu2}% ${cpubar cpu2 4,65}${font Bitstream Vera Sans Mono:size=9}
    ${color2}RAM:$color $mem/$memmax
    ${color2}Root: $color${fs_used /}/${fs_size /}${font Bitstream Vera Sans Mono:size=9}
    ${color2}Home: $color${fs_used /home/}/${fs_size /home/}${font Bitstream Vera Sans Mono:size=9}
    ${color2}Today:${color6}${execi 10 vnstat -i eth0 | grep "today" | awk '{print $5 $6}'}${goto 120}${color1}${execi 10 vnstat -i eth0 | grep "today" | awk '{print $8 $9}'}
    ${color2}Week: ${color6}${execi 10 vnstat -i eth0 -w | grep "current week" | awk '{print $6 $7}'}${goto 120}${color1}${execi 10 vnstat -i eth0 -w | grep "current week" | awk '{print $9 $10}'}
    ${color2}Month: ${color6}${execi 10 vnstat -i eth0 -m | grep "`date +"%b '%y"`" | awk '{print $6 $7}'}${goto 120}${color1}${execi 10 vnstat -i eth0 -m | grep "`date +"%b '%y"`" | awk '{print $9 $10}'}${font}
    ${color2}Battery:$color ${color red}${battery_bar 4,50 BAT0}
    Background by londonali1010 (2009)
    This script draws a background to the Conky window. It covers the whole of the Conky window, but you can specify rounded corners, if you wish.
    To call this script in Conky, use (assuming you have saved this script to ~/scripts/):
    lua_load ~/scripts/draw_bg.lua
    lua_draw_hook_pre
    Changelog:
    + v1.0 -- Original release (07.10.2009)
    -- Change these settings to affect your background.
    -- "corner_r" is the radius, in pixels, of the rounded corners. If you don't want rounded corners, use 0.
    corner_r=15
    -- Set the colour and transparency (alpha) of your background.
    bg_colour=0x000000
    bg_alpha=0.4
    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 conky_draw_bg()
    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)
    cairo_move_to(cr,corner_r,0)
    cairo_line_to(cr,w-corner_r,0)
    cairo_curve_to(cr,w,0,w,0,w,corner_r)
    cairo_line_to(cr,w,h-corner_r)
    cairo_curve_to(cr,w,h,w,h,w-corner_r,h)
    cairo_line_to(cr,corner_r,h)
    cairo_curve_to(cr,0,h,0,h,0,h-corner_r)
    cairo_line_to(cr,0,corner_r)
    cairo_curve_to(cr,0,0,0,0,corner_r,0)
    cairo_close_path(cr)
    cairo_set_source_rgba(cr,rgb_to_r_g_b(bg_colour,bg_alpha))
    cairo_fill(cr)
    end
    Last edited by Henry Flower (2010-04-13 04:54:08)

    The error in line 121 is because of lua_draw_hook_pre command must have a function name. In your file, it would be:
    lua_draw_hook_pre draw_bg
    To get the transparency put the command:
    own_window_transparent yes
    I have tried this in an AwesomeWM, with conky 1.8.0 compiled with lua support, and without compositing.

  • Loading native code lua modules

    I'm trying to load a C lua module into my Lightroom Plugin. Unfortunately I can't get it to work and keep getting the error:
    An internal error occurred
    Could not load toolkit script: PluginGUI-OSX
    This is an Objective-C code lua library and the error occurs on the following line in my lua script:
    require 'PluginGUI-OSX'
    I've also tried preceding this with the following, but still I get no luck:
    package.path = package.path..";./?/init.lua;./?.so"
    Has anyone ever had luck trying this? Or does anyone on the Lightroom team know it to be impossible?
    Thanks in advance
    Rich

    Hello,
    I've got a similar problem. But I don't want to include native code. As in every example plugin I've found, I wanted to extract portions of my code to other scripts (just as FtpUploadTask.lua in FTP example)
    But whenever I add the following line to my ExportServiceProvider I get an error:
    require 'RhubarbHttpClient'
    The error message looks as described in the post above:
    Plug-in error log for plug-in at: /Users/krizleebear/Library/Application Support/Adobe/Lightroom/Modules/rhubarb-gallery.lrdevplugin
    **** Error 1
    An error occurred while attempting to run one of the plug-in’s scripts.
    Could not load toolkit script: RhubarbHttpClient
    **** Error 2
    Could not load the post-processing filter from this plug-in.
    Could not load toolkit script: RhubarbHttpClient
    When I just put my code from RhubarbHttpClient.lua directly into my ExportServiceProvider, it's working.
    The full code can be viewed on google-code:
    http://code.google.com/p/rhubarb-gallery/source/browse/#svn/trunk/rhubarb_lightroom_plugin /rhubarb-gallery.lrdevplugin

  • [Solved] Lua with Conky gives unwanted background color

    Hi,
    I've Googled and ransacked the forum looking for an answer. I have Conky with lua on KDE4 and I cannot run both together without creating an unwanted background. After getting sidetracked with KDE4 transparency considerations, I discovered that if I start Conky without Lua, I can get proper transparency. If I start Conky with Lua enabled I get a background color. The Lua script doesn't seem to have any background settings. I'm not sure what files are relevant to post, the conkyrc and or the Lua script, which is quite large. I'm reasonably au fait with Conky but this is the first Conky I cannot get to function correctly. My basic question is how to use Lua without starting a background color. Here is where I got the original files http://www.linuxandlife.com/2012/06/get … -your.html . Of course, I can post the relevant Lua file if necessary but, as I  mentioned, it is quite large and I'm not clear on forum rules regarding posting large files of this type. Here's how Conky starts Lua:
    lua_load ~/.conky/avi9526_conky.lua
    lua_draw_hook_pre Widgets
    Thanks for your time.
    In case anyone is interested, changing line 1236 of the Lua script to cairo_set_source_rgba(CairoContext, 0.6, 0.61, 0.62, 0.0) did the trick.
    Last edited by Foxblood (2013-04-28 14:07:15)

    If you set your minimum_size and maximum_width variables you can make it any size that you want.
    So, lets say that you are using a 1280x1024 screensize.
    You can set your minimum_size to be 1200.  If you don't provide a second option, you are specifying the width.
    Then, if you set your maximum_width to be 1280,  or, if you want a 1 pixel gap on either side 1278,  then your conky will not go off the sides of the screen, and if you use any align option, then it will stay within that specified width.
    P.S.  The reason that it doesn't go all the way across your screen right now, is because there is not enough information being displayed to warrant anything larger.
    HTH
    Last edited by Knute (2010-08-09 21:22:17)

  • Conky lua

    while trying to run a conky lua script i get this out put
    no field package.preload['cairo']
    no file './cairo.lua'
    no file '/usr/share/lua/5.1/cairo.lua'
    no file '/usr/share/lua/5.1/cairo/init.lua'
    no file '/usr/lib/lua/5.1/cairo.lua'
    no file '/usr/lib/lua/5.1/cairo/init.lua'
    no file './cairo.so'
    no file '/usr/lib/lua/5.1/cairo.so'
    no file '/usr/lib/lua/5.1/loadall.so'
    i have installed conky-lua-nv  and all dependices are installed, what am i missing to get this running i have tried googling the answer but nothing helped.
    here is conky -v  output
    Conky 1.9.0 compiled Sat Aug 18 20:07:34 EDT 2012 for Linux 3.4.9-1-ARCH (x86_64)
    Compiled in features:
    System config file: /etc/conky/conky.conf
    Package library path: /usr/lib/conky
    X11:
    * Xdamage extension
    * XDBE (double buffer extension)
    * Xft
    * ARGB visual
    Music detection:
    * MPD
    * MOC
    General:
    * math
    * hddtemp
    * portmon
    * Curl
    * RSS
    * wireless
    * support for IBM/Lenovo notebooks
    * nvidia
    * config-output
    * Imlib2
    * apcupsd
    * iostats
    * ncurses
    * Lua
    Lua bindings:
    * Cairo
    * Imlib2
    edit
    nothing appears to be in the folder even resembling cairo
    Last edited by xcabal (2012-08-19 00:22:05)

    xcabal wrote:
    while trying to run a conky lua script i get this out put
    no field package.preload['cairo']
    no file './cairo.lua'
    no file '/usr/share/lua/5.1/cairo.lua'
    no file '/usr/share/lua/5.1/cairo/init.lua'
    no file '/usr/lib/lua/5.1/cairo.lua'
    no file '/usr/lib/lua/5.1/cairo/init.lua'
    no file './cairo.so'
    no file '/usr/lib/lua/5.1/cairo.so'
    no file '/usr/lib/lua/5.1/loadall.so'
    i have installed conky-lua-nv  and all dependices are installed, what am i missing to get this running i have tried googling the answer but nothing helped.
    here is conky -v  output
    Conky 1.9.0 compiled Sat Aug 18 20:07:34 EDT 2012 for Linux 3.4.9-1-ARCH (x86_64)
    Compiled in features:
    System config file: /etc/conky/conky.conf
    Package library path: /usr/lib/conky
    X11:
    * Xdamage extension
    * XDBE (double buffer extension)
    * Xft
    * ARGB visual
    Music detection:
    * MPD
    * MOC
    General:
    * math
    * hddtemp
    * portmon
    * Curl
    * RSS
    * wireless
    * support for IBM/Lenovo notebooks
    * nvidia
    * config-output
    * Imlib2
    * apcupsd
    * iostats
    * ncurses
    * Lua
    Lua bindings:
    * Cairo
    * Imlib2
    edit
    nothing appears to be in the folder even resembling cairo
    Did you check the AUR, or the Wiki?  Go check the AUR package for Conky-lua and see if any of the comments on there are helpful, please.

  • Memory Leakage in Conky with Lua

    Hi there, I've been experiencing ongoing memory leakage using my Conky + Lua scripts. It tends to keep accumulating memory until I kill the process and restart it. Highest I've seen it go is 10% of my 4gb of RAM, so it does get to be substantial if unchecked.
    I did google it, and it mentioned something about cairo_destroy(cr), so I inserted it at the end of functions randomly where it made sense (to my limited scripting skills) and where it didn't (just in case), but it didn't seem to make any difference.
    Here is the lua script - it creates rings as % bars, I believe it was taken from somewhere on the arch forums months ago where it was also modified.
    Ring Meters by londonali1010 (2009)
    This script draws percentage meters as rings. It is fully customisable; all options are described in the script.
    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
    -- Background settings
    corner_r=20
    main_bg_colour=0x060606
    main_bg_alpha=0.4
    -- Ring color settings
    ring_background_color = 0x000000
    ring_background_alpha = 0.6
    ring_foreground_color = 0x909090
    ring_foreground_alpha = 1
    -- Rings settings
    settings_table = {
    name='cpu',
    arg='cpu2',
    max=100,
    bg_colour=ring_background_color,
    bg_alpha=ring_background_alpha,
    fg_colour=ring_foreground_color,
    fg_alpha=ring_foreground_alpha,
    x=50, y=55,
    radius=31,
    thickness=3,
    start_angle=-180,
    end_angle=0
    name='cpu',
    arg='cpu1',
    max=100,
    bg_colour=ring_background_color,
    bg_alpha=ring_background_alpha,
    fg_colour=ring_foreground_color,
    fg_alpha=ring_foreground_alpha,
    x=50, y=55,
    radius=35,
    thickness=3,
    start_angle=-180,
    end_angle=0
    name='memperc',
    arg='',
    max=100,
    bg_colour=ring_background_color,
    bg_alpha=ring_background_alpha,
    fg_colour=ring_foreground_color,
    fg_alpha=ring_foreground_alpha,
    x=205, y=55,
    radius=32,
    thickness=10,
    start_angle=-180,
    end_angle=-0
    require 'cairo'
    local function rgb_to_r_g_b(colour,alpha)
    return ((colour / 0x10000) % 0x100) / 255., ((colour / 0x100) % 0x100) / 255., (colour % 0x100) / 255., alpha
    end
    local 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
    local 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
    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>1 then
    for i in pairs(settings_table) do
    setup_rings(cr,settings_table[i])
    end
    end
    cairo_destroy(cr)
    end
    --[[ This is a script made for draw a transaprent background for conky ]]
    local function conky_draw_bg()
    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)
    local cr=cairo_create(cs)
    -- local thick=2
    cairo_move_to(cr,corner_r,0)
    cairo_line_to(cr,w-corner_r,0)
    cairo_curve_to(cr,w,0,w,0,w,corner_r)
    cairo_line_to(cr,w,h-corner_r)
    cairo_curve_to(cr,w,h,w,h,w-corner_r,h)
    cairo_line_to(cr,corner_r,h)
    cairo_curve_to(cr,0,h,0,h,0,h-corner_r)
    cairo_line_to(cr,0,corner_r)
    cairo_curve_to(cr,0,0,0,0,corner_r,0)
    cairo_close_path(cr)
    cairo_set_source_rgba(cr,rgb_to_r_g_b(main_bg_colour,main_bg_alpha))
    --cairo_set_line_width(cr,thick)
    --cairo_stroke(cr)
    cairo_fill(cr)
    cairo_destroy(cr)
    end
    function conky_main()
    conky_draw_bg()
    conky_ring_stats()
    cairo_destroy(cr)
    end
    And this is called into conky via:
    background no
    override_utf8_locale no
    use_xft yes
    xftfont Monospace:size=8
    ## orig font cure
    text_buffer_size 2048
    update_interval 1.0
    total_run_times 0
    own_window yes
    own_window_transparent yes
    own_window_type desktop
    own_window_colour 191919
    own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager
    double_buffer yes
    minimum_size 600 90
    maximum_width 320
    draw_shades no
    draw_outline no
    draw_borders no
    draw_graph_borders no
    default_color 909090
    default_shade_color fed053
    default_outline_color 7f8f9f
    alignment br
    gap_x 30
    gap_y 50
    no_buffers yes
    uppercase no
    cpu_avg_samples 2
    override_utf8_locale no
    color1 fff
    border_inner_margin 5
    border_outer_margin 5
    own_window_argb_visual no
    own_window_argb_value 200
    lua_load ~/.conky/rings.lua
    lua_draw_hook_pre main
    Left out the conky TEXT section unless anybody desperately needs to see that too.
    If anybody can point me in the right direction with this silly thing, that would be appreciated. Thanks!
    Last edited by ugugii (2011-11-16 17:42:00)

    No I meant that the destroy functions should not be in conky_main at all. Why? Because you are using cr as an argument when you have no local cr defined. You are passing the undefined value (nil) to these destroy functions and they do nothing.
    Like I said, I don't use conky or cairo but it is generally a good idea to destroy a resource you create. If you don't you will get memory leaks because "creating" is usually vague language that comes down to allocating memory and "destroy" deallocates memory.
    This line from your own post creates a surface and stores it in the cs variable:
    local cs=cairo_xlib_surface_create(conky_window.display,conky_window.drawable,conky_window.visual, conky_window.width,conky_window.height)
    Yet you forget to deallocate the surface stored in cs. So add a line like this after each cairo_destroy(cr):
    cairo_surface_destroy(cs)
    I hope that helps.

  • Ability to write workflow scripts

    Hi,
    as a DAM, one of the very few things that I find very frustrating about Lightroom, is that I have to do a lot of repetative work manually. For example: I photography a wedding and in the arrive at 8-12 chapters (represented as collections in lightroom, all with a custom sort order). I now want to export each chapter into it's own folder with a given preset and need to set the folder name and the custom filename part.
    It would be great if I could write lua (or any other scripting language) scripts to automate things like this. What would be needed are things like access to metadata, possibility to filter and iterate over photos, trigger certain actions (like exports, creation of virtual copies or collections), simple file i/o (at least of text files) and the ability to modify the selection (e.g. to select all files whose filenames are given in a text file).
    This would make my work in lightroom a lot quicker and lightroom a much more flexible tool. I realise, that this is an advanced feature, but for professionals who need to work as quickly as possible, this would make a huge difference!
    Thanks in advance for considering this feature!

    You can write lua scripts to automate things like this - SDK3.0.

  • Scripts - Not plugins

    I recently discovered a new feature in Lightroom 4 (not documented).
    Add a Scripts directory (sibling of 'Modules' directory) and you can run lua scripts without making full-blown plugins.
    e.g. D:\Users\{me}\AppData\Roaming\Adobe\Lightroom\Scripts\HelloWorld.lua
    local LrDialogs = import 'LrDialogs'
    LrDialogs.message( "Hello", "(World)" )
    Appears as 'HelloWorld' in Scripts Menu (Main Lightroom Toolbar - for all modules).
    (restart Lightroom after adding new scripts).
    Rob

    Hi Rob,
    This capability has been around since Lightroom 2 (or possibly earlier) and first came to public attention when it was used to resolve a bug with upgrading Lightroom 1 catalogs to Lightroom 2. We discussed it a little in this forum nearing 4 years ago so its no wonder you didn't spot that conversation..
    I used it years ago to publish a small script for relaunching Lightroom with the current catalog. 
    If what you are doing can be done within a plugin then it is much better to use that approach. Scripts are unsupported, and not designed for Lightroom user use, so a thrown exception, endless loop, or long running synchronous task can cause havoc for Lightroom and when first using this technique I managed to lock up Lightroom quite a few times. You need to be very careful when using this undocumented capability.
    Matt

  • Configuring DAPs using LUA

    Hi,
    I'm attempting to write a LUA script to help fill in the blanks when Host Scan can't properly detect an AV or FW package.  This seems to happen with newer packages because of the delay getting the updated OPSWAT DLLs integrated with CSD.
    Below is a FW check I put together (based on the DAP Advanced Functions Deployment Guide).  The idea is to first do all OPSWAT-based FW checks, then if they all fail, check the results of Host Check processes checks.  The Host Check process checks would be named "fw_$fw_name" as in "fw_Symantec" or "fw_McAfee".  These process checks would be added after an administrator verifies a user complaint that their new FW version is not being detected.
    DAP record [    Windows_FW_Check  ]:
    ((EVAL(endpoint.os.version,"EQ","Windows 7","string"))
    or (EVAL(endpoint.os.version,"EQ","Windows Vista","string"))
    or (EVAL(endpoint.os.version,"EQ","Windows XP","string")))
    and (assert(function()
      local no_fw = true
      for k,v in pairs(endpoint.fw) do -- OPSWAT fw checks
        if (EVAL(v.exists, "EQ", "true", "string")) then
          no_fw = false
        end
      end
      if no_fw = true then –- custom fw process checks if required
    >    for k,v in pairs(endpoint.process.fw_.*$) do -- This doesn't appear to work.  Can't I do regex based string expansion on table keys?
    >    for k,v in pairs(endpoint.process) do -- This doesn't work either.  Isn't there a Lua table for Host Scan processes?
          if (EVAL(v.exists, “EQ”, “true”, “string”)) then
            no_fw = false
          end
        end
      end
      return no_fw
    end)())
    The problem I'm having is that while I can iterate on the Cisco predefined Lua tables such as endpoint.fw, endpoint.av, and endpoint.as, I can't seem to iterate on an endpoint.process Lua table.  Maybe I'm doing something wrong or have some incorrect syntax.  Does Host Scan create an endpoint.process Lua table?  When a client connects, Host Scan checks for known processes and the status shows up in "debug dap trace".  These processes can be checked using simple
    (EVAL(endpoint.process.processname.exists,"EQ","true","string"))
    That simple syntax doesn't help me.  I'm trying to create a DAP framework that can remain static, while giving the administrators the flexibility to add or remove custom fw_$FWNAME and av_$AVNAME Host Scan process checks to fill the gap between when a package is updated and CSD is updated.
    Thanks for any help,
    Jim

    So I had some syntax and logic errors to work through.  I have two different methods that appear to work.
    To make this work, when a client fw is not detected properly by OPSWAT, an admin verifies the problem, then adds an appropriate Host Scan process check called "fw_$FW_VENDOR" or similar.  For instance, the latest version of Norton 360 isn't being detected properly by CSD 3.5.  The admin would add a process check called "fw_Symantec" with a process value of "ccSvcHost.exe".  When the client PC connects, if OPSWAT checks fail, a basic process check would succeed and allow the connection.  This isn't ideal for a few reasons:
    1) I don't believe there's a way to do SHA1 hash verification on Host Scan process checks.  This allows a user to rename "calc.exe" to a valid process name, run it and get logged on without the real process running.
    2) The checks aren't as solid as the real OPSWAT checks.  A fw service process may be running even when the firewall itself is disabled.
    3) Endpoint Assessment is only as strong as your weakest link.
    The first method checks all "endpoint.fw.*.exists" keys for a "true" value.  If yes, the no_fw variable is set to "false".  If all checks fail, all existing "endpoint.process.fw_*.exists" keys are checked for a "true" value.  If yes, the no_fw variable is set to "false".  Then the return value is set to "no_fw".  If return is "true" the DAP is selected, a user message is sent to the user that their firewall was not detected, and they are disconnected.
    ((EVAL(endpoint.os.version,"EQ","Windows 7","string"))
    or (EVAL(endpoint.os.version,"EQ","Windows Vista","string"))
    or (EVAL(endpoint.os.version,"EQ","Windows XP","string")))
    and (assert(function()
      local no_fw = true
      for k,v in pairs(endpoint.fw) do --> OPSWAT fw checks
        if (EVAL(v.exists,"EQ","true","string")) then
          no_fw = false
        end
      end
      if no_fw == true then --> fw process checks if OPSWAT checks fail
        local fw_pattern = "fw_"
        for k,v in pairs(endpoint.process) do
          print(k)
          match = string.find(k,fw_pattern)
          if (match) then
            if (EVAL(v.exists,"EQ","true","string")) then
              no_fw = false
            end
          end
        end
      end
      return no_fw
    end)())
    The second method checks a subset of preferred "endpoint.fw.*.exists" keys for a "true" value.  (eg - MS, McAfee, Norton/Symantec, AVG/Grisoft, TrendMicro, Kaspersky, etc).  If yes, the no_fw variable is set to "false".  If all checks fail, all existing "endpoint.process.fw_*.exists keys are checked for a "true" value.  If yes, the no_fw variable is set to "false".  Then the return value is set to "no_fw".  If return is "true" the DAP is selected, a user message is sent to the  user that their firewall was not detected, and they are disconnected.  This may or may not be more CPU efficient due to less total fw checks.
    ((EVAL(endpoint.os.version,"EQ","Windows 7","string"))
    or (EVAL(endpoint.os.version,"EQ","Windows Vista","string"))
    or (EVAL(endpoint.os.version,"EQ","Windows XP","string")))
    and (assert(function()
      local no_fw = true
      if ((EVAL(endpoint.fw.MSWindowsFW.exists,"EQ","true","string"))
       or (EVAL(endpoint.fw.NortonFW.exists,"EQ","true","string"))
       or (EVAL(endpoint.fw.GrisoftFW.exists,"EQ","true","string"))
       or (EVAL(endpoint.fw.TrendMicroFW.exists,"EQ","true","string"))
       or (EVAL(endpoint.fw.KasperskyFW.exists,"EQ","true", "string"))
       or (EVAL(endpoint.fw.McAfeeFW.exists,"EQ","true","string"))) then
       no_fw = false
      end
      if no_fw == true then --> fw process checks if OPSWAT fails
        local fw_pattern = "fw_"
        for k,v in pairs(endpoint.process) do
          print(k)
          match = string.find(k,fw_pattern)
          if (match) then
            if (EVAL(v.exists,"EQ","true","string")) then
              no_fw = false
            end
          end
        end
      end
      return no_fw
    end)())
    In any case, this Lua code can be applied to fw, av, and  as checks relatively easily.  The way I plan to implement this is to  place the fw and av checks just above the Default Terminate rule.  This  improves troubleshooting by still allowing a valid DAP trace for higher  priority DAPs when a client fails detection.  Clients should still match  their intended DAPs in addition to the fw check that terminates the  connection.  Also, it will no longer be necessary to include Endpoint  Assessment variables in user DAPs.  All user DAPs will only include AAA  variables and any required client access modifications.
    I can't say this stuff is original, since I just cobbled it together using code snippets from various sources.  Maybe somebody else will find this useful.  As flexible as Lua is, harnessing the true power in a GUI would put Cisco in the same league as Juniper, IMO.  Last time I checked, Juniper was miles ahead of Cisco when it comes to endpoint assessment rule flexibility and dynamic access permissions.

  • Help modifing a simple Lua DAP query

    Hello I need help with something I can't figure out.
    We currently have the following LUA script ( found in the Cisco DAP examples)
    This rule allows a vpn client to connect if any AV software is installed, this is fine for PC and Mac, but now have users conneting from iOS device where no AV is running and we want to allow them in our exsiting LUA script.
    assert(function()
        for k,v in pairs(endpoint.av) do
             if (EVAL(v.exists, "EQ", "true", "string")) then
                  return true
             end
        end
        return false
    end)()
    We'd like to modify this simple script to allow any antivirus or any iOS based device.
    I need to put in an OR  if (EVAL(endpoint.os.version, "EQ", "Apple Plugin", "string") then return true.
    But in all honesty I don't have the skills to make it work.
    Naim

    Hi,
    Check this :
    select t2.itemcode as 'Item Code', t2.ItemName as 'Item Description',
    t2.AVgPrice as 'Item Cost', t2.LstEvlPric as 'Base Price ', t0.whsname as 'Warehouse Name'
    from OWHS T0 
    INNER JOIN OITW T1 ON T0.WhsCode = T1.WhsCode
    INNER JOIN OITM T2 ON T1.ItemCode = T2.ItemCode
    where t1.whscode = '10'
    Also, please let us know what is meant by Base Price which you require in your query?
    Kind Regards,
    Jitin
    SAP Business One Forum Team

  • Lua require statement & penlight

    Hello community,
    I have written direct with lua some code and here I'm using the penlight library with several classes.
    stevedonovan/Penlight · GitHub
    This library is based in a Sub Directory structure and can be loaded with code like
    require ('pl.pretty)     OR
    local pretty = require ('pl.pretty');
    Usage:
    pretty.dump(list);
    The "pl" is like a package and the lua script is loaded from the Sub Directory.
    If I use this library in my lightroom plugin I will get some error
    "error loading toolkit script could not load"
    In the PDF from SDK there are some informations, that "require" is not the original lua implementation. This is a overriden function.
    Has somebody any idea, how to use the penlight library. How can I load this library.
    Thanks

    I don't recall anyone posting here about Penlight.  Over the years, people have alluded to the difficulties of using Lua libraries not written for the Lightroom environment.
    So I think you'll have to debug this yourself. I suggest starting with the section "Using built-in Lua features" on page 19 of the Lightroom SDK 5 Programmer's Guide, which lists the restrictions LR places on its use of Lua 5.1.4.  (It appears that Penlight claims to support 5.1, but who knows.)
    If what you want primarily is pretty printing of Lua data structures, you could use my Debugging Toolkit for Lightroom SDK.  The toolkit is much more limited in scope than Penlight, but it's implemented specifically for LR.

  • Lua malloc errors

    Not sure where this topic belongs. Please move it accordingly.
    I'm working on a fairly large project making use of lua, and was getting weird memory corruption bugs I was having issues tracking down. It looked like these bugs were coming from lua, but I was somewhat in disbelief.
    Then I ran this:
    valgrind -v lua -e "print('hi')"
    For a bit of clarity, I compiled the latest lua so I would have some symbols:
    valgrind -v ./lua -e "print('hi')"
    ==2277== Memcheck, a memory error detector
    ==2277== Copyright (C) 2002-2010, and GNU GPL'd, by Julian Seward et al.
    ==2277== Using Valgrind-3.6.1 and LibVEX; rerun with -h for copyright info
    ==2277== Command: ./lua -e print('hi')
    ==2277==
    ... omitted for brevity ...
    ==2277== Invalid read of size 8
    ==2277== at 0x59DB6C1: ??? (in /lib/libc-2.14.1.so)
    ==2277== by 0x59C362D: fputs (in /lib/libc-2.14.1.so)
    ==2277== by 0x417267: luaB_print (in /home/endeavor/source/lua-5.1.4/src/lua)
    ==2277== by 0x40852B: luaD_precall (in /home/endeavor/source/lua-5.1.4/src/lua)
    ==2277== by 0x411A47: luaV_execute (in /home/endeavor/source/lua-5.1.4/src/lua)
    ==2277== by 0x40893C: luaD_call (in /home/endeavor/source/lua-5.1.4/src/lua)
    ==2277== by 0x407BF6: luaD_rawrunprotected (in /home/endeavor/source/lua-5.1.4/src/lua)
    ==2277== by 0x408AD1: luaD_pcall (in /home/endeavor/source/lua-5.1.4/src/lua)
    ==2277== by 0x4061FE: lua_pcall (in /home/endeavor/source/lua-5.1.4/src/lua)
    ==2277== by 0x4043E5: docall (in /home/endeavor/source/lua-5.1.4/src/lua)
    ==2277== by 0x40447D: dostring (in /home/endeavor/source/lua-5.1.4/src/lua)
    ==2277== by 0x404986: pmain (in /home/endeavor/source/lua-5.1.4/src/lua)
    ==2277== Address 0x5cf5398 is 24 bytes inside a block of size 27 alloc'd
    ==2277== at 0x4C2740D: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
    ==2277== by 0x4C27597: realloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
    ==2277== by 0x40A97B: luaM_realloc_ (in /home/endeavor/source/lua-5.1.4/src/lua)
    ==2277== by 0x40E565: luaS_newlstr (in /home/endeavor/source/lua-5.1.4/src/lua)
    ==2277== by 0x415B31: luaX_newstring (in /home/endeavor/source/lua-5.1.4/src/lua)
    ==2277== by 0x415F52: llex (in /home/endeavor/source/lua-5.1.4/src/lua)
    ==2277== by 0x416828: luaX_next (in /home/endeavor/source/lua-5.1.4/src/lua)
    ==2277== by 0x40C23F: funcargs (in /home/endeavor/source/lua-5.1.4/src/lua)
    ==2277== by 0x40C445: primaryexp (in /home/endeavor/source/lua-5.1.4/src/lua)
    ==2277== by 0x40C533: chunk (in /home/endeavor/source/lua-5.1.4/src/lua)
    ==2277== by 0x40DCE4: luaY_parser (in /home/endeavor/source/lua-5.1.4/src/lua)
    ==2277== by 0x407F6F: f_parser (in /home/endeavor/source/lua-5.1.4/src/lua)
    ==2277==
    hi
    ==2277==
    ==2277== HEAP SUMMARY:
    ==2277== in use at exit: 0 bytes in 0 blocks
    ==2277== total heap usage: 430 allocs, 430 frees, 33,475 bytes allocated
    ==2277==
    ==2277== All heap blocks were freed -- no leaks are possible
    ==2277==
    ==2277== ERROR SUMMARY: 2 errors from 1 contexts (suppressed: 6 from 6)
    ==2277==
    ==2277== 2 errors in context 1 of 1:
    ==2277== Invalid read of size 8
    ==2277== at 0x59DB6C1: ??? (in /lib/libc-2.14.1.so)
    ==2277== by 0x59C362D: fputs (in /lib/libc-2.14.1.so)
    ==2277== by 0x417267: luaB_print (in /home/endeavor/source/lua-5.1.4/src/lua)
    ==2277== by 0x40852B: luaD_precall (in /home/endeavor/source/lua-5.1.4/src/lua)
    ==2277== by 0x411A47: luaV_execute (in /home/endeavor/source/lua-5.1.4/src/lua)
    ==2277== by 0x40893C: luaD_call (in /home/endeavor/source/lua-5.1.4/src/lua)
    ==2277== by 0x407BF6: luaD_rawrunprotected (in /home/endeavor/source/lua-5.1.4/src/lua)
    ==2277== by 0x408AD1: luaD_pcall (in /home/endeavor/source/lua-5.1.4/src/lua)
    ==2277== by 0x4061FE: lua_pcall (in /home/endeavor/source/lua-5.1.4/src/lua)
    ==2277== by 0x4043E5: docall (in /home/endeavor/source/lua-5.1.4/src/lua)
    ==2277== by 0x40447D: dostring (in /home/endeavor/source/lua-5.1.4/src/lua)
    ==2277== by 0x404986: pmain (in /home/endeavor/source/lua-5.1.4/src/lua)
    ==2277== Address 0x5cf5398 is 24 bytes inside a block of size 27 alloc'd
    ==2277== at 0x4C2740D: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
    ==2277== by 0x4C27597: realloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
    ==2277== by 0x40A97B: luaM_realloc_ (in /home/endeavor/source/lua-5.1.4/src/lua)
    ==2277== by 0x40E565: luaS_newlstr (in /home/endeavor/source/lua-5.1.4/src/lua)
    ==2277== by 0x415B31: luaX_newstring (in /home/endeavor/source/lua-5.1.4/src/lua)
    ==2277== by 0x415F52: llex (in /home/endeavor/source/lua-5.1.4/src/lua)
    ==2277== by 0x416828: luaX_next (in /home/endeavor/source/lua-5.1.4/src/lua)
    ==2277== by 0x40C23F: funcargs (in /home/endeavor/source/lua-5.1.4/src/lua)
    ==2277== by 0x40C445: primaryexp (in /home/endeavor/source/lua-5.1.4/src/lua)
    ==2277== by 0x40C533: chunk (in /home/endeavor/source/lua-5.1.4/src/lua)
    ==2277== by 0x40DCE4: luaY_parser (in /home/endeavor/source/lua-5.1.4/src/lua)
    ==2277== by 0x407F6F: f_parser (in /home/endeavor/source/lua-5.1.4/src/lua)
    ==2277==
    --2277--
    --2277-- used_suppression: 4 U1004-ARM-_dl_relocate_object
    --2277-- used_suppression: 2 glibc-2.5.x-on-SUSE-10.2-(PPC)-2a
    ==2277==
    ==2277== ERROR SUMMARY: 2 errors from 1 contexts (suppressed: 6 from 6)
    I am unsure of where to go from here. I get these errors both in 64 and 32-bit Arch. Another user in the #lua channel using gentoo does not have these errors, which leads me to believe this is an arch-specific issue.
    Can someone smarter than myself shed some light on this? It looks like lua, for some reason, isn't playing nice with Arch's glibc. I'm leaning towards perhaps this is an Arch glibc issue, but not sure.

    I'm running a couple of lua scripts which import files into NoteCase Pro. These scripts always stall (about 2/3 of the way through) on Arch when I import a large number of files (say more than 500), but they work when I import the files in smaller batches (so not a data problem). The same scripts work on Windows XP and other Linux distros tried, but always stall on Arch so that the NoteCase process has to be killed.
    So, your suspicion about Lua problems and Arch is very interesting, and I have also been in touch with the author of NoteCase Pro to discount other possibilties.
    May try as you have done and experiment with Valgrind a bit.

  • Scripting Languages are for Insane People!!!!

    Hope you brought your flamethrowers because I am feeling a bit chilled.
    Sooo I am knee deep in some heavy javascript(Nodejs) and while fighting to populate an array with the results of a sqlite query
    (somehow my array is getting nuked nodejs or nodejs-sqlite3 bug? )
    I am left scratching my head saying to my self WTF!! This would have taken me like 5 sec in Qt C++. So I wrote up the same example
    in Ruby, Python, Java, Lua and Perl. And in every case my Qt C++ example was not only cleaner, shorter but easier to write/understand.
    Granted scripting languages are not only valuable but necessary in CERTAIN cases, but the way people use them today is just INSANE.
    My primary scripting language is javascript but that is only because my work requires it. But ill take lua over any scripting language any day.
    I am going to go sink my teeth in Django see if that pisses me off any less!
    Sooo whats your opinion.
    Last edited by zester (2011-09-13 05:19:18)

    satanselbow wrote:
    ethail wrote:
    keenerd wrote:But Lua is a scripting language.  Maybe I missed the joke?
    I think he could be pointing that of the many scripting languajes he has used, seems that only LUA satisfies him, and it's not widely used as he would like. That's what it seemed to me.
    Somewhat ironically (within this threads context) - one of Lua's biggest selling points is it's simple integration with other languages, both scripting and higher level.
    Good point!
    Lua is insanely <-- Word of the day (Pee-Wee Herman Play House AHHHHHHHHHH) easy
    to embed and bind.
    Little examples I wrote a couple of years ago sooooo it is what it is.
    If using C++
    extern "C" {
    #include "lua.h"
    #include "lualib.h"
    #include "lauxlib.h"
    How to call a C Function from Lua
    luaavg.c
    #include <stdio.h>
    #include "lua.h"
    #include "lualib.h"
    #include "lauxlib.h"
    /* gcc -o luaavg luaavg.c -I/usr/local/include -L/usr/local/lib -llua -lm -ldl */
    /* the Lua interpreter */
    lua_State* L;
    static int average(lua_State *L)
    /* get number of arguments */
    int n = lua_gettop(L);
    double sum = 0;
    int i;
    /* loop through each argument */
    for (i = 1; i <= n; i++)
    /* total the arguments */
    sum += lua_tonumber(L, i);
    /* push the average */
    lua_pushnumber(L, sum / n);
    /* push the sum */
    lua_pushnumber(L, sum);
    /* return the number of results */
    return 2;
    int main ( int argc, char *argv[] )
    /* initialize Lua */
    L = lua_open();
    /* load Lua base libraries */
    luaL_openlibs(L);
    /* register our function */
    lua_register(L, "average", average);
    /* run the script */
    luaL_dofile(L, "avg.lua");
    /* cleanup Lua */
    lua_close(L);
    /* print */
    printf( "Press enter to exit..." );
    getchar();
    return 0;
    -- call a C function
    avg, sum = average(10, 20, 30, 40, 50)
    print("The average is ", avg)
    print("The sum is ", sum)
    avg, sum = average(1, 2, 3, 4, 5)
    print("The average is ", avg)
    print("The sum is ", sum)
    --- How to call a Lua Function from C
    #include <stdio.h>
    #include "lua.h"
    #include "lualib.h"
    #include "lauxlib.h"
    /* gcc -o luadd luadd.c -I/usr/local/include -L/usr/local/lib -llua -lm -ldl */
    /* the Lua interpreter */
    lua_State* L;
    int luaadd ( int x, int y )
    int sum;
    /* the function name */
    lua_getglobal(L, "add");
    /* the first argument */
    lua_pushnumber(L, x);
    /* the second argument */
    lua_pushnumber(L, y);
    /* call the function with 2 arguments, return 1 result */
    lua_call(L, 2, 1);
    /* get the result */
    sum = (int)lua_tointeger(L, -1);
    lua_pop(L, 1);
    return sum;
    int main ( int argc, char *argv[] )
    int sum;
    /* initialize Lua */
    L = lua_open();
    /* load Lua base libraries */
    luaL_openlibs(L);
    /* load the script */
    luaL_dofile(L, "add.lua");
    /* call the add function */
    sum = luaadd( 10, 15 );
    /* print the result */
    printf( "The sum is %d\n", sum );
    /* cleanup Lua */
    lua_close(L);
    /* pause */
    printf( "Press enter to exit..." );
    getchar();
    return 0;
    -- add two numbers
    function add ( x, y )
    return x + y
    end
    --- How to load and call a lua function from c
    //last.cc
    # extern "C" {
    # #include "lua.h"
    # #include "lualib.h"
    # #include "lauxlib.h"
    int main()
    double z;
    lua_State *L = lua_open();
    luaL_openlibs(L);
    if (luaL_loadfile(L, "last.lua") || lua_pcall(L, 0, 0, 0)) {
    printf("error: %s", lua_tostring(L, -1));
    return -1;
    lua_getglobal(L, "f");
    if(!lua_isfunction(L,-1))
    lua_pop(L,1);
    return -1;
    lua_pushnumber(L, 21); /* push 1st argument */
    lua_pushnumber(L, 31); /* push 2nd argument */
    /* do the call (2 arguments, 1 result) */
    if (lua_pcall(L, 2, 1, 0) != 0) {
    printf("error running function `f': %s\n",lua_tostring(L, -1));
    return -1;
    /* retrieve result */
    if (!lua_isnumber(L, -1)) {
    printf("function `f' must return a number\n");
    return -1;
    z = lua_tonumber(L, -1);
    printf("Result: %f\n",z);
    lua_pop(L, 1);
    lua_close(L);
    return 0;
    function f (x, y)
    return (x^2 * math.sin(y))/(1 - x)
    end
    ---- How to execute a Lua Script from C.
    #include "lua.h"
    #include "lualib.h"
    #include "lauxlib.h"
    /* gcc -o luatest luatest.c -I/usr/local/include -L/usr/local/lib -llua -lm -ldl */
    int main()
    int s=0;
    lua_State *L = lua_open();
    // load the libs
    luaL_openlibs(L);
    //run a Lua scrip here
    luaL_dofile(L,"foo.lua");
    printf("\nAllright we are back in C.\n");
    lua_close(L);
    return 0;
    io.write("Please enter your name: ")
    name = io.read() -- read input from user
    print ("Hi " .. name .. ", did you know we are in lua right now?")
    ---- How to get a Variable value from Lua to C.
    #include <stdio.h>
    #include <lua.h>
    #include <lualib.h>
    #include <lauxlib.h>
    #include <string.h>
    /* gcc -o test test.c -I/usr/local/include -L/usr/local/lib -llua -lm -ldl */
    int main()
    lua_State *L = lua_open();
    if(luaL_loadfile(L,"settings.lua") || lua_pcall(L,0,0,0))
    printf("Error failed to load %s",lua_tostring(L,-1));
    else
    lua_getglobal(L,"screenWidth");
    const int screenWidth = lua_tonumber(L,-1);
    printf("Screen Width = %d \n", screenWidth);
    lua_getglobal(L,"appName");
    const char *appName = luaL_checkstring(L, -1);
    printf("Screen Name = %s \n", appName);
    lua_close(L);
    /* If we got this far, everything worked */
    printf("Success!\n");
    return 0;
    appName = "Firefox"
    screenWidth = 400
    ------ How to write a lua binding in C.
    #include "lua.h"
    #include "lualib.h"
    #include "lauxlib.h"
    #include <string.h>
    /* gcc zstring.c -Wall -shared -o zstring.so */
    static int zst_strlen(lua_State *L)
    size_t len;
    len = strlen(lua_tostring(L, 1));
    lua_pushnumber(L, len);
    return 1;
    int luaopen_zstring(lua_State *L)
    lua_register(L,"zst_strlen", zst_strlen);
    return 0;
    require "zstring"
    print(zst_strlen("Hello, World"))
    ----- Another Binding Example
    #include "lua.h"
    #include "lualib.h"
    #include "lauxlib.h"
    #include <unistd.h>
    #include <sys/stat.h>
    #include <stdlib.h>
    /* gcc general.c -Wall -shared -o general.so */
    /* system */
    static int zst_exec(lua_State *L)
    int status;
    status = system(lua_tostring(L, 1));
    lua_pushnumber(L, status);
    return 1;
    /* mkdir */
    static int zst_mkdir(lua_State *L)
    int status;
    mode_t mode = lua_tonumber(L, 2);
    status = mkdir(lua_tostring(L, 1), mode);
    lua_pushnumber(L, status);
    return 1;
    /* symlink */
    static int zst_symlink(lua_State *L)
    int status;
    const char *old = lua_tostring(L, 1);
    const char *new = lua_tostring(L, 2);
    status = symlink(old, new);
    lua_pushnumber(L, status);
    return 1;
    /* rmdir */
    static int zst_rmdir(lua_State *L)
    int status;
    status = rmdir(lua_tostring(L, 1));
    lua_pushnumber(L, status);
    return 1;
    /* rename */
    static int zst_rename(lua_State *L)
    int status;
    const char *old = lua_tostring(L, 1);
    const char *new = lua_tostring(L, 2);
    status = rename(old, new);
    lua_pushnumber(L, status);
    return 1;
    /* remove */
    static int zst_remove(lua_State *L)
    int status;
    const char *filename = lua_tostring(L, 1);
    status = remove(filename);
    lua_pushnumber(L, status);
    return 1;
    /* chown */
    static int zst_chown(lua_State *L)
    int status;
    const char *filename = lua_tostring(L, 1);
    uid_t owner = lua_tonumber(L, 2);
    gid_t group = lua_tonumber(L, 3);
    status = chown(filename, owner, group);
    lua_pushnumber(L, status);
    return 1;
    /* chmod */
    static int zst_chmod(lua_State *L)
    int status;
    const char *filename = lua_tostring(L, 1);
    mode_t mode = lua_tonumber(L, 2);
    status = chmod(filename, mode);
    lua_pushnumber(L, status);
    return 1;
    /* get_current_dir_name */
    static int zst_getcwd(lua_State *L)
    char *dir;
    dir = get_current_dir_name();
    lua_pushstring(L, dir);
    return 1;
    int luaopen_general(lua_State *L)
    lua_register(L,"zst_exec", zst_exec);
    lua_register(L,"zst_mkdir", zst_mkdir);
    lua_register(L,"zst_symlink", zst_symlink);
    lua_register(L,"zst_rmdir", zst_rmdir);
    lua_register(L,"zst_rename", zst_rename);
    lua_register(L,"zst_remove", zst_remove);
    lua_register(L,"zst_chown", zst_chown);
    lua_register(L,"zst_chmod", zst_chmod);
    lua_register(L,"zst_getcwd", zst_getcwd);
    return 0;
    Ugggg lost all the formating in that.
    If you cant make heads or tails of the above you can view it on my google code wiki http://code.google.com/p/zester/wiki/Lua_C
    Last edited by zester (2011-09-13 18:20:07)

  • Conky-lua problem

    I used this as a lua script guide for conky (semi-relvent)
    error message I can't resolve with my current lua knowledge or though research/script reading.
    Conky: llua_do_call: function conky_main execution failed: attempt to call a nil value
    conky config
    # Conky, a system monitor, based on torsmo
    # Any original torsmo code is licensed under the BSD license
    # All code written since the fork of torsmo is licensed under the GPL
    # Please see COPYING for details
    # Copyright (c) 2004, Hannu Saransaari and Lauri Hakkarainen
    # Copyright (c) 2005-2010 Brenden Matthews, Philip Kovacs, et. al. (see AUTHORS)
    # All rights reserved.
    # This program is free software: you can redistribute it and/or modify
    # it under the terms of the GNU General Public License as published by
    # the Free Software Foundation, either version 3 of the License, or
    # (at your option) any later version.
    # This program is distributed in the hope that it will be useful,
    # but WITHOUT ANY WARRANTY; without even the implied warranty of
    # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    # GNU General Public License for more details.
    # You should have received a copy of the GNU General Public License
    # along with this program. If not, see <http://www.gnu.org/licenses/>.
    # - Conky settings - #
    update_interval .5
    total_run_times 0
    net_avg_samples 1
    cpu_avg_samples 1
    imlib_cache_size 0
    double_buffer yes
    no_buffers yes
    # - Text settings - #
    use_xft yes
    xftfont Ubuntu:size=9
    override_utf8_locale yes
    text_buffer_size 2048
    # - Window specifications - #
    own_window_class Conky
    own_window yes
    own_window_type override
    own_window_transparent yes
    own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager
    #own_window_argb_visual yes
    #own_window_argb_value 100
    alignment bottom_right
    alignment tr
    gap_x -2
    gap_y 180
    minimum_size 350 300
    default_bar_size 100 8
    draw_shades no
    default_color efefef
    default_shade_color 1d1d1d
    background no
    border_width 1
    default_color white
    default_outline_color white
    default_shade_color white
    draw_borders no
    draw_graph_borders yes
    draw_outline no
    out_to_console no
    out_to_stderr no
    extra_newline no
    own_window yes
    own_window_class Conky
    own_window_type desktop
    stippled_borders 0
    update_interval 1.0
    uppercase no
    use_spacer none
    show_graph_scale no
    show_graph_range no
    lua_load ./conky_outline.lua
    lua_draw_hook_post main
    TEXT
    $alignc CPU
    #${scroll 16 $nodename - $sysname $kernel on $machine | }
    #$hr
    #${color grey}Uptime:$color $uptime
    #${color grey}Frequency (in MHz):$color $freq
    #${color grey}Frequency (in GHz):$color $freq_g
    #${color grey}RAM Usage:$color $mem/$memmax - $memperc% ${membar 4}
    #${color grey}Swap Usage:$color $swap/$swapmax - $swapperc% ${swapbar 4}
    #${color grey}CPU Usage:$color ${cpu cpu0}% ${cpugauge 0}
    #${color grey}Processes:$color $processes ${color grey}Running:$color $running_processes
    #$hr
    #${color grey}File systems:
    # / $color${fs_used /}/${fs_size /} ${fs_bar 6 /}
    #${color grey}Networking:
    #Up:$color ${upspeed eth0} ${color grey} - Down:$color ${downspeed eth0}
    #$hr
    #${color grey}Name PID CPU% MEM%
    #${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}
    #${color lightgrey} ${top name 4} ${top pid 4} ${top cpu 4} ${top mem 4}
    the lua script giving the errors
    --[[line_width=5
    top_left_x=20
    top_left_y=20
    rec_width=50
    rec_height=50
    red=1
    green=0
    blue=0
    alpha=1 ]]
    --draw it
    require 'cario'
    line_width=5
    top_left_x=20
    top_left_y=20
    rec_width=50
    rec_height=50
    red=1
    green=0
    blue=0
    alpha=1
    function conky_main()
    if value == nil then value = 0 end
    pct = value/pt['max']
    if conky_window == nil then return end
    --local updates = conky_parse('${updates}')
    -- update_num = tonumber(updates)
    --if updates_num>5 then
    cs = cairo_xlib_surface_create(conky_window.display, conky_window.drawable, conky_window.visual, conky_window.width, conky_window.height)
    cr = cairo_create(cs)
    --local updates=tonumber(conky_parse('${updates}')
    cairo_set_line_width (cr,line_width)
    cairo_rectangle (cr,top_left_x,top_left_y,rec_width,rec_height)
    cairo_set_source_rgba (cr,red,green,blue,alpha)
    --end-- if updates>5
    cairo_destroy(cr)
    cairo_surface_destroy(cs)
    cr=nil
    end-- end main function
    ra
    backgroud for anybody that cares.
    Ive been trying to learn enough about lua and conky enough to make my own lua script for conky for flexabilty reasons. I want to be able to draw the background with lua which is what im trying to do here as a proof of concept.

    runny6play wrote:
    I tried it. It had no effect. also I changed lua_draw_hook_post main to lua_draw_hook_post conky_main
    and this is what i got. though i think its just annother error for the setting i just changed because its incorrect.
    Conky: llua_load: /home/alec/conky_outline.lua:11: module 'cario' not found:
    no field package.preload['cario']
    no file './cario.lua'
    no file '/usr/share/lua/5.1/cario.lua'
    no file '/usr/share/lua/5.1/cario/init.lua'
    no file '/usr/lib/lua/5.1/cario.lua'
    no file '/usr/lib/lua/5.1/cario/init.lua'
    no file '/usr/lib/conky/libcario.so'
    no file './cario.so'
    no file '/usr/lib/lua/5.1/cario.so'
    no file '/usr/lib/lua/5.1/loadall.so'
    Conky: desktop window (15d) is root window
    Conky: window type - desktop
    Conky: drawing to created window (0x1200001)
    Conky: drawing to double buffer
    Conky: llua_do_call: function conky_main execution failed: attempt to call a nil value
    Conky: llua_do_call: function conky_main execution failed: attempt to call a nil value
    Conky: llua_do_call: function conky_main execution failed: attempt to call a nil value
    Conky: llua_do_call: function conky_main execution failed: attempt to call a nil value
    Shouldn't that be "Cairo" and not "Cario"?

Maybe you are looking for

  • 6.0.2/6.0.3 Crashing when playing any audio file.

    Hi Folks, I've had this problem since 6.0.2 and upgraded to 6.0.3 last night hoping it would fix the issue but it hasn't. Whenever I try to play a song in my library or playlists iTunes unexpectedly quits. I have tried deleteing all preferences. Remo

  • Bug or feature: APEX_ITEM.DISPLAY_AND_SAVE (1, DATE) is sort by alphanumeric...???

    Hi, my select is like this: select      APEX_ITEM.DISPLAY_AND_SAVE (1, STICHTAG) as STICHTAG, --Datatype is date      APEX_ITEM.DISPLAY_AND_SAVE (2, Name) as Name,      APEX_ITEM.DISPLAY_AND_SAVE (3, Animal) as animal From XYZ; If i want to sort asc/

  • How do you restore a depleted batte

    I was going through the trouble shooting on the site and it seems like the problem with my player falls in that category as it doesnt want to recharge no matter what?i do. The site says "Restoring the power to depleted battery" but only gives the sym

  • I forgot security confimation

    I forgot security confimation

  • Installing CS6 on two company workstations

    I work for a small company and I am sometimes required to travel to another office which is 300 km away. If the company purchases one copy of CS6, may I install it on both desktop computers which I use? All of our company computers are networked, but