harmattan version.
authorlance colton <lance.colton@gmail.com>
Wed, 9 Nov 2011 07:43:30 +0000 (00:43 -0700)
committerlance colton <lance.colton@gmail.com>
Wed, 9 Nov 2011 07:43:30 +0000 (00:43 -0700)
35 files changed:
data/LoadAll.lua [new file with mode: 0644]
data/Makefile.am
data/bargraph_eng.lua [new file with mode: 0644]
data/box.lua [new file with mode: 0644]
data/conky.conf
data/conky.conf.nolua [new file with mode: 0644]
data/conky_no_x11.conf [deleted file]
data/graph.lua [new file with mode: 0644]
data/luatraverse.lua [new file with mode: 0644]
data/misc.lua [new file with mode: 0644]
data/n950-kobol.jpg [new file with mode: 0644]
data/piechart.lua [new file with mode: 0644]
data/strict.lua [new file with mode: 0644]
data/testCairo.lua [new file with mode: 0644]
data/text.lua [new file with mode: 0644]
debian/changelog
debian/conky-n900.docs [deleted file]
debian/conky-n900.install [deleted file]
debian/conky-n900.menu [deleted file]
debian/conky-n950.docs [new file with mode: 0644]
debian/conky-n950.install [new file with mode: 0644]
debian/conky-n950.menu [new file with mode: 0644]
debian/control
debian/optify [deleted file]
debian/rules
lua_scripts/LoadAll.lua
lua_scripts/bargraph_eng.lua
lua_scripts/conky.conf [new file with mode: 0644]
lua_scripts/graph.lua
lua_scripts/n900-kobol.jpg [deleted file]
lua_scripts/n950-kobol.jpg [new file with mode: 0644]
lua_scripts/piechart.lua
lua_scripts/text.lua
src/dbus/Makefile.am
src/linux.c

diff --git a/data/LoadAll.lua b/data/LoadAll.lua
new file mode 100644 (file)
index 0000000..ca4c013
--- /dev/null
@@ -0,0 +1,30 @@
+do
+       package.path = "/etc/conky/?.lua" --loads all lua files from here
+       require 'text' --specify each one we really want again like this, text = text.lua
+       require 'graph'
+       require 'bargraph_eng'
+       require 'misc'
+       require 'luatraverse'
+       require 'strict'
+       require 'box'
+
+       --local count
+       
+       function conky_main() --conky will run this if you specified to load 'main' in the conf
+               conky_main_box()
+               conky_main_bars()
+               conky_main_graph()
+               conky_draw_text()
+               --collectgarbage(collect)
+               --local y = traverse.countreferences(deleteme)
+               --print (tostring(y))
+               --count = #(_G)
+               --local run = true
+               --io.output("/home/user/MyDocs/lua/lua.log")
+               --for n,v in pairs(_G) do
+               --      io.write (tostring(n)," ",tostring(v),"\n")
+               --end
+               --io.write (tostring(count))
+               --print (count)
+       end
+end
\ No newline at end of file
index a7607d9..480b2c1 100644 (file)
@@ -26,6 +26,6 @@
 #
 
 configdir = ${sysconfdir}/conky
-dist_config_DATA = conky.conf conky_no_x11.conf
+dist_config_DATA = bargraph_eng.lua box.lua conky.conf conky.conf.nolua graph.lua LoadAll.lua luatraverse.lua misc.lua n950-kobol.jpg piechart.lua strict.lua testCairo.lua text.lua
 
 # vi:set ts=4 sw=4 noet ai nocindent syntax=automake:
diff --git a/data/bargraph_eng.lua b/data/bargraph_eng.lua
new file mode 100644 (file)
index 0000000..675941e
--- /dev/null
@@ -0,0 +1,580 @@
+
+
+--[[ BARGRAPH WIDGET
+       v2.0 by wlourf (12.07.2010)
+       this widget draws a bargraph with different effects 
+       http://u-scripts.blogspot.com/2010/07/bargraph-widget.html
+       
+       
+Parameters are :
+3 parameters are mandatory
+name   - the name of the conky variable to display, for example for {$cpu cpu0}, just write name="cpu"
+arg            - the argument of the above variable, for example for {$cpu cpu0}, just write arg="cpu0"
+                 arg can be a numerical value if name=""
+max            - the maximum value the above variable can reach, for example, for {$cpu cpu0}, just write  max=100
+       
+Optional parameters:
+x,y            - coordinates of the starting point of the bar, default = middle of the conky window
+cap            - end of cap line, ossibles values are r,b,s (for round, butt, square), default="b"
+                 http://www.cairographics.org/samples/set_line_cap/
+angle  - angle of rotation of the bar in degress, default = 0 (i.e. a vertical bar)
+                 set to 90 for an horizontal bar
+skew_x - skew bar around x axis, default = 0
+skew_y - skew bar around y axis, default = 0
+blocks  - number of blocks to display for a bar (values >0) , default= 10
+height - height of a block, default=10 pixels
+width  - width of a block, default=20 pixels
+space  - space between 2 blocks, default=2 pixels
+angle_bar      - this angle is used to draw a bar on a circular way (ok, this is no more a bar !) default=0
+radius         - for cicular bars, internal radius, default=0
+                         with radius, parameter width has no more effect.
+
+Colours below are defined into braces {colour in hexadecimal, alpha}
+fg_colour      - colour of a block ON, default= {0x00FF00,1}
+bg_colour      - colour of a block OFF, default = {0x00FF00,0.5}
+alarm          - threshold, values after this threshold will use alarm_colour colour , default=max
+alarm_colour - colour of a block greater than alarm, default=fg_colour
+smooth         - (true or false), create a gradient from fg_colour to bg_colour, default=false 
+mid_colour     - colours to add to gradient, with this syntax {position into the gradient (0 to1), colour hexa, alpha}
+                         for example, this table {{0.25,0xff0000,1},{0.5,0x00ff00,1},{0.75,0x0000ff,1}} will add
+                         3 colurs to gradient created by fg_colour and alarm_colour, default=no mid_colour
+led_effect     - add LED effects to each block, default=no led_effect
+                         if smooth=true, led_effect is not used
+                         possibles values : "r","a","e" for radial, parallelel, perdendicular to the bar (just try!)
+                         led_effect has to be used with theses colours :
+fg_led         - middle colour of a block ON, default = fg_colour
+bg_led         - middle colour of a block OFF, default = bg_colour
+alarm_led      - middle colour of a block > ALARM,  default = alarm_colour
+
+reflection parameters, not avaimable for circular bars
+reflection_alpha    - add a reflection effect (values from 0 to 1) default = 0 = no reflection
+                      other values = starting opacity
+reflection_scale    - scale of the reflection (default = 1 = height of text)
+reflection_length   - length of reflection, define where the opacity will be set to zero
+                                         calues from 0 to 1, default =1
+reflection                     - position of reflection, relative to a vertical bar, default="b"
+                                         possibles values are : "b","t","l","r" for bottom, top, left, right
+
+
+v1.0 (10 Feb. 2010) original release
+v1.1 (13 Feb. 2010) numeric values can be passed instead conky stats with parameters name="", arg = numeric_value      
+v1.2 (28 Feb. 2010) just renamed the widget to bargraph
+v1.3 (03 March 2010) added parameters radius & angle_bar to draw the bar in a circular way
+v2.0 (12 Jul. 2010) rewrite script + add reflection effects and parameters are now set into tables
+]]
+
+require 'cairo'
+
+----------------START OF PARAMETERS ----------
+function conky_main_bars()
+       local bars_settings={
+
+               {
+                       name="fs_used",
+                       arg="/",
+                       max=conky_parse("${to_bytes ${fs_size /}}"),
+                       --alarm=1,--no alarm with 1 smooth block, don't do extra work here
+                       bg_colour={0x00ff00,0.25},
+                       fg_colour={0x00ff00,1},
+                       alarm_colour={0xff0000,1},
+                       x=5,y=112,
+                       angle=90,
+                       blocks=1,
+                       height=210,width=18,
+                       smooth=true,
+                       mid_colour={{0.5,0xffff00,1}},
+               },
+               
+               {
+                       name="fs_used",
+                       arg="/home",
+                       max=conky_parse("${to_bytes ${fs_size /home}}"),
+                       --alarm=1,--no alarm with 1 smooth block, don't do extra work here
+                       bg_colour={0x00ff00,0.25},
+                       fg_colour={0x00ff00,1},
+                       alarm_colour={0xff0000,1},
+                       x=5,y=132,
+                       angle=90,
+                       blocks=1,
+                       height=210,width=18,
+                       smooth=true,
+                       mid_colour={{0.5,0xffff00,1}},
+               },
+               {
+                       name="fs_used",
+                       arg="/home/user/MyDocs",
+                       max=conky_parse("${to_bytes ${fs_size /home/user/MyDocs}}"),
+                       --alarm=1,--no alarm with 1 smooth block, don't do extra work here
+                       bg_colour={0x00ff00,0.25},
+                       fg_colour={0x00ff00,1},
+                       alarm_colour={0xff0000,1},
+                       x=5,y=152,
+                       angle=90,
+                       blocks=1,
+                       height=210,width=18,
+                       smooth=true,
+                       mid_colour={{0.5,0xffff00,1}},
+                       DrawMe=conky_parse("${if_mounted /home/user/MyDocs}1$endif")
+               },      
+               --[[{
+                       name="fs_used",
+                       arg="/media/mmc1",
+                       max=conky_parse("${to_bytes ${fs_size /media/mmc1}}"),
+                       --alarm=1,--no alarm with 1 smooth block, don't do extra work here
+                       bg_colour={0x00ff00,0.25},
+                       fg_colour={0x00ff00,1},
+                       alarm_colour={0xff0000,1},
+                       x=5,y=172,
+                       angle=90,
+                       blocks=1,
+                       height=210,width=18,
+                       smooth=true,
+                       mid_colour={{0.5,0xffff00,1}},
+                       DrawMe=conky_parse("${if_mounted /media/mmc1}1$endif")
+               },]]
+               {
+                       name="mem",
+                       arg="",
+                       max=conky_parse("${to_bytes ${memmax}}"),
+                       alarm=100,
+                       bg_colour={0x00ff00,0.25},
+                       fg_colour={0x00ff00,1},
+                       alarm_colour={0xff0000,1},
+                       x=9,y=95,
+                       angle=90,
+                       blocks=18,
+                       height=10,width=18,
+                       smooth=true,
+                       --mid_colour={{0.5,0xffff00,1}},
+               },              
+               {
+                       name="battery_percent",
+                       arg="",
+                       max=100,
+                       angle=90,
+                       alarm=25,
+                       alarm_colour={0x00ffff,0.5},
+                       bg_colour={0x00ffff,0.5},
+                       fg_colour={0xff0000,0.5},
+                       led_effect="e",
+                       bg_led  ={0x0000ff,1},
+                       fg_led  ={0xffff00,1},
+                       x=575,y=40,
+                       skew_y=15,
+               },
+               {
+                       name="wireless_link_qual_perc",
+                       arg="wlan0",
+                       max=100,
+                       angle=270,
+                       bg_colour={0x00ff33,0},
+                       fg_colour={0x00ff33,1},
+                       blocks=10,
+                       x=390,y=225,
+                       height=3,
+                       cap="b",
+                       angle_bar=20,
+                       radius=9,
+                       mid_colour={{0,0xFF0000,1},{0.5,0xff0000,1},{0.7,0xffff00,1},{0.85,0x00ff33,1}},
+                       smooth = true,
+                       DrawMe=conky_parse("${if_empty ${wireless_essid wlan0}}${else}1$endif"),
+               },
+               {
+                       name="wireless_link_qual_perc",
+                       arg="wlan0",
+                       max=100,
+                       angle=90,
+                       bg_colour={0x00ff33,0},
+                       fg_colour={0x00ff33,1},
+                       blocks=10,
+                       x=410,y=225,
+                       height=3,
+                       cap="b",
+                       angle_bar=20,
+                       radius=9,
+                       mid_colour={{0,0xFF0000,1},{0.5,0xff0000,1},{0.7,0xffff00,1},{0.85,0x00ff33,1}},
+                       smooth = true,
+                       DrawMe=conky_parse("${if_empty ${wireless_essid wlan0}}${else}1$endif"),
+               },      
+               {
+                       name="cell_radio_percent",
+                       arg="",
+                       max=100,
+                       bg_colour={0x00ff33,0},
+                       fg_colour={0x00ff33,1},
+                       blocks=10,
+                       x=445,
+                       y=49,
+                       height=3,
+                       cap="b",
+                       angle_bar=20,
+                       angle=90,
+                       radius=9,
+                       mid_colour={{0,0xFF0000,1},{0.5,0xff0000,1},{0.7,0xffff00,1},{0.85,0x00ff33,1}},
+                       smooth = true,
+                       --DrawMe=conky_parse("${if_up gprs0}1$endif")
+               },                                      
+       }
+          
+       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)    
+       --prevent segmentation error when reading cpu state
+    if tonumber(conky_parse('${updates}'))>3 then
+        for i in pairs(bars_settings) do
+               draw_multi_bar_graph(bars_settings[i])
+        end
+    end
+       cairo_destroy(cr)
+       cairo_surface_destroy(cs)
+       cr=nil
+end
+
+function draw_multi_bar_graph(t)
+       cairo_save(cr)
+       --check values
+       if t.DrawMe~=nil and t.DrawMe ~= "1" then return end
+       if t.name==nil and t.arg==nil then 
+               print ("No input values ... use parameters 'name' with 'arg' or only parameter 'arg' ") 
+               return
+       end
+       if t.max==nil then
+               print ("No maximum value defined, use 'max'")
+               return
+       end
+       if t.name==nil then t.name="" end
+       if t.arg==nil then t.arg="" end
+
+       --set default values    
+       if t.x == nil           then t.x = conky_window.width/2 end
+       if t.y == nil           then t.y = conky_window.height/2 end
+       if t.blocks == nil      then t.blocks=10 end
+       if t.height == nil      then t.height=10 end
+       if t.angle == nil       then t.angle=0 end
+       t.angle = t.angle*math.pi/180
+       --line cap style
+       if t.cap==nil           then t.cap = "b" end
+       local cap="b"
+       for i,v in ipairs({"s","r","b"}) do 
+               if v==t.cap then cap=v end
+       end
+       local delta=0
+       if t.cap=="r" or t.cap=="s" then delta = t.height end
+       if cap=="s" then        cap = CAIRO_LINE_CAP_SQUARE
+       elseif cap=="r" then
+               cap = CAIRO_LINE_CAP_ROUND
+       elseif cap=="b" then
+               cap = CAIRO_LINE_CAP_BUTT
+       end
+       --end line cap style
+       --if t.led_effect == nil        then t.led_effect="r" end
+       if t.width == nil       then t.width=20 end
+       if t.space == nil       then t.space=2 end
+       if t.radius == nil      then t.radius=0 end
+       if t.angle_bar == nil   then t.angle_bar=0 end
+       t.angle_bar = t.angle_bar*math.pi/360 --halt angle
+       --colours
+       if t.bg_colour == nil   then t.bg_colour = {0x00FF00,0.5} end
+       if #t.bg_colour~=2              then t.bg_colour = {0x00FF00,0.5} end
+       if t.fg_colour == nil   then t.fg_colour = {0x00FF00,1} end
+       if #t.fg_colour~=2              then t.fg_colour = {0x00FF00,1} end
+       if t.alarm_colour == nil        then t.alarm_colour = t.fg_colour end
+       if #t.alarm_colour~=2           then t.alarm_colour = t.fg_colour end
+       if t.mid_colour ~= nil then     
+               for i=1, #t.mid_colour do    
+                   if #t.mid_colour[i]~=3 then 
+                       print ("error in mid_color table")
+                       t.mid_colour[i]={1,0xFFFFFF,1} 
+                   end
+               end
+    end
+       if t.bg_led ~= nil and #t.bg_led~=2     then t.bg_led = t.bg_colour end
+       if t.fg_led ~= nil and #t.fg_led~=2     then t.fg_led = t.fg_colour end
+       if t.alarm_led~= nil and #t.alarm_led~=2 then t.alarm_led = t.fg_led end
+       if t.led_effect~=nil then
+               if t.bg_led == nil then t.bg_led = t.bg_colour end
+               if t.fg_led == nil      then t.fg_led = t.fg_colour end
+               if t.alarm_led == nil  then t.alarm_led = t.fg_led end
+       end
+       if t.alarm==nil then t.alarm = t.max end --0.8*t.max end
+       if t.smooth == nil then t.smooth = false end
+       if t.skew_x == nil then 
+               t.skew_x=0 
+       else
+               t.skew_x = math.pi*t.skew_x/180 
+       end
+       if t.skew_y == nil then 
+               t.skew_y=0
+       else
+               t.skew_y = math.pi*t.skew_y/180 
+       end
+       if t.reflection_alpha==nil then t.reflection_alpha=0 end
+       if t.reflection_length==nil then t.reflection_length=1 end
+       if t.reflection_scale==nil then t.reflection_scale=1 end
+       --end of default values
+       
+       local function rgb_to_r_g_b(col_a)
+               return ((col_a[1] / 0x10000) % 0x100) / 255., ((col_a[1] / 0x100) % 0x100) / 255., (col_a[1] % 0x100) / 255., col_a[2]
+       end
+       
+       --functions used to create patterns
+       local function create_smooth_linear_gradient(x0,y0,x1,y1)
+               local pat = cairo_pattern_create_linear (x0,y0,x1,y1)
+               cairo_pattern_add_color_stop_rgba (pat, 0, rgb_to_r_g_b(t.fg_colour))
+               cairo_pattern_add_color_stop_rgba (pat, 1, rgb_to_r_g_b(t.alarm_colour))
+               if t.mid_colour ~=nil then
+                       for i=1, #t.mid_colour do
+                               cairo_pattern_add_color_stop_rgba (pat, t.mid_colour[i][1], rgb_to_r_g_b({t.mid_colour[i][2],t.mid_colour[i][3]}))
+                       end
+               end
+               return pat
+       end
+       
+       local function create_smooth_radial_gradient(x0,y0,r0,x1,y1,r1)
+               local pat =  cairo_pattern_create_radial (x0,y0,r0,x1,y1,r1)
+               cairo_pattern_add_color_stop_rgba (pat, 0, rgb_to_r_g_b(t.fg_colour))
+               cairo_pattern_add_color_stop_rgba (pat, 1, rgb_to_r_g_b(t.alarm_colour))
+               if t.mid_colour ~=nil then
+                       for i=1, #t.mid_colour do
+                               cairo_pattern_add_color_stop_rgba (pat, t.mid_colour[i][1], rgb_to_r_g_b({t.mid_colour[i][2],t.mid_colour[i][3]}))
+                       end
+               end
+               return pat
+       end
+       
+       local function create_led_linear_gradient(x0,y0,x1,y1,col_alp,col_led)
+               local pat = cairo_pattern_create_linear (x0,y0,x1,y1) ---delta, 0,delta+ t.width,0)
+               cairo_pattern_add_color_stop_rgba (pat, 0.0, rgb_to_r_g_b(col_alp))
+               cairo_pattern_add_color_stop_rgba (pat, 0.5, rgb_to_r_g_b(col_led))
+               cairo_pattern_add_color_stop_rgba (pat, 1.0, rgb_to_r_g_b(col_alp))
+               return pat
+       end
+
+       local function create_led_radial_gradient(x0,y0,r0,x1,y1,r1,col_alp,col_led,mode)
+               local pat = cairo_pattern_create_radial (x0,y0,r0,x1,y1,r1)
+               if mode==3 then
+                       cairo_pattern_add_color_stop_rgba (pat, 0, rgb_to_r_g_b(col_alp))                               
+                       cairo_pattern_add_color_stop_rgba (pat, 0.5, rgb_to_r_g_b(col_led))
+                       cairo_pattern_add_color_stop_rgba (pat, 1, rgb_to_r_g_b(col_alp))                               
+               else
+                       cairo_pattern_add_color_stop_rgba (pat, 0, rgb_to_r_g_b(col_led))
+                       cairo_pattern_add_color_stop_rgba (pat, 1, rgb_to_r_g_b(col_alp))                               
+               end
+               return pat
+       end
+
+       local function draw_single_bar()
+               --this fucntion is used for bars with a single block (blocks=1) but 
+               --the drawing is cut in 3 blocks : value/alarm/background
+               --not zvzimzblr for circular bar
+               local function create_pattern(col_alp,col_led,bg)
+                       local pat
+                       if not t.smooth then
+                               if t.led_effect=="e" then
+                                       pat = create_led_linear_gradient (-delta, 0,delta+ t.width,0,col_alp,col_led)
+                               elseif t.led_effect=="a" then
+                                       pat = create_led_linear_gradient (t.width/2, 0,t.width/2,-t.height,col_alp,col_led)
+                               elseif  t.led_effect=="r" then
+                                       pat = create_led_radial_gradient (t.width/2, -t.height/2, 0, t.width/2,-t.height/2,t.height/1.5,col_alp,col_led,2)
+                               else
+                                       pat = cairo_pattern_create_rgba  (rgb_to_r_g_b(col_alp))
+                               end
+                       else
+                               if bg then
+                                       pat = cairo_pattern_create_rgba  (rgb_to_r_g_b(t.bg_colour))
+                               else
+                                       pat = create_smooth_linear_gradient(t.width/2, 0, t.width/2,-t.height)
+                               end
+                       end
+                       return pat
+               end
+               
+               local y1=-t.height*pct/100
+               local y2,y3=nil
+               if pct>(100*t.alarm/t.max) then 
+                       y1 = -t.height*t.alarm/100
+                       y2 = -t.height*pct/100
+                       if t.smooth then y1=y2 end
+               end
+               
+               if t.angle_bar==0 then
+               
+                       --block for fg value
+                       local pat = create_pattern(t.fg_colour,t.fg_led,false)
+                       cairo_set_source(cr,pat)
+                       cairo_rectangle(cr,0,0,t.width,y1)
+                       cairo_fill(cr)
+                       cairo_pattern_destroy(pat)
+                       -- block for alarm value                        
+                       if not t.smooth and y2 ~=nil then 
+                               pat = create_pattern(t.alarm_colour,t.alarm_led,false)
+                               cairo_set_source(cr,pat)
+                               cairo_rectangle(cr,0,y1,t.width,y2-y1)
+                               cairo_fill(cr)
+                               y3=y2
+                               cairo_pattern_destroy(pat)
+                       else
+                               y2,y3=y1,y1
+                       end
+                       -- block for bg value
+                       cairo_rectangle(cr,0,y2,t.width,-t.height-y3)
+                       pat = create_pattern(t.bg_colour,t.bg_led,true)
+                       cairo_set_source(cr,pat)
+                       cairo_pattern_destroy(pat)
+                       cairo_fill(cr)
+               end             
+       end  --end single bar
+       
+       local function draw_multi_bar()
+               --function used for bars with 2 or more blocks
+               for pt = 1,t.blocks do 
+                       --set block y
+                       local y1 = -(pt-1)*(t.height+t.space)
+                       local light_on=false
+                       
+                       --set colors
+                       local col_alp = t.bg_colour
+                       local col_led = t.bg_led
+                       if pct>=(100/t.blocks) or pct>0 then --ligth on or not the block
+                               if pct>=(pcb*(pt-1))  then 
+                                       light_on = true
+                                       col_alp = t.fg_colour
+                                       col_led = t.fg_led
+                                       if pct>=(100*t.alarm/t.max) and (pcb*pt)>(100*t.alarm/t.max) then 
+                                               col_alp = t.alarm_colour 
+                                               col_led = t.alarm_led 
+                                       end
+                               end
+                       end
+
+                       --set colors
+                       --have to try to create gradients outside the loop ?
+                       local pat 
+                       if not t.smooth then
+                               if t.angle_bar==0 then
+                                       if t.led_effect=="e" then
+                                               pat = create_led_linear_gradient (-delta, 0,delta+ t.width,0,col_alp,col_led)
+                                       elseif t.led_effect=="a" then
+                                               pat = create_led_linear_gradient (t.width/2, -t.height/2+y1,t.width/2,0+t.height/2+y1,col_alp,col_led)                                  
+                                       elseif  t.led_effect=="r" then
+                                               pat = create_led_radial_gradient (t.width/2, y1, 0, t.width/2,y1,t.width/1.5,col_alp,col_led,2) 
+                                       else
+                                               pat = cairo_pattern_create_rgba  (rgb_to_r_g_b(col_alp))
+                                       end
+                               else
+                                        if t.led_effect=="a"  then
+                                                pat = create_led_radial_gradient (0, 0, t.radius+(t.height+t.space)*(pt-1),
+                                                                                                                0, 0, t.radius+(t.height+t.space)*(pt),                                                 
+                                                                                        col_alp,col_led,3)     
+                                       else
+                                               pat = cairo_pattern_create_rgba  (rgb_to_r_g_b(col_alp))                                        
+                                       end
+                               end
+                       else
+                               if light_on then
+                                       if t.angle_bar==0 then
+                                               pat = create_smooth_linear_gradient(t.width/2, t.height/2, t.width/2,-(t.blocks-0.5)*(t.height+t.space))
+                                       else
+                                               pat = create_smooth_radial_gradient(0, 0, (t.height+t.space),  0,0,(t.blocks+1)*(t.height+t.space),2)
+                                       end
+                               else            
+                                       pat = cairo_pattern_create_rgba  (rgb_to_r_g_b(t.bg_colour))
+                               end
+                       end
+                       cairo_set_source (cr, pat)
+                       cairo_pattern_destroy(pat)
+
+                       --draw a block
+                       if t.angle_bar==0 then
+                               cairo_move_to(cr,0,y1)
+                               cairo_line_to(cr,t.width,y1)
+                       else            
+                               cairo_arc( cr,0,0,
+                                       t.radius+(t.height+t.space)*(pt)-t.height/2,
+                                        -t.angle_bar -math.pi/2 ,
+                                        t.angle_bar -math.pi/2)
+                       end
+                       cairo_stroke(cr)
+               end     
+       end
+       
+       local function setup_bar_graph()
+               --function used to retrieve the value to display and to set the cairo structure
+               if t.blocks ~=1 then t.y=t.y-t.height/2 end
+               local value = 0
+               if t.name ~="" then
+                       value = (conky_parse(string.format('${%s %s}', t.name, t.arg)))
+                       if string.match(value,"%w") then
+                               value = conky_parse(string.format('${to_bytes %s}',value))
+                       end
+                       value=tonumber(value)
+               else
+                       value = tonumber(t.arg)
+               end
+               if value==nil then value =0 end
+               pct = 100*value/t.max
+               pcb = 100/t.blocks
+               cairo_set_line_width (cr, t.height)
+               cairo_set_line_cap  (cr, cap)
+               cairo_translate(cr,t.x,t.y)
+               cairo_rotate(cr,t.angle)
+               local matrix0 = cairo_matrix_t:create()
+               tolua.takeownership(matrix0)
+               cairo_matrix_init (matrix0, 1,t.skew_y,t.skew_x,1,0,0)
+               cairo_transform(cr,matrix0)
+               --call the drawing function for blocks
+               if t.blocks==1 and t.angle_bar==0 then
+                       draw_single_bar()
+                       if t.reflection=="t" or t.reflection=="b" then cairo_translate(cr,0,-t.height) end
+               else
+                       draw_multi_bar()
+               end
+               --call the drawing function for reflection and prepare the mask used            
+               if t.reflection_alpha>0 and t.angle_bar==0 then
+                       local pat2
+                       local matrix1 = cairo_matrix_t:create()
+                       tolua.takeownership(matrix1)
+                       if t.angle_bar==0 then
+                               pts={-delta/2,(t.height+t.space)/2,t.width+delta,-(t.height+t.space)*(t.blocks)}
+                               if t.reflection=="t" then
+                                       cairo_matrix_init (matrix1,1,0,0,-t.reflection_scale,0,-(t.height+t.space)*(t.blocks-0.5)*2*(t.reflection_scale+1)/2)
+                                       pat2 = cairo_pattern_create_linear (t.width/2,-(t.height+t.space)*(t.blocks),t.width/2,(t.height+t.space)/2)
+                               elseif t.reflection=="r" then
+                                       cairo_matrix_init (matrix1,-t.reflection_scale,0,0,1,delta+2*t.width,0)
+                                       pat2 = cairo_pattern_create_linear (delta/2+t.width,0,-delta/2,0)
+                               elseif t.reflection=="l" then
+                                       cairo_matrix_init (matrix1,-t.reflection_scale,0,0,1,-delta,0)
+                                       pat2 = cairo_pattern_create_linear (-delta/2,0,delta/2+t.width,-0)
+                               else --bottom
+                                       cairo_matrix_init (matrix1,1,0,0,-1*t.reflection_scale,0,(t.height+t.space)*(t.reflection_scale+1)/2)
+                                       pat2 = cairo_pattern_create_linear (t.width/2,(t.height+t.space)/2,t.width/2,-(t.height+t.space)*(t.blocks))
+                               end
+                       end
+                       cairo_transform(cr,matrix1)
+                       if t.blocks==1 and t.angle_bar==0 then
+                               draw_single_bar()
+                               cairo_translate(cr,0,-t.height/2) 
+                       else
+                               draw_multi_bar()
+                       end
+                       cairo_set_line_width(cr,0.01)
+                       cairo_pattern_add_color_stop_rgba (pat2, 0,0,0,0,1-t.reflection_alpha)
+                       cairo_pattern_add_color_stop_rgba (pat2, t.reflection_length,0,0,0,1)
+                       if t.angle_bar==0 then
+                               cairo_rectangle(cr,pts[1],pts[2],pts[3],pts[4])
+                       end
+                       cairo_clip_preserve(cr)
+                       cairo_set_operator(cr,CAIRO_OPERATOR_CLEAR)
+                       cairo_stroke(cr)
+                       cairo_mask(cr,pat2)
+                       cairo_pattern_destroy(pat2)
+                       cairo_set_operator(cr,CAIRO_OPERATOR_OVER)
+               end --reflection
+       pct,pcb=nil
+       end --setup_bar_graph()
+
+       --start here !
+       setup_bar_graph()
+       cairo_restore(cr)
+end
+
diff --git a/data/box.lua b/data/box.lua
new file mode 100644 (file)
index 0000000..4eda773
--- /dev/null
@@ -0,0 +1,309 @@
+--[[BOX WIDGET v1.0 by Wlourf 19/12/2010
+This widget can drawn some boxes, even circles in your conky window
+http://u-scripts.blogspot.com/ (HowTo coming soon)
+
+Inspired by Background by londonali1010 (2009)
+
+The parameters (all optionals) are :
+x           - x coordinate of top-left corner of the box, default = 0 = (top-left corner of conky window)
+y           - y coordinate of top-left corner of the box, default = 0 = (top-left corner of conky window)
+w           - width of the box, default = width of the conky window
+h           - height of the box, default = width of the conky window
+radius      - radius of the corner, default = 0 = no radius
+mode        - mode for drawing the radius, possible values are "circle" or "curve", default ="curve"
+linear_gradient - table with the coordinates of two points to define a linear gradient,
+                  points are relative to top-left corner of the box, (not the conky window)
+                  {x1,y1,x2,y2}
+radial_gradient - table with the coordinates of two circle to define a radial gradient,
+             colour={{0,0xCCCCCC,1},{1,0xCCCCCC,0}}     points are relative to top-left corner of the box, (not the conky window)
+                  {x1,y1,r1,x2,y2,r2} (r=radius)
+colour      - table of colours, default = plain white {{1,0xFFFFFF,1}}
+              this table contains one or more tables with format {P,C,A}
+              P=position of gradient (0 = start of the gradient, 1= end of the gradient)
+              C=hexadecimal colour 
+              A=alpha (opacity) of color (0=invisible,1=opacity 100%)
+              Examples :
+              for a plain color {{1,0x00FF00,0.5}}
+              for a gradient with two colours {{0,0x00FF00,0.5},{1,0x000033,1}}
+              or {{0.5,0x00FF00,1},{1,0x000033,1}} -with this one, gradient will start in the middle
+              for a gradient with three colours {{0,0x00FF00,0.5},{0.5,0x000033,1},{1,0x440033,1}}
+              and so on ...
+
+
+
+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 main_box
+    
+And leave one line blank or not after TEXT
+
+Changelog:
++ v1.0 -- Original release (19.12.2010)
+]]
+
+-- Change these settings to affect your background.
+
+table_settings={
+    {   
+        x=5,
+        y=57,
+        h=40,
+        w=650,
+        linear_gradient = {300,200,550,350},
+        colour = {{0,0x000000,0.5},{1,0x000000,0.5}},
+        radius=20,
+    },
+    {   
+        x=315,
+        y=100,
+        h=90,
+        w=485,
+        linear_gradient = {300,200,550,350},
+        colour = {{0,0x000000,0.2},{1,0x000000,0.1}},
+        radius=20,
+    },
+    {   
+        x=5,
+        y=192,
+        h=44,
+        w=795,
+        linear_gradient = {300,200,550,350},
+        colour = {{0,0x000000,0.4},{1,0x000000,0.1}},
+        radius=20,
+    },
+    {   
+        x=5,
+        y=355,
+        h=125,
+        w=795,
+        colour = {{0,0x000000,0.25}},
+        radius=20,
+     },
+    {   
+        x=5,
+        y=240,
+        h=110,
+        w=795,
+        colour = {{0,0x000000,0.4}},
+        radius=20,
+    },
+
+--[[
+    { --backgound with gradient
+        radius=25,
+        mode="circle",
+        linear_gradient = {300,200,550,350},
+        colour={{0,0xCCCCCC,1},{1,0xCCCCCC,0}}
+    },
+
+
+
+
+    { --pink rounded box
+        x=25,
+        y=150,
+        h=200,
+        w=100,
+        colour = {{O,0xff00ff,0.5}},
+        radius=30,
+        mode="circle"
+     }, 
+    { --border for pink rounded box
+        x=25,
+        y=150,
+        h=200,
+        w=100,
+        radius=30,
+        border=3,
+        mode="circle",
+        colour={
+                {0,0x0000CC,1},
+                },    
+         },
+     
+    {  --box with linear gradient
+        x=150,
+        y=150,
+        h=100,
+        w=100,
+        linear_gradient = {50,0,50,100 },
+        colour={
+                    {0,0xffff00,1},
+                    {0.5,0xff0000,1},                
+                    {1,0xff00ff,1},
+        },   
+     },
+     
+     { --box with radial gradient
+        x=150,
+        y=270,
+        h=100,
+        w=100,
+        radius=10,
+        radial_gradient = {20,20,0,20,20,100 },
+        colour={
+                    {0,0xff0000,1},
+                    {1,0xffff00,1},
+                    },   
+        mode="circle",
+        border=0
+     },
+    { --border for above box --gradient are inversed
+        x=150,
+        y=270,
+        h=100,
+        w=100,
+        radius=10,
+        radial_gradient = {20,20,0,20,20,100 },
+        colour={
+                    {1,0xff0000,1},
+                    {0,0xffff00,1},
+                    },   
+        mode="circle",
+        border=5
+     },
+
+
+    { --oh my god, a circle with radial gradient
+        x=300, y=30,
+        w=100,h=100,
+        mode="circle",
+        radius=50,
+        radial_gradient = {50,50,0,50,50,50 },        
+        colour={
+            {0,0xff0000,1},
+            {1,0xffff00,1},
+            },         
+    },
+
+    { --no name for this one ! radius > w or h !
+        x=300, y=250,
+        w=100,h=100,
+        mode="circle",
+        radius=100,
+        radial_gradient = {50,50,0,50,50,50 },        
+        colour={
+            {0,0xff0000,1},
+            {0.5,0x0000ff,1},            
+            {1,0xffff00,1},
+            }, 
+    },
+]]
+
+
+  }
+
+---------END OF PARAMETERS
+    
+require 'cairo'
+
+
+    
+function conky_main_box()
+    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)
+    
+    for i in pairs(table_settings) do
+        draw_bg (table_settings[i])
+    end
+    
+    cairo_destroy(cr)
+    cairo_surface_destroy(cs)    
+end
+    
+function draw_bg(t)
+    function rgba_to_r_g_b_a(tc)
+        --tc={position,colour,alpha}
+        local colour = tc[2]
+        local alpha = tc[3]
+        return ((colour / 0x10000) % 0x100) / 255., ((colour / 0x100) % 0x100) / 255., (colour % 0x100) / 255., alpha
+    end
+
+    local PI = math.pi
+
+    --check values and set default values
+    if t.x == nil then t.x = 0 end
+    if t.y == nil then t.y = 0 end
+    if t.w == nil then t.w = conky_window.width end
+    if t.h == nil then t.h = conky_window.height end
+    if t.radius == nil then t.radius = 0 end
+    if t.border == nil then t.border = 0 end
+    if t.colour==nil then t.colour={{1,0xFFFFFF,1}} end
+    if t.linear_gradient ~= nil then 
+        if #t.linear_gradient ~= 4 then
+            t.linear_gradient = {t.x,t.y,t.width,t.height}
+        end
+    end 
+    if t.radial_gradient ~= nil then 
+        if #t.radial_gradient ~= 6 then
+            t.radial_gradient = {t.x,t.y,0, t.x,t.y, t.width}
+        end
+    end 
+    
+    for i=1, #t.colour do    
+        if #t.colour[i]~=3 then 
+            print ("error in color table")
+            t.colour[i]={1,0xFFFFFF,1} 
+        end
+    end
+
+    --for better reading
+    t.linear = t.linear_gradient
+    t.radial = t.radial_gradient
+    t.no_gradient = (t.linear == nil ) and (t.radial == nil )
+
+    cairo_save(cr)
+    cairo_translate(cr, t.x, t.y)
+
+    if t.radius>0 then
+        if t.mode=="circle" then
+            cairo_arc(cr, t.radius, t.radius, t.radius, -PI, -PI/2)
+            cairo_line_to(cr,t.w-t.radius,0)
+            cairo_arc(cr, t.w-t.radius, t.radius, t.radius, -PI/2,0)
+            cairo_line_to(cr,t.w,t.h-t.radius)
+            cairo_arc(cr, t.w-t.radius, t.h-t.radius, t.radius, 0,PI/2)
+            cairo_line_to(cr,t.radius,t.h)
+            cairo_arc(cr, t.radius, t.h-t.radius, t.radius, PI/2,-PI)        
+            cairo_line_to(cr,0,t.radius) 
+        else
+            cairo_move_to(cr,   t.radius,     0)
+            cairo_line_to(cr,   t.w-t.radius, 0)
+            cairo_curve_to(cr,  t.w,    0,  t.w,    0,  t.w,    t.radius)
+            cairo_line_to(cr,   t.w,    t.h-t.radius)
+            cairo_curve_to(cr,  t.w,    t.h,    t.w,    t.h,    t.w -   t.radius, t.h)
+            cairo_line_to(cr,   t.radius, t.h)
+            cairo_curve_to(cr,  0,  t.h,    0,  t.h,    0,  t.h-t.radius)
+            cairo_line_to(cr,   0,  t.radius)
+            cairo_curve_to(cr,  0,  0,  0,  0,  t.radius,0)
+        end
+        cairo_close_path(cr)
+    else
+        cairo_rectangle(cr,0,0,t.w,t.h)
+    end
+    
+    if t.no_gradient then
+        cairo_set_source_rgba(cr,rgba_to_r_g_b_a(t.colour[1]))
+    else
+        if t.linear ~= nil then
+            pat = cairo_pattern_create_linear (t.linear[1],t.linear[2],t.linear[3],t.linear[4])
+        elseif t.radial ~= nil then
+            pat = cairo_pattern_create_radial (t.radial[1],t.radial[2],t.radial[3],t.radial[4],t.radial[5],t.radial[6])
+        end
+        for i=1, #t.colour do
+            cairo_pattern_add_color_stop_rgba (pat, t.colour[i][1], rgba_to_r_g_b_a(t.colour[i]))
+        end
+        cairo_set_source (cr, pat)
+        cairo_pattern_destroy(pat)
+    end
+    
+    if t.border>0 then
+        cairo_set_line_width(cr,t.border)
+        cairo_stroke(cr)
+    else
+        cairo_fill(cr)
+    end
+    
+    cairo_restore(cr)
+end
+
index ff650e6..610540b 100644 (file)
@@ -1,18 +1,15 @@
-# cpu red    > white                                                                                                
-# memory blue  > white                                                                                                   
-# disk green > white                                                                                                    
-#                                                                                                     
-#                                                                                                     
-#                                                                                                     
-# cool blue > cyan: 0000ff 00FFFF                                                                                  
-#                                                                                                     
+#don't modify this file directly because an update could overwrite your changes!
+#copy any files you modify to /home/user/MyDocs and update the path below and also in the loadAll.lua file
+#conky will load the .conf file from there unless you are using mass storage usb at that moment
+
+lua_load /etc/conky/LoadAll.lua
+lua_draw_hook_pre main
 
 alignment top_left
 background no
-maximum_width 800
+maximum_width 854
 border_width 1
 cpu_avg_samples 2
-default_color white
 default_outline_color white
 default_shade_color white
 diskio_avg_samples 10
@@ -31,7 +28,7 @@ own_window yes
 own_window_class Conky
 own_window_type normal
 own_window_transparent no
-own_window_hints undecorated
+own_window_hints fullscreen
 #own_window_colour ff0000
 override_utf8_locale yes
 show_graph_scale no
@@ -44,51 +41,34 @@ update_interval_on_battery 4
 uppercase no
 use_spacer none
 use_xft yes
-xftfont Droid Sans Mono:size=11
+xftfont Nokia Pure:size=11
 xftalpha 0.8
 
+default_color FFFFFF
+
 TEXT
-${color       }$alignr$sysname $kernel on $machine ${color 4072a5}Uptime:$color $uptime
-${color       }$alignr${color #4072a5}Battery: ${color}${battery_short} ${battery_temp}°C ${battery_volts}mV
-${color       }$alignr${color #4072a5}Cell Radio: $color ${cell_radio_dbm}dBm ${cell_radio_percent}%
-${color 4072a5}CPU:${goto 45}${color red}${voffset 2}${cpubar cpu0 14,240}${goto 300}${color 4072a5}Load 1/5/15:$color $loadavg $alignr ${color 4072a5}Processes:$color $processes ${color 4072a5}Running:$color $running_processes
-${color       }${alignr 460}${voffset -20}$cpu%${voffset 0}#can't alignr two things on the same line. alignr is the only way to get the % symbol to stay lined up. it will move if you use goto
-${color       }${goto 119}$freq MHz
-${color 4072a5}CPU:${color black}${cpugraph 16,240 ffffff ff0000 -t}${color 4072a5}${goto 300}Load1 avg:${color black}${loadgraph 16,105 ffffff ff0000 -t -1}${color 4072a5} Dio:${color black}${diskiograph /dev/mmcblk0 16,105 ffffff 00ff00 -t -1}${color 4072a5} Mem:${color black}${memgraph 16,105 ffffff 0000ff -t}
-${color 4072a5}RAM:${goto 47}${color blue}${voffset 2}${membar 16,240}
-${color       }${voffset -20}${goto 110}$mem${goto 160}/ $memmax
-${color       }${alignr 525}${voffset -18}$memperc%
-${color 4072a5}${voffset -18}${goto 315} Top I/O ${goto 480}READ ${goto 550}WRITE ${goto 630}%
-${color 4072a5}Swap:${goto 48}${color green}${swapbar 16,240}                     
-${color       }${voffset -19}${goto 110}$swap${goto 160}/ $swapmax
-${color       }${alignr 525}${voffset -18}$swapperc%
-${color red}${voffset -18}${goto 315} ${top_io name 1} ${goto 480}${top_io io_read 1}${goto 550}${top_io io_write 1}${goto 610}${top_io io_perc 1}
-${color 4072a5}rootfs:${goto 70}${color darkgreen}${fs_bar 16,240 /}
-${color       }${voffset -18}${goto 110}${fs_used /}${goto 160}/ ${fs_size /}
-${color       }${alignr 490}${voffset -20}(${fs_free /})
-${color       }${voffset -18}${goto 315} ${top_io name 2} ${goto 480}${top_io io_read 2}${goto 550}${top_io io_write 2}${goto 610}${top_io io_perc 2}
-${color 4072a5}home:${goto 70}${color darkgreen}${fs_bar 16,240 /home}
-${color       }${voffset -19}${goto 110}${fs_used /home}${goto 160}/ ${fs_size /home}
-${color       }${alignr 490}${voffset -20}(${fs_free /home})
-${color       }${voffset -18}${goto 315} ${top_io name 3} ${goto 480}${top_io io_read 3}${goto 550}${top_io io_write 3}${goto 610}${top_io io_perc 3}
-${voffset 1}${if_mounted /home/user/MyDocs}${color 4072a5}MyDocs:${goto 70}${color darkgreen}${fs_bar 16,240 /home/user/MyDocs}
-${color       }${voffset -19}${goto 110}${fs_used /home/user/MyDocs}${goto 160}/ ${fs_size /home/user/MyDocs}
-${color       }${alignr 490}${voffset -19}(${fs_free /home/user/MyDocs})$endif
-${if_mounted /media/mmc1}${color 4072a5}MicroSD:${goto 70}${color darkgreen}${fs_bar 16,240 /media/mmc1}
-${color       }${voffset -18}${goto 110}${fs_used /media/mmc1}${goto 160}/ ${fs_size /media/mmc1}
-${color       }${alignr 490}${voffset -20}(${fs_free /media/mmc1})$endif
-${if_up gprs0}${color 4072a5}gprs0: ${color 4072a5}Up:$color ${upspeed gprs0}/s ${color 4072a5}Down:$color ${downspeed gprs0}/s 
-${color 4072a5}gprs0 Up: ${color black}${upspeedgraph gprs0 20,290 ff0000 00ff00}$alignr${color 4072a5}gprs0 Down: ${color black}${downspeedgraph gprs0 20,290 00ff0000 ff0000}$else${if_empty ${wireless_essid wlan0}}$else${color #4072a5}wlan0 ESSID: $color${wireless_essid wlan0} ${color #4072a5}Rate: ${color}${wireless_bitrate wlan0} ${color #4072a5}Connection Quality: $color${wireless_link_qual_perc wlan0}% ${color #4072a5}Up:$color ${upspeed wlan0}/s ${color grey} ${color #4072a5}Down:$color ${downspeed wlan0}/s 
-${color 4072a5}wlan0 Up: ${color black}${upspeedgraph wlan0 20,290 00ff00 ff0000}$alignr${color 4072a5}wlan0 Down: ${color black}${downspeedgraph wlan0 20,290 ff0000 00ff00}$endif$endif
-${color 4072a5}CONNECTIONS [$color${tcp_portmon 1 65535 count}${color 4072a5}] (lport:rservice:rport):$color                                            ${goto 405}${tcp_portmon 1 65535 lservice 0}${goto 450}:${scroll 32 5${tcp_portmon 1 65535 rhost 0}}${goto 744}:${scroll 5 1 ${tcp_portmon 1 65535 rservice 0}}
+${image /etc/conky/n950-kobol.jpg}
+
+
+${goto 265}${color 4072a5}Load1 avg: ${goto 517}${color 4072a5}Processes:$color $processes
+${color 4072a5}${goto 265}Load 1/5/15: $color$loadavg${goto 517}${color 4072a5}Running:${goto 620}$color$running_processes
+${voffset -10}
+${color 4072a5}${goto 315} Top I/O         READ  WRITE      %
+${color red}   ${goto 315} ${lua_parse top_io_colour 1}
+${color       }${goto 315} ${lua_parse top_io_colour 2}
+${color       }${goto 315} ${lua_parse top_io_colour 3}
+
+
+${voffset 10}
+${color 33cc99}CONNECTIONS [$color${tcp_portmon 1 65535 count}${color 33cc99}] (lport:rservice:rport):$color                                            ${goto 405}${tcp_portmon 1 65535 lservice 0}${goto 450}:${scroll 32 5${tcp_portmon 1 65535 rhost 0}}${goto 744}:${scroll 5 1 ${tcp_portmon 1 65535 rservice 0}}
 $color${tcp_portmon 1 65535 lservice 1}${goto 50}:${scroll 32 5${tcp_portmon 1 65535 rhost 1}}${goto 345}:${scroll 5 2${tcp_portmon 1 65535 rservice 1}}${goto 405}${tcp_portmon 1 65535 lservice 2}${goto 450}:${scroll 32 5${tcp_portmon 1 65535 rhost 2}}${goto 744}:${scroll 5 1 ${tcp_portmon 1 65535 rservice 2}}
 $color${tcp_portmon 1 65535 lservice 3}${goto 50}:${scroll 32 5${tcp_portmon 1 65535 rhost 3}}${goto 345}:${scroll 5 2${tcp_portmon 1 65535 rservice 3}}${goto 405}${tcp_portmon 1 65535 lservice 4}${goto 450}:${scroll 32 5${tcp_portmon 1 65535 rhost 4}}${goto 744}:${scroll 5 1 ${tcp_portmon 1 65535 rservice 4}}
 $color${tcp_portmon 1 65535 lservice 5}${goto 50}:${scroll 32 5${tcp_portmon 1 65535 rhost 5}}${goto 345}:${scroll 5 2${tcp_portmon 1 65535 rservice 5}}${goto 405}${tcp_portmon 1 65535 lservice 6}${goto 450}:${scroll 32 5${tcp_portmon 1 65535 rhost 6}}${goto 744}:${scroll 5 1 ${tcp_portmon 1 65535 rservice 6}}
 $color${tcp_portmon 1 65535 lservice 7}${goto 50}:${scroll 32 5${tcp_portmon 1 65535 rhost 7}}${goto 345}:${scroll 5 2${tcp_portmon 1 65535 rservice 7}}${goto 405}${tcp_portmon 1 65535 lservice 8}${goto 450}:${scroll 32 5${tcp_portmon 1 65535 rhost 8}}${goto 744}:${scroll 5 1 ${tcp_portmon 1 65535 rservice 8}}
-${color 4072a5}Top CPU%          CPU%  MEM%       ${goto 257}${color 4072a5} | ${color 4072a5}Top Total Memory  RAM     VM                               ${goto 555}${color 4072a5}| ${color 4072a5}Top CPU TIME     MM:SS.cs
-${color red}${top name 1}${top cpu 1}${top mem 1} ${goto 257}${color 4072a5} | ${color red}${top_mem name 1}${top_mem mem_res 1}  ${top_mem mem_vsize 1} ${goto 555}${color 4072a5}| ${color red}${top_time name 1}${top_time time 1} ${top_time cpu 1}
-$color${top name 2}${top cpu 2}${top mem 2}       ${goto 257}${color 4072a5} | ${color    }${top_mem name 2}${top_mem mem_res 2}  ${top_mem mem_vsize 2} ${goto 555}${color 4072a5}| ${color    }${top_time name 2}${top_time time 2} ${top_time cpu 2}
-$color${top name 3}${top cpu 3}${top mem 3}       ${goto 257}${color 4072a5} | ${color    }${top_mem name 3}${top_mem mem_res 3}  ${top_mem mem_vsize 3} ${goto 555}${color 4072a5}| ${color    }${top_time name 3}${top_time time 3} ${top_time cpu 3}
-$color${top name 4}${top cpu 4}${top mem 4}       ${goto 257}${color 4072a5} | ${color    }${top_mem name 4}${top_mem mem_res 4}  ${top_mem mem_vsize 4} ${goto 555}${color 4072a5}| ${color    }${top_time name 4}${top_time time 4} ${top_time cpu 4}
-$color---------1---------2---------3---------4---------5---------6---------7---------8---------9---------0---------1
-#imagetest: ${image /home/user/image-test.png -p 100,410}
+$color${tcp_portmon 1 65535 lservice 9}${goto 50}:${scroll 32 5${tcp_portmon 1 65535 rhost 9}}${goto 345}:${scroll 5 2${tcp_portmon 1 65535 rservice 9}}${goto 405}${tcp_portmon 1 65535 lservice 10}${goto 450}:${scroll 32 5${tcp_portmon 1 65535 rhost 10}}${goto 744}:${scroll 5 1 ${tcp_portmon 1 65535 rservice 10}}
+${voffset 10}${color 4072a5}Top CPU%          CPU%  MEM%       ${goto 257}${color 4072a5} | ${color 4072a5}Top Total Memory  RAM     VM                              ${goto 555}${color 4072a5}| ${color 4072a5}Top CPU TIME     MM:SS.cs
+${lua_parse top_cpu_colour 1}                     ${goto 257}${color 4072a5} | ${lua_parse top_mem_colour 1}                                                                                                                                                    ${goto 555}${color 4072a5}| ${color    }${top_time name 1}${top_time time 1} ${top_time cpu 1}
+$color${top name 2}${top cpu 2}${top mem 2}       ${goto 257}${color 4072a5} | ${lua_parse top_mem_colour 2}                                                                                                                                                                    ${goto 555}${color 4072a5}| ${color    }${top_time name 2}${top_time time 2} ${top_time cpu 2}
+$color${top name 3}${top cpu 3}${top mem 3}       ${goto 257}${color 4072a5} | ${lua_parse top_mem_colour 3}                                                                                                                                                                    ${goto 555}${color 4072a5}| ${color    }${top_time name 3}${top_time time 3} ${top_time cpu 3}
+$color${top name 4}${top cpu 4}${top mem 4}       ${goto 257}${color 4072a5} | ${lua_parse top_mem_colour 4}                                                                                                                                                                    ${goto 555}${color 4072a5}| ${color    }${top_time name 4}${top_time time 4} ${top_time cpu 4}
+$color${top name 5}${top cpu 5}${top mem 5}       ${goto 257}${color 4072a5} | ${lua_parse top_mem_colour 5}                                                                                                                                                                    ${goto 555}${color 4072a5}| ${color    }${top_time name 5}${top_time time 5} ${top_time cpu 5}
diff --git a/data/conky.conf.nolua b/data/conky.conf.nolua
new file mode 100644 (file)
index 0000000..bd7607d
--- /dev/null
@@ -0,0 +1,96 @@
+# this is the non-lua conf file, please don't modify it directly -- copy it to /home/user/MyDocs instead. conky.sh looks for it there and will load it instead.
+# if you modify it directly, it can get replaced and your changes lost when you update, so make sure to back it up!!!
+# cpu red    > white                                                                                                
+# memory blue  > white                                                                                                   
+# disk green > white                                                                                                    
+#                                                                                                     
+#                                                                                                     
+#                                                                                                     
+# cool blue > cyan: 0000ff 00FFFF                                                                                  
+#                                                                                                     
+
+alignment top_left
+background no
+maximum_width 854
+border_width 1
+cpu_avg_samples 2
+default_color white
+default_outline_color white
+default_shade_color white
+diskio_avg_samples 10
+draw_borders no
+draw_graph_borders yes
+draw_outline no
+draw_shades no
+double_buffer yes
+gap_x 20
+gap_y 60
+minimum_size 5 5
+net_avg_samples 2
+no_buffers yes
+out_to_console no
+own_window yes
+own_window_class Conky
+own_window_type normal
+own_window_transparent no
+own_window_hints fullscreen
+#own_window_colour ff0000
+override_utf8_locale yes
+show_graph_scale no
+show_graph_range no
+short_units yes
+stippled_borders 0
+temperature_unit celsius
+update_interval 1.5
+update_interval_on_battery 4
+uppercase no
+use_spacer none
+use_xft yes
+xftfont Nokia Pure:size=11
+xftalpha 0.8
+
+TEXT
+${color       }$alignr$sysname $kernel on $machine ${color 4072a5}Uptime:$color $uptime
+${color       }$alignr${color #4072a5}Battery: ${color}${battery_short} ${battery_temp}°C ${battery_volts}mV
+${color       }$alignr${color #4072a5}Cell Radio: $color ${cell_radio_dbm}dBm ${cell_radio_percent}%
+${color 4072a5}CPU:${goto 45}${color red}${voffset 2}${cpubar cpu0 14,240}${goto 300}${color 4072a5}Load 1/5/15:$color $loadavg $alignr ${color 4072a5}Processes:$color $processes ${color 4072a5}Running:$color $running_processes
+${color       }${alignr 460}${voffset -20}$cpu%${voffset 0}#can't alignr two things on the same line. alignr is the only way to get the % symbol to stay lined up. it will move if you use goto
+${color       }${goto 119}$freq MHz
+${color 4072a5}CPU:${color black}${cpugraph 16,240 ffffff ff0000 -t}${color 4072a5}${goto 300}Load1 avg:${color black}${loadgraph 16,105 ffffff ff0000 -t -1}${color 4072a5} Dio:${color black}${diskiograph /dev/mmcblk0 16,105 ffffff 00ff00 -t -1}${color 4072a5} Mem:${color black}${memgraph 16,105 ffffff 0000ff -t}
+${color 4072a5}RAM:${goto 47}${color blue}${voffset 2}${membar 16,240}
+${color       }${voffset -20}${goto 110}$mem${goto 160}/ $memmax
+${color       }${alignr 525}${voffset -18}$memperc%
+${color 4072a5}${voffset -18}${goto 315} Top I/O ${goto 480}READ ${goto 550}WRITE ${goto 630}%
+${color 4072a5}Swap:${goto 48}${color green}${swapbar 16,240}                     
+${color       }${voffset -19}${goto 110}$swap${goto 160}/ $swapmax
+${color       }${alignr 525}${voffset -18}$swapperc%
+${color red}${voffset -18}${goto 315} ${top_io name 1} ${goto 480}${top_io io_read 1}${goto 550}${top_io io_write 1}${goto 610}${top_io io_perc 1}
+${color 4072a5}rootfs:${goto 70}${color darkgreen}${fs_bar 16,240 /}
+${color       }${voffset -18}${goto 110}${fs_used /}${goto 160}/ ${fs_size /}
+${color       }${alignr 490}${voffset -20}(${fs_free /})
+${color       }${voffset -18}${goto 315} ${top_io name 2} ${goto 480}${top_io io_read 2}${goto 550}${top_io io_write 2}${goto 610}${top_io io_perc 2}
+${color 4072a5}home:${goto 70}${color darkgreen}${fs_bar 16,240 /home}
+${color       }${voffset -19}${goto 110}${fs_used /home}${goto 160}/ ${fs_size /home}
+${color       }${alignr 490}${voffset -20}(${fs_free /home})
+${color       }${voffset -18}${goto 315} ${top_io name 3} ${goto 480}${top_io io_read 3}${goto 550}${top_io io_write 3}${goto 610}${top_io io_perc 3}
+${voffset 1}${if_mounted /home/user/MyDocs}${color 4072a5}MyDocs:${goto 70}${color darkgreen}${fs_bar 16,240 /home/user/MyDocs}
+${color       }${voffset -19}${goto 110}${fs_used /home/user/MyDocs}${goto 160}/ ${fs_size /home/user/MyDocs}
+${color       }${alignr 490}${voffset -19}(${fs_free /home/user/MyDocs})$endif
+#${if_mounted /media/mmc1}${color 4072a5}MicroSD:${goto 70}${color darkgreen}${fs_bar 16,240 /media/mmc1}
+#${color       }${voffset -18}${goto 110}${fs_used /media/mmc1}${goto 160}/ ${fs_size /media/mmc1}
+#${color       }${alignr 490}${voffset -20}(${fs_free /media/mmc1})$endif
+${if_up gprs0}${color 4072a5}gprs0: ${color 4072a5}Up:$color ${upspeed gprs0}/s ${color 4072a5}Down:$color ${downspeed gprs0}/s 
+${color 4072a5}gprs0 Up: ${color black}${upspeedgraph gprs0 20,290 ff0000 00ff00}$alignr${color 4072a5}gprs0 Down: ${color black}${downspeedgraph gprs0 20,290 00ff0000 ff0000}$else${if_empty ${wireless_essid wlan0}}$else${color #4072a5}wlan0 ESSID: $color${wireless_essid wlan0} ${color #4072a5}Rate: ${color}${wireless_bitrate wlan0} ${color #4072a5}Connection Quality: $color${wireless_link_qual_perc wlan0}% ${color #4072a5}Up:$color ${upspeed wlan0}/s ${color grey} ${color #4072a5}Down:$color ${downspeed wlan0}/s 
+${color 4072a5}wlan0 Up: ${color black}${upspeedgraph wlan0 20,290 00ff00 ff0000}$alignr${color 4072a5}wlan0 Down: ${color black}${downspeedgraph wlan0 20,290 ff0000 00ff00}$endif$endif
+${color 4072a5}CONNECTIONS [$color${tcp_portmon 1 65535 count}${color 4072a5}] (lport:rservice:rport):$color                                            ${goto 405}${tcp_portmon 1 65535 lservice 0}${goto 450}:${scroll 32 5${tcp_portmon 1 65535 rhost 0}}${goto 744}:${scroll 5 1 ${tcp_portmon 1 65535 rservice 0}}
+$color${tcp_portmon 1 65535 lservice 1}${goto 50}:${scroll 32 5${tcp_portmon 1 65535 rhost 1}}${goto 345}:${scroll 5 2${tcp_portmon 1 65535 rservice 1}}${goto 405}${tcp_portmon 1 65535 lservice 2}${goto 450}:${scroll 32 5${tcp_portmon 1 65535 rhost 2}}${goto 744}:${scroll 5 1 ${tcp_portmon 1 65535 rservice 2}}
+$color${tcp_portmon 1 65535 lservice 3}${goto 50}:${scroll 32 5${tcp_portmon 1 65535 rhost 3}}${goto 345}:${scroll 5 2${tcp_portmon 1 65535 rservice 3}}${goto 405}${tcp_portmon 1 65535 lservice 4}${goto 450}:${scroll 32 5${tcp_portmon 1 65535 rhost 4}}${goto 744}:${scroll 5 1 ${tcp_portmon 1 65535 rservice 4}}
+$color${tcp_portmon 1 65535 lservice 5}${goto 50}:${scroll 32 5${tcp_portmon 1 65535 rhost 5}}${goto 345}:${scroll 5 2${tcp_portmon 1 65535 rservice 5}}${goto 405}${tcp_portmon 1 65535 lservice 6}${goto 450}:${scroll 32 5${tcp_portmon 1 65535 rhost 6}}${goto 744}:${scroll 5 1 ${tcp_portmon 1 65535 rservice 6}}
+$color${tcp_portmon 1 65535 lservice 7}${goto 50}:${scroll 32 5${tcp_portmon 1 65535 rhost 7}}${goto 345}:${scroll 5 2${tcp_portmon 1 65535 rservice 7}}${goto 405}${tcp_portmon 1 65535 lservice 8}${goto 450}:${scroll 32 5${tcp_portmon 1 65535 rhost 8}}${goto 744}:${scroll 5 1 ${tcp_portmon 1 65535 rservice 8}}
+${color 4072a5}Top CPU%          CPU%  MEM%       ${goto 257}${color 4072a5} | ${color 4072a5}Top Total Memory  RAM     VM                               ${goto 555}${color 4072a5}| ${color 4072a5}Top CPU TIME     MM:SS.cs
+${color red}${top name 1}${top cpu 1}${top mem 1} ${goto 257}${color 4072a5} | ${color red}${top_mem name 1}${top_mem mem_res 1}  ${top_mem mem_vsize 1} ${goto 555}${color 4072a5}| ${color red}${top_time name 1}${top_time time 1} ${top_time cpu 1}
+$color${top name 2}${top cpu 2}${top mem 2}       ${goto 257}${color 4072a5} | ${color    }${top_mem name 2}${top_mem mem_res 2}  ${top_mem mem_vsize 2} ${goto 555}${color 4072a5}| ${color    }${top_time name 2}${top_time time 2} ${top_time cpu 2}
+$color${top name 3}${top cpu 3}${top mem 3}       ${goto 257}${color 4072a5} | ${color    }${top_mem name 3}${top_mem mem_res 3}  ${top_mem mem_vsize 3} ${goto 555}${color 4072a5}| ${color    }${top_time name 3}${top_time time 3} ${top_time cpu 3}
+$color${top name 4}${top cpu 4}${top mem 4}       ${goto 257}${color 4072a5} | ${color    }${top_mem name 4}${top_mem mem_res 4}  ${top_mem mem_vsize 4} ${goto 555}${color 4072a5}| ${color    }${top_time name 4}${top_time time 4} ${top_time cpu 4}
+$color---------1---------2---------3---------4---------5---------6---------7---------8---------9---------0---------1
+#imagetest: ${image /home/user/image-test.png -p 100,410}
diff --git a/data/conky_no_x11.conf b/data/conky_no_x11.conf
deleted file mode 100644 (file)
index 2799245..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-# 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/>.
-#
-
-background no
-cpu_avg_samples 2
-net_avg_samples 2
-no_buffers yes
-out_to_stderr no
-update_interval 1.0
-uppercase no
-use_spacer none
-
-TEXT
-${scroll 16 $nodename - $sysname $kernel on $machine | }
-Uptime: $uptime
-Frequency (in MHz): $freq
-Frequency (in GHz): $freq_g
-RAM Usage: $mem/$memmax - $memperc% ${membar 4}
-Swap Usage: $swap/$swapmax - $swapperc% ${swapbar 4}
-CPU Usage: $cpu% ${cpubar 4}
-Processes: $processes  Running: $running_processes
-File systems:
- / ${fs_used /}/${fs_size /} ${fs_bar 6 /}
-Networking:
-Up: ${upspeed eth0}  - Down: ${downspeed eth0}
-Name              PID   CPU%   MEM%
- ${top name 1} ${top pid 1} ${top cpu 1} ${top mem 1}
- ${top name 2} ${top pid 2} ${top cpu 2} ${top mem 2}
- ${top name 3} ${top pid 3} ${top cpu 3} ${top mem 3}
- ${top name 4} ${top pid 4} ${top cpu 4} ${top mem 4}
diff --git a/data/graph.lua b/data/graph.lua
new file mode 100644 (file)
index 0000000..dbff1d4
--- /dev/null
@@ -0,0 +1,529 @@
+--[[ GRAPH widget v1.0 by wlourf (31.10.2010)
+       this widget draws some graphs with some effects 
+       http://u-scripts.blogspot.com/2010/10/graph-widget.html
+       
+To call the script in a conky, use, before TEXT
+       lua_load /path/to/the/script/graph.lua
+       lua_draw_hook_pre main_graph
+and add one line (blank or not) after TEXT
+
+
+Parameters are :
+3 parameters are mandatory
+name           - the name of the conky variable to display,
+                         for example for {$cpu cpu0}, just write name="cpu"
+arg                    - the argument of the above variable,
+                         for example for {$cpu cpu1}, just write arg="cpu1"
+                         arg can be a numerical value if name=""
+max                    - the maximum value the above variable can reach,
+                         for example for {$cpu cpu1}, just write max=100 or less or more
+       
+Optional parameters:
+x,y            - coordinates of the bottom-left corner of the graph,
+              relative to the top-left corner of the conky window 
+                         default =  bottom-left corner of the conky window
+width       - width of the graph, default = 100 pixels
+height      - height of the graph, default = 20 pixels
+nb_values   - number of values to display in the graph, default=width 
+              i.e. 1 pixel for 1 value
+autoscale   - if set to true, calculate the max valeu of the y axis and
+              doesn't use the max parameter above, default=false
+skew_x      - skew graph around x axis, défaut = 0
+skew_y      - skew graph around y axis, défaut = 0
+angle      - angle of rotation of the graph in degress, default = 0
+              i.e. a horizontal graph)
+inverse     - if set to true, graph are draw from right to left, default=false
+background  - if set to false, background is not drawn, default=true
+foreground  - if set to false, foreground is not drawn, default=true
+              foreground = plain graph
+bg_bd_size  - size of the border of the background, default=0=no border
+fg_bd_size  - size of the border of the foreground, default=0=no border
+
+
+Colours tables below are defined into braces :
+{position in the gradient (0 to 1), colour in hexadecimal, alpha (0 to 1)}
+example for a single colour table : 
+{{0,0xFFAA00,1}} position parameter doesn't matter
+example for a two-colours table : 
+{{0,0xFFAA00,1},{1,0x00AA00,1}} or {{0.5,0xFFAA00,1},{1,0x00AA00,1}}
+example for a three-colours table : 
+{{0,0xFFAA00,1},{0.5,0xFF0000,1},{1,0x00AA00,1}}
+
+bg_colour      - colour table for background,
+                         default = {{0,0x000000,.5},{1,0xFFFFFF,.5}}
+fg_colour      - colour table for foreground,
+                         default = {{0,0x00FFFF,1},{1,0x0000FF,1}}
+bg_bd_colour- colour table for background border,
+                         default = {{1,0xFFFFFF,1}}                      
+fg_bd_colour- colour table for foreground border,
+                         default = {{1,0xFFFF00,1}}                      
+
+bg_orientation, bg_bd_orientation, fg_orientation, fg_bd_orientation,
+               - "orientation" defines the starting point of the gradient,
+                 default="nn"
+                         there are 8 available starting points : 
+                         "nw","nn","ne","ee","se","ss","sw","ww"
+                         (n for north, w for west ...)
+                         theses 8 points are the 4 corners + the 4 middles of graph
+                         so a gradient "nn" will go from "nn" to "ss"
+                         a gradient "nw" will go from "nw" to "se"
+
+
+v1.0 (31 Oct. 2010) original release
+
+--      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 version 3 (GPLv3)
+--     
+--      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, write to the Free Software
+--      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+--      MA 02110-1301, USA.
+
+]]
+
+require 'cairo'
+
+function set_settings()
+       graph_settings={
+           {
+                       name="cpu",
+                       arg="",
+                       max=100,
+                       y=87,
+                       x=5,
+                       autoscale=false,
+                       width=215,
+                       height=29,
+                       nb_values=120,
+                       fg_bd_size=2,
+                       bg_colour = {{0,0x007AF6,0},{1,0x000000,0}},
+                       --fg_bd_colour = { {0,0xFF0000,1},{0.5,0xFFA209,1},{1,0xFFFF00,1}},
+                       fg_bd_colour = { {0,0xFF0000,1},{0.5,0xFF3300,1},{1,0xFFFFFF,1}},
+                       --fg_colour = { {0,0xFF0000,1},{0.5,0xFFA209,1},{1,0xFFFF00,1}},
+                       fg_colour = { {0,0x00CCFF,0.7},{0.5,0x0000FF,0.7},{1,0x000000,0.1}},
+                       foreground=true,
+                       fg_orientation="ne",
+                       bg_bd_orientation="nn",
+                       bg_orientation="ne",
+               },
+           {
+                       name="upspeedf",
+                       arg="wlan0",
+                       max=9999,
+                       y=233,
+                       x=5,
+                       autoscale=true,
+                       width=275,
+                       height=35,
+                       nb_values=120,
+                       fg_bd_size=1,
+                       bg_colour = {{0,0x007AF6,0},{1,0x000000,0}},
+                       fg_bd_colour = { {0,0xFF0000,1},{0.5,0xFFA209,0.8},{1,0xFFFF00,0.6}},
+                       fg_colour = { {0,0xFF0000,0.65},{0.5,0xFFA209,0.5},{1,0xFFFF00,0.3}},
+                       foreground=true,
+                       inverse=true,
+                       DrawMe="${if_up wlan0}1${else}0$endif",
+                       bg_orientation="ww",
+           },
+           {
+                       name="downspeedf",
+                       arg="wlan0",
+                       max=9999,
+                       y=233,
+                       x=525,
+                       autoscale=true,
+                       width=275,
+                       height=35,
+                       nb_values=120,
+                       fg_bd_size=1,
+                       bg_colour = {{0,0x007AF6,0},{1,0x000000,0}},
+                       fg_bd_colour = { {0,0xFF0000,1},{0.5,0xFFA209,0.8},{1,0xFFFF00,0.6}},
+                       fg_colour = { {0,0xFF0000,0.65},{0.5,0xFFA209,0.5},{1,0xFFFF00,0.3}},
+                       foreground=true,
+                       DrawMe="${if_up wlan0}1${else}0$endif",
+                       bg_orientation="ee",
+           },
+           {
+                       name="upspeedf",
+                       arg="gprs0",
+                       max=9999,
+                       y=233,
+                       x=5,
+                       autoscale=true,
+                       width=275,
+                       height=35,
+                       nb_values=120,
+                       fg_bd_size=1,
+                       bg_colour = {{0,0x007AF6,0},{1,0x000000,0}},
+                       fg_bd_colour = { {0,0xFF0000,1},{0.5,0xFFA209,0.8},{1,0xFFFF00,0.6}},
+                       fg_colour = { {0,0xFF0000,0.65},{0.5,0xFFA209,0.5},{1,0xFFFF00,0.3}},
+                       foreground=true,
+                       inverse=true,
+                       DrawMe="${if_up gprs0}1${else}0$endif",
+                       bg_orientation="ww",
+           },
+           {
+                       name="downspeedf",
+                       arg="gprs0",
+                       max=9999,
+                       y=233,
+                       x=525,
+                       autoscale=true,
+                       width=275,
+                       height=35,
+                       nb_values=120,
+                       fg_bd_size=1,
+                       bg_colour = {{0,0x007AF6,0},{1,0x000000,0}},
+                       fg_bd_colour = { {0,0xFF0000,1},{0.5,0xFFA209,0.8},{1,0xFFFF00,0.6}},
+                       fg_colour = { {0,0xFF0000,0.65},{0.5,0xFFA209,0.5},{1,0xFFFF00,0.3}},
+                       foreground=true,
+                       DrawMe="${if_up gprs0}1${else}0$endif",
+                       bg_orientation="ee",
+           },
+           {
+                       name="loadavg",
+                       arg="1",
+                       max=20,
+                       y=95,
+                       x=372,
+                       autoscale=true,
+                       width=140,
+                       height=36,
+                       nb_values=100,
+                       fg_bd_size=0,
+                       bg_colour = {{0,0x667AF6,0},{1,0x000000,0}},
+                       fg_bd_colour =  { {0,0xdd0000,0.7},{0.5,0xdddd00,0.7},{1,0xFFFF00,0.7}},
+                       fg_colour = { {0,0x000000,0.7},{0.5,0xdd0000,0.7},{1,0xff0000,0.7}},
+                       foreground=true,
+           },
+           {
+                       name="to_bytes ${diskio",
+                       arg="mmcblk0}",
+                       max=2500000,
+                       y=187,
+                       x=640,
+                       autoscale=true,
+                       width=160,
+                       height=89,
+                       nb_values=130,
+                       fg_bd_size=0,
+                       bg_colour = {{0,0x667AF6,0},{1,0x000000,0}},
+                       fg_bd_colour =  { {0,0xdd0000,1},{0.5,0xdddd00,1},{1,0xFFFF00,1}},
+                       fg_colour = { {1,0x111111,0.3},{0.5,0x33cc00,0.6},{0,0x00FF00,0.8}},
+                       foreground=true,
+                       bg_orientation="ne",
+                       fg_orientation="ee",
+           },
+    }
+end
+
+function check_settings(t)
+    --tables are check only when conky start
+       if t.name==nil and t.arg==nil then 
+               print ("No input values ... use parameters 'name'" .. 
+                       " with 'arg' or only parameter 'arg' ") 
+               return 1
+       end
+       if t.max==nil then
+               print ("No maximum value defined, use 'max'")
+               print ("for name=" .. t.name .. " with arg=" .. t.arg)
+               return 1
+       end
+       if t.name==nil then t.name="" end
+       if t.arg==nil then t.arg="" end
+       return 0
+end
+
+function conky_main_graph()
+    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)
+    updates=tonumber(conky_parse('${updates}'))
+    --start drawing after "updates_gap" updates
+    --prevent segmentation error for cpu
+    updates_gap=5
+    if updates==1 then    
+       set_settings()
+           flagOK=0
+                       for i in pairs(graph_settings) do
+                               if graph_settings[i].width==nil then graph_settings[i].width=100 end
+        if graph_settings[i].nb_values==nil then  
+               graph_settings[i].nb_values= graph_settings[i].width
+        end
+                       --create an empty table to store values
+                       graph_settings[i]["values"]={}
+                       --beginning point
+                       graph_settings[i].beg = graph_settings[i].nb_values
+                       --graph_settings[i].beg = 0
+                       for j =1, graph_settings[i].nb_values do
+                           graph_settings[i].values[j]=0
+                       end
+                 graph_settings[i].flag_init=true
+                 flagOK=flagOK + check_settings(graph_settings[i])
+                 end
+    end
+    if flagOK>0 then 
+        --abort script if error in one of the tables
+        print ("ERROR : Check the graph_setting table")
+        return
+    end
+    --drawing process
+    if updates > updates_gap then
+               for i in pairs(graph_settings) do
+                       if (graph_settings[i].DrawMe==nil or conky_parse(graph_settings[i].DrawMe) == "1") then 
+                               --print(graph_settings[i].DrawMe.."= '"..conky_parse(graph_settings[i].DrawMe).."'")
+                               --return
+                        --cancel fetch value from conky if interface down or whatever
+                       local nb_values=graph_settings[i].nb_values
+                       graph_settings[i].automax=0
+                       for j =1, nb_values do
+                               if graph_settings[i].values[j+1]==nil then 
+                                   graph_settings[i].values[j+1]=0 
+                               end
+                               graph_settings[i].values[j]=graph_settings[i].values[j+1]
+                               if j==nb_values then
+                                       --store value
+                                       if graph_settings[i].name=="" then
+                                           value=graph_settings[i].arg
+                                       else
+                                       value=tonumber(conky_parse('${' .. 
+                                           graph_settings[i].name .. " " ..
+                                           graph_settings[i].arg ..'}'))
+                       end
+                                       graph_settings[i].values[nb_values]=value
+                               end
+                               graph_settings[i].automax=math.max(graph_settings[i].automax,
+                                                                  graph_settings[i].values[j])
+                               if graph_settings[i].automax == 0 then graph_settings[i].automax = 1 end --should stop weird glitches at beginning when no values reported yet for upspeed or diskio
+                       end
+                       draw_graph(graph_settings[i])
+                       end
+               end
+    end
+    cairo_destroy(cr)
+    cairo_surface_destroy(cs)
+       updates=nil
+       updates_gap=nil
+end
+
+function draw_graph(t)
+    --drawing function
+    local function rgb_to_r_g_b(colour)
+        return ((colour[2] / 0x10000) % 0x100) / 255., ((colour[2] / 0x100) % 0x100) / 255., (colour[2] % 0x100) / 255., colour[3]
+    end
+       local function linear_orientation(o,w,h)
+           --set gradient for bg and bg border
+               local p
+               if o=="nn" then
+                       p={w/2,h,w/2,0}
+               elseif o=="ne" then
+                       p={w,h,0,0}
+               elseif o=="ww" then
+                       p={0,h/2,w,h/2}
+               elseif o=="se" then
+                       p={w,0,0,h}
+               elseif o=="ss" then
+                       p={w/2,0,w/2,h}
+               elseif o=="ee" then
+                       p={w,h/2,0,h/2}         
+               elseif o=="sw" then
+                       p={0,0,w,h}
+               elseif o=="nw" then
+                       p={0,h,w,0}
+               end
+               return p
+       end
+
+       local function linear_orientation_inv(o,w,h)
+           --set gradient for fg and fg border
+               local p
+               if o=="ss" then
+                       p={w/2,h,w/2,0}
+               elseif o=="sw" then
+                       p={w,h,0,0}
+               elseif o=="ee" then
+                       p={0,h/2,w,h/2}
+               elseif o=="nw" then
+                       p={w,0,0,h}
+               elseif o=="nn" then
+                       p={w/2,0,w/2,h}
+               elseif o=="ww" then
+                       p={w,h/2,0,h/2}         
+               elseif o=="ne" then
+                       p={0,0,w,h}
+               elseif o=="se" then
+                       p={0,h,w,0}
+               end
+               return p
+       end
+       if t.DrawMe~=nil and conky_parse(t.DrawMe) ~= "1" then 
+               --print(t.DrawMe.."= '"..conky_parse(t.DrawMe).."'")
+               return
+       --else
+       --      print(t.name)
+       end --cancel drawing for same reason as earlier 
+       --set default values
+       if t.height==nil        then t.height=20 end
+       --checked in previous part : width and nb_values
+       if t.background==nil    then t.background=true end
+       if t.bg_bd_size==nil    then t.bg_bd_size=0 end
+       if t.x==nil                 then t.x=t.bg_bd_size end
+       if t.y==nil                 then t.y=conky_window.height -t.bg_bd_size end
+       if t.bg_colour==nil     then t.bg_colour={{0,0x000000,.5},{1,0xFFFFFF,.5}} end
+       if t.bg_bd_colour==nil  then t.bg_bd_colour={{1,0xFFFFFF,1}} end
+       if t.foreground==nil    then t.foreground=true end
+       if t.fg_colour==nil     then t.fg_colour={{0,0x00FFFF,1},{1,0x0000FF,1}} end
+       if t.fg_bd_size==nil    then t.fg_bd_size=0 end 
+       if t.fg_bd_colour==nil  then t.fg_bd_colour={{1,0xFFFF00,1}} end
+       if t.autoscale==nil     then t.autoscale=false end
+       if t.inverse==nil       then t.inverse=false end
+       if t.angle==nil         then t.angle=0 end
+       if t.bg_bd_orientation==nil then t.bg_bd_orientation="nn" end
+       if t.bg_orientation==nil then t.bg_orientation="nn" end
+       if t.fg_bd_orientation==nil then t.fg_bd_orientation="nn" end
+       if t.fg_orientation==nil then t.fg_orientation="nn" end
+    --check colours tables
+       for i=1, #t.fg_colour do    
+        if #t.fg_colour[i]~=3 then 
+               print ("error in fg_colour table")
+               t.fg_colour[i]={1,0x0000FF,1} 
+        end
+    end
+       for i=1, #t.fg_bd_colour do    
+        if #t.fg_bd_colour[i]~=3 then 
+               print ("error in fg_bd_colour table")
+               t.fg_bd_colour[i]={1,0x00FF00,1} 
+        end
+    end
+       for i=1, #t.bg_colour do    
+        if #t.bg_colour[i]~=3 then 
+               print ("error in background color table")
+               t.bg_colour[i]={1,0xFFFFFF,0.5} 
+        end
+    end    
+       for i=1, #t.bg_bd_colour do    
+        if #t.bg_bd_colour[i]~=3 then 
+               print ("error in background border color table")
+               t.bg_bd_colour[i]={1,0xFFFFFF,1} 
+        end
+    end    
+    --calculate skew parameters if needed
+    if t.flag_init then
+           if t.skew_x == nil then 
+                   t.skew_x=0 
+           else
+                   t.skew_x = math.pi*t.skew_x/180     
+           end
+           if t.skew_y == nil then 
+                   t.skew_y=0
+           else
+                   t.skew_y = math.pi*t.skew_y/180     
+           end
+           t.flag_init=false
+       end
+    cairo_set_line_cap(cr,CAIRO_LINE_CAP_ROUND)
+    cairo_set_line_join(cr,CAIRO_LINE_JOIN_ROUND)
+    local matrix0 = cairo_matrix_t:create()
+       tolua.takeownership(matrix0)
+    cairo_save(cr)
+    cairo_matrix_init (matrix0, 1,t.skew_y,t.skew_x,1,0,0)
+    cairo_transform(cr,matrix0)
+       local ratio=t.width/t.nb_values
+       cairo_translate(cr,t.x,t.y)
+       cairo_rotate(cr,t.angle*math.pi/180)
+       cairo_scale(cr,1,-1)
+       --background
+       if t.background then
+           local pts=linear_orientation(t.bg_orientation,t.width,t.height)
+               local pat = cairo_pattern_create_linear (pts[1],pts[2],pts[3],pts[4])
+               for i=1, #t.bg_colour do
+                       --print ("i",i,t.colour[i][1], rgb_to_r_g_b(t.colour[i]))
+                   cairo_pattern_add_color_stop_rgba (pat, t.bg_colour[i][1], rgb_to_r_g_b(t.bg_colour[i]))
+               end
+               cairo_set_source (cr, pat)
+               cairo_rectangle(cr,0,0,t.width,t.height)        
+               cairo_fill(cr)
+               cairo_pattern_destroy(pat)
+       end
+    --autoscale
+    cairo_save(cr)
+       if t.autoscale then
+               t.max= t.automax*1.1
+       end
+    local scale_x = t.width/(t.nb_values-1)
+       local scale_y = t.height/t.max
+    --define first point of the graph
+       if updates-updates_gap <t.nb_values then 
+               t.beg = t.beg - 1
+       --next line prevent segmentation error when conky window is redraw 
+               --quicly when another window "fly" over it
+               if t.beg<0 then t.beg=0 end
+       else
+               t.beg=0
+       end
+    if t.inverse then cairo_scale(cr,-1,1)
+    cairo_translate(cr,-t.width,0) end
+       --graph foreground
+       if t.foreground then
+           local pts_fg=linear_orientation_inv(t.fg_orientation,t.width,t.height)
+           local pat = cairo_pattern_create_linear (pts_fg[1],pts_fg[2],pts_fg[3],pts_fg[4])
+               for i=1,#t.fg_colour,1 do
+                       cairo_pattern_add_color_stop_rgba (pat, 1-t.fg_colour[i][1], rgb_to_r_g_b(t.fg_colour[i]))
+               end
+               cairo_set_source (cr, pat)
+               cairo_move_to(cr,t.beg*scale_x,0)
+               cairo_line_to(cr,t.beg*scale_x,t.values[t.beg+1]*scale_y)
+               for i=t.beg, t.nb_values-1 do
+                       cairo_line_to(cr,i*scale_x,t.values[i+1]*scale_y)               
+               end
+               cairo_line_to(cr,(t.nb_values-1)*scale_x,0)
+               cairo_close_path(cr)
+               cairo_fill(cr)
+               cairo_pattern_destroy(pat)
+       end
+       --graph_border
+       if t.fg_bd_size>0 then
+       local pts=linear_orientation_inv(t.fg_bd_orientation,t.width,t.height)
+               local pat = cairo_pattern_create_linear (pts[1],pts[2],pts[3],pts[4])
+               for i=1,#t.fg_bd_colour,1 do
+                       cairo_pattern_add_color_stop_rgba (pat, 1-t.fg_bd_colour[i][1], rgb_to_r_g_b(t.fg_bd_colour[i]))
+               end
+               cairo_set_source (cr, pat)
+               cairo_move_to(cr,t.beg*scale_x,t.values[t.beg+1]*scale_y)
+               for i=t.beg, t.nb_values-1 do
+                       cairo_line_to(cr,i*scale_x,t.values[i+1]*scale_y)               
+               end
+               cairo_set_line_width(cr,t.fg_bd_size)
+               cairo_stroke(cr)
+               cairo_pattern_destroy(pat)
+       end
+       cairo_restore(cr)
+       --background border
+       if t.bg_bd_size>0 then
+       local pts=linear_orientation(t.bg_bd_orientation,t.width,t.height)
+               local pat = cairo_pattern_create_linear (pts[1],pts[2],pts[3],pts[4])
+               for i=1, #t.bg_bd_colour do
+                       --print ("i",i,t.colour[i][1], rgb_to_r_g_b(t.colour[i]))
+                   cairo_pattern_add_color_stop_rgba (pat, t.bg_bd_colour[i][1], rgb_to_r_g_b(t.bg_bd_colour[i]))
+               end
+               cairo_set_source (cr, pat)
+               cairo_rectangle(cr,0,0,t.width,t.height)        
+               cairo_set_line_width(cr,t.bg_bd_size)
+               cairo_stroke(cr)
+               cairo_pattern_destroy(pat)
+       end     
+
+       cairo_restore(cr)
+
+end
+
diff --git a/data/luatraverse.lua b/data/luatraverse.lua
new file mode 100644 (file)
index 0000000..f0a3234
--- /dev/null
@@ -0,0 +1,195 @@
+-------------------------------------------------------------------------------
+-- This module implements a function that traverses all live objects.
+-- You can implement your own function to pass as a parameter of traverse
+-- and give you the information you want. As an example we have implemented
+-- countreferences and findallpaths
+--
+-- Alexandra Barros - 2006.03.15
+-------------------------------------------------------------------------------
+
+module("traverse", package.seeall)
+
+local List = {}
+
+function List.new ()
+       return {first = 0, last = -1}
+end
+
+function List.push (list, value)
+       local last = list.last + 1
+    list.last = last
+    list[last] = value
+end
+
+function List.pop (list)       
+    local first = list.first
+    if first > list.last then error("list is empty") end
+    local value = list[first]
+    list[first] = nil        
+    list.first = first + 1
+    return value
+end
+
+function List.isempty (list)
+       return list.first > list.last
+end
+
+-- Counts all references for a given object
+function countreferences(value)
+       local count = -1 
+       local f = function(from, to, how, v)
+               if to == value then 
+                       count = count + 1
+               end 
+       end     
+       traverse({edge=f}, {count, f})
+       return count
+end
+
+-- Main function
+-- 'funcs' is a table that contains a funcation for every lua type and also the
+-- function edge edge (traverseedge).
+function traverse(funcs, ignoreobjs)
+
+       -- The keys of the marked table are the objetcts (for example, table: 00442330).
+       -- The value of each key is true if the object has been found and false
+       -- otherwise.
+       local env = {marked = {}, list=List.new(), funcs=funcs}
+       
+       if ignoreobjs then
+               for i=1, #ignoreobjs do
+                       env.marked[ignoreobjs[i]] = true
+               end
+       end
+       
+       env.marked["traverse"] = true
+       env.marked[traverse] = true
+       
+       -- marks and inserts on the list
+       edge(env, nil, "_G", "isname", nil)
+       edge(env, nil, _G, "value", "_G")
+
+       -- traverses the active thread
+       -- inserts the local variables
+       -- interates over the function on the stack, starting from the one that
+       -- called traverse
+       
+       for i=2, math.huge do
+               local info = debug.getinfo(i, "f") 
+               if not info then break end 
+               for j=1, math.huge do
+                       local n, v = debug.getlocal(i, j)
+                       if not n then break end
+               
+                       edge(env, nil, n, "isname", nil)
+                       edge(env, nil, v, "local", n)
+               end
+       end
+       
+       while not List.isempty(env.list) do                     
+       
+               local obj = List.pop(env.list)
+               local t = type(obj)
+               _M["traverse" .. t](env, obj)
+                       
+       end                     
+       
+end
+
+function traversetable(env, obj)
+       
+       local f = env.funcs.table
+       if f then f(obj) end
+       
+       for key, value in pairs(obj) do 
+               edge(env, obj, key, "key", nil)
+               edge(env, obj, value, "value", key)
+       end
+       
+       local mtable = debug.getmetatable(obj)
+       if mtable then edge(env, obj, mtable, "ismetatable", nil) end
+
+end
+                       
+function traversestring(env, obj)
+       local f = env.funcs.string
+       if f then f(obj) end
+       
+end
+
+function traverseuserdata(env, obj)
+       local f = env.funcs.userdata
+       if f then f(obj) end
+       
+       local mtable = debug.getmetatable(obj)
+       if mtable then edge(env, obj, mtable, "ismetatable", nil) end
+       
+       local fenv = debug.getfenv(obj)
+       if fenv then edge(env, obj, fenv, "environment", nil) end
+       
+end
+
+function traversefunction(env, obj)
+       local f = env.funcs.func
+       if f then f(obj) end
+       
+       -- gets the upvalues
+       local i = 1     
+       while true do
+               local n, v = debug.getupvalue(obj, i)
+               if not n then break end -- when there is no upvalues
+               edge(env, obj, n, "isname", nil)
+               edge(env, obj, v, "upvalue", n)
+               i = i + 1
+       end
+               
+       local fenv = debug.getfenv(obj)
+       edge(env, obj, fenv, "environment", nil)
+       
+end
+                       
+function traversethread(env, t)
+       local f = env.funcs.thread
+       if f then f(t) end
+       
+       for i=1, math.huge do
+               local info = debug.getinfo(t, i, "f") 
+               if not info then break end 
+               for j=1, math.huge do
+                       local n, v = debug.getlocal(t, i , j)
+                       if not n then break end
+                       print(n, v)
+               
+                       edge(env, nil, n, "isname", nil)
+                       edge(env, nil, v, "local", n)
+               end
+       end
+       
+       local fenv = debug.getfenv(t)
+       edge(env, t, fenv, "environment", nil)
+       
+end
+
+
+-- 'how' is a string that identifies the content of 'to' and 'value':
+--             if 'how' is "key", then 'to' is a key and 'name' is nil.
+--             if 'how' is "value", then 'to' is an object and 'name' is the name of the
+--             key.
+function edge(env, from, to, how, name)
+       
+       local t = type(to)      
+       
+       if to and (t~="boolean") and (t~="number") and (t~="new") then
+               -- If the destination object has not been found yet
+               if not env.marked[to] then 
+                       env.marked[to] = true
+                       List.push(env.list, to) -- puts on the list to be traversed
+               end
+               
+               local f = env.funcs.edge
+               if f then f(from, to, how, name) end
+               
+       end     
+end
+
+return _M;
diff --git a/data/misc.lua b/data/misc.lua
new file mode 100644 (file)
index 0000000..9e9a739
--- /dev/null
@@ -0,0 +1,204 @@
+--
+-- Conky Lua scripting example
+--
+-- Copyright (c) 2009 Brenden Matthews, 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.
+--
+
+function components_to_colour(r, g, b)
+       -- Take the RGB components r, g, b, and return an RGB integer
+       return ((math.floor(r + 0.5) * 0x10000) + (math.floor(g + 0.5) * 0x100) + math.floor(b + 0.5)) % 0xffffff -- no bit shifting operator in Lua afaik
+end
+
+function colour_to_components(colour)
+       -- Take the RGB components r, g, b, and return an RGB integer
+       return (colour / 0x10000) % 0x100, (colour / 0x100) % 0x100, colour % 0x100
+end
+
+function conky_top_colour(value, default_colour, lower_thresh, upper_thresh)
+       --[[
+       This function returns a colour based on a threshold, by adding more of
+       the red component and reducing the other components.  ``value'' is the
+       value we're checking the thresholds against, ``default_colour'' is the
+       original colour (before adjusting), and the ``lower_thresh'' and
+       ``upper_thresh'' parameters are the low and high values for which we
+       start applying redness.
+       ]]
+       local r, g, b = colour_to_components(default_colour)
+       local colour = 0
+       if value ~= nil and (value - lower_thresh) > 0 then
+               if value > upper_thresh then value = upper_thresh end
+               local perc = (value - lower_thresh) / (upper_thresh - lower_thresh)
+               if perc > 1 then perc = 1 end
+               -- add some redness, depending on where ``value'' lies within the
+               -- threshhold range
+               r = r + perc * (0xff - r)
+               b = b - perc * b
+               g = g - perc * g
+       end
+       colour = components_to_colour(r, g, b)
+       return string.format("${color #%06x}", colour)
+end
+
+-- parses the output from top and calls the colour function
+function conky_top_cpu_colour(arg)
+       -- input is the top var number we want to use
+       local str = conky_parse(string.format('${top name %i}${top cpu %i}${top mem %i}', tonumber(arg), tonumber(arg), tonumber(arg)))
+       local cpu = tonumber(string.match(str, '(%d+%.%d+)'))
+       return conky_top_colour(cpu, 0xd3d3d3, 25, 70) .. str
+end
+
+function conky_top_mem_colour(arg)
+       -- input is the top var number we want to use
+       local str = conky_parse(string.format('${top_mem name %i}${top_mem mem_res %i}  ${top_mem mem_vsize %i}', tonumber(arg), tonumber(arg), tonumber(arg)))
+       local mem = tonumber(string.match(str, '%w+%s+(%d+%.%d+)%w%s%s'))
+       -- tweak the last 3 parameters to your liking
+       -- my machine has ~8GiB of ram, so an upper thresh of 15% seemed appropriate
+       return conky_top_colour(mem, 0xd3d3d3, 10, 24) .. str
+end
+
+function conky_top_io_colour(arg)
+       -- input is the top var number we want to use
+       local str = conky_parse(string.format('${top_io name %i}${top_io io_read %i} ${top_io io_write %i} ${top_io io_perc %i}', tonumber(arg), tonumber(arg), tonumber(arg), tonumber(arg)))
+       local ioR,ioW = string.match(str, '%w+%s+(%d+%.*%d*%w)%s+(%d+%.*%d*%w)%s+')
+       local tot = conky_parse("${to_bytes "..ioR.."}") + conky_parse("${to_bytes "..ioW.."}") --these can be bytes or mb :(
+       -- tweak the last 3 parameters to your liking
+       -- my machine has ~8GiB of ram, so an upper thresh of 15% seemed appropriate
+       str = string.gsub(str," 0B", " 0.00B")
+       return conky_top_colour(tot, 0xd3d3d3, 100, 200) .. str
+end
+
+function colour_transition(start, stop, position)
+       --[[
+       Transition from one colour to another based on the value of
+       ``position'', which should be a number between 0 and 1.
+       ]]
+       local rs, gs, bs = colour_to_components(start) -- start components
+       local re, ge, be = colour_to_components(stop) -- end components
+       local function tr(s, e, p)
+               return e + (e - s) * p
+       end
+       local rr, gr, br = tr(rs, re, position), tr(gs, ge, position), tr(bs, be, position) -- result components
+       return components_to_colour(rr, gr, br)
+end
+
+function get_timezone_offset()
+       -- returns the number of seconds of timezone offset
+       local tz = tonumber(os.date('%z'))
+       local tzh = math.floor(tz / 100 + 0.5)
+       local tzm = math.abs(tz) % 100 / 60.
+       if tzh < 0 then tzm = -tzm end
+       return (tzh + tzm) * 3600
+end
+
+function julian_to_unix(J)
+       -- converts a julian date into unit time
+       return (J - 2440588) * 86400
+end
+
+function get_julian_now()
+       -- returns the current time in julian date format
+       local now = os.time()
+       return now / 86400. + 2440588
+end
+
+function calculate_sunrise_sunset(latitude, longitude)
+       --[[
+       This function returns the unix timestamps in the local time for sunrise and
+       sunset times, according to ``latitude'' and ``longitude''.  For the
+       latitude, north is positive and south is negative.  For the longitude, west
+       is negative, and east is positive.  You can usually determine the lat/long
+       for your location from Wikipedia or using some mapping tool.
+
+       In my case (Calgary, AB) the lat/long are 51.045 and -114.057222
+
+       Reference: http://en.wikipedia.org/wiki/Sunrise_equation
+       ]]
+
+       -- Negate longitude, west is positive and east is negative
+       longitude = -longitude
+
+       --  Calculate current Julian Cycle
+       local n = math.floor(get_julian_now() - 2451545 - 0.0009 - longitude / 360 + 0.5)
+
+       -- Approximate Solar Noon
+       local Js = 2451545 + 0.0009 + longitude / 360 + n
+
+       -- Solar Mean Anomaly
+       local M = (357.5291 + 0.98560028 * (Js - 2451545)) % 360
+
+       -- Equation of Center
+       local C = (1.9148 * math.deg(math.sin(math.rad(M)))) + (0.0200 * math.deg(math.sin(math.rad(2 * M)))) + (0.0003 * math.deg(math.sin(math.rad(3 * M))))
+
+       -- Ecliptic Longitude
+       local lam = (M + 102.9372 + C + 180) % 360
+
+       -- Solar Transit
+       local Jt = Js + (0.0053 * math.deg(math.sin(math.rad(M)))) - (0.0069 * math.deg(math.sin(math.rad(2 * lam))))
+
+       -- Declination of the Sun
+       local delta = math.deg(math.asin(math.sin(math.rad(lam)) * math.sin(math.rad(23.45))))
+
+       -- Hour Angle
+       local w = math.deg(math.acos((math.sin(math.rad(-0.83)) - math.sin(math.rad(delta)) * math.sin(math.rad(latitude))) / (math.cos(math.rad(latitude)) * math.cos(math.rad(delta)))))
+
+       local J_set = 2451545 + 0.0009 + ((w + longitude)/360 + n + (0.0053 * math.deg(math.sin(math.rad(M)))) - (0.0069 * math.deg(math.sin(math.rad(2 * lam)))))
+       local J_rise = Jt - (J_set - Jt)
+
+
+       local rising_t, setting_t = julian_to_unix(J_rise), julian_to_unix(J_set)
+
+       -- apply timezone offset
+       local tz_offset = get_timezone_offset()
+       rising_t = rising_t + tz_offset
+       setting_t = setting_t + tz_offset
+
+       return rising_t, setting_t
+end
+
+local last_sunrise_set_check = 0
+local sunrise, sunset = 0
+
+function conky_datey(latitude, longitude, change)
+       --[[
+       Returns a colour at or between day_sky and night_sky (see below) depending on the
+       time of day.  You must provide the ``latitude'' and ``longitude''
+       parameters for your location (see the comments for
+       calculate_sunrise_sunset() above for more info).  The ``change'' parameter
+       is the number of hours we want to start and have a transition, so a value
+       of 1 will mean the transition starts 30 minutes before, and ends 30 minutes
+       after.
+       ]]
+       local function to_hours(t)
+               return tonumber(os.date('%k', t)) + (tonumber(os.date('%M', t)) / 60) + (tonumber(os.date('%S', t)) / 3600)
+       end
+       if last_sunrise_set_check < os.time() - 86400 then
+               sunrise, sunset = calculate_sunrise_sunset(tonumber(latitude), tonumber(longitude))
+               -- convert unix times into hours
+               sunrise, sunset = to_hours(sunrise), to_hours(sunset)
+       end
+       local day_sky = 0x6698FF -- colour to use during daytime
+       local night_sky = 0x342D7E -- colour to use during nighttime
+       local hour = to_hours(os.time())
+       if hour > sunrise + change / 2 and hour < sunset - change / 2 then
+               -- midday
+               sky = day_sky
+       elseif hour > sunset + change / 2 or hour < sunrise - change / 2 then
+               -- midnight
+               sky = night_sky
+       elseif hour > sunset - change / 2 then
+               -- sunset time
+               sky = colour_transition(day_sky, night_sky, (hour - sunset - change / 2) / change)
+       elseif hour < sunrise + change / 2 then
+               -- sunrise time
+               sky = colour_transition(night_sky, day_sky, (hour - sunrise - change / 2) / change)
+       end
+       return string.format('${color #%6x}', sky)
+end
+
+require 'imlib2'
+
diff --git a/data/n950-kobol.jpg b/data/n950-kobol.jpg
new file mode 100644 (file)
index 0000000..6d69cca
Binary files /dev/null and b/data/n950-kobol.jpg differ
diff --git a/data/piechart.lua b/data/piechart.lua
new file mode 100644 (file)
index 0000000..5320cce
--- /dev/null
@@ -0,0 +1,654 @@
+--[[PIE CHART WIDGET BY WLOURF v1.21 26 june 2010
+
+This widget draw a pie chart or a ring in a conky window.
+More info on the parameters with pictures on this page :
+http://u-scripts.blogspot.com/2010/04/pie-chart-widget.html
+
+Parameters are :
+tableV                         -- table of labels and values {{label,conky_variable,conky_argument,convert to Go-Mo-Ko units (true/false) or unit}, ...}
+                                       -- this table is mandatory, others parameters are optionals
+                                       -- example :
+                                                       tableV={
+                                                               {"cpu 0","cpu","cpu0",100,"%"},
+                                                               {"cpu 1","cpu","cpu1",100,"%"},                                                 
+                                                               },
+                                       -- to know disk space, use this line :
+                                                       tableV=read_df(true,true),      
+                                                       
+xc                                     -- x center of the pie, default = conky_window.width/2
+yc,                                    -- y center of the pie, default = conky_window.height/2
+radius_int                     -- internal radius in pixel, default = conky_window.width/6
+radius_ext                     -- external radius in pixel, default = conky_window.width/4
+first_angle                    -- first angle of the pie (in degrees), default=0
+last_angle                     -- last angle of the pie (in degrees), default=360
+type_arc,                      -- fill the arc in a linear way (ring) or radial way (pie), values l or r, default=l
+inverse_l_arc          -- inverse arc for rings (true/false), default=false
+proportional           -- display proportional sectors (true/false); default =false
+gradient_effect        -- gradient effect (true/false), default=true
+line_length                    -- length for horizontal line (from radius_ext to end of line), default=radius_ext
+line_thickness         -- thickness of line, default=1
+line_space                     -- vertical space between two lines, default=10 pixels
+extend_line                    -- grow up the line (true/false) if length of text> line_length, default=true
+nb_decimals                    -- number of decimals for numbers, default=1
+show_text                      -- display text (true/false), default=true
+font_name                      -- font, default "Nokia Pure"
+font_size                      -- font size, default=12
+font_color                     -- font color (for gradient) or nil (for constant color), default = nil
+font_alpha                     -- font alpha, default=1
+txt_offset                     -- space between text and line, default=1
+txt_format                     -- string for formatting text, possibles values are :  default = "&l : &v"
+                                               -- &l for label
+                                               -- &o for occupied percentage
+                                               -- &f for free percentage
+                                               -- &v for value 
+                                               -- &n for free value (non-occupied)     
+                                               -- &m for max value
+                                               -- &p for percentage value of full graph
+tablebg                                -- table of tables of colours for background {colors,alpha}
+tablefg                                -- table of tables of colours for foreground {colors,alpha}
+       
+       
+v1.0 10/04/2010  original release
+v1.1 15/05/2010  the parameters are in a table (pie_settings), only the values in pie_settings.tableV are mandatory
+                                added an option to draw values like a ring (type_arc="l")
+v1.2 26/05/2010         add inverse_l parameter (for type_arc="l")
+                                bug fix : line_length problem
+                                read_df function improved
+v1.21 26/06/2010 rename some parameters and write more infos
+]]
+
+
+require 'cairo'
+
+
+--main function
+function conky_main_pie()
+    if conky_window==nil then return end
+
+
+-- ------------------PARAMETERS TO SET-----------------------
+    --theses parameters are called many times so I put them into variables
+    local font_name,font_size="Nokia Pure",14
+    local col0,col1,col2=0xFFFFCC,0xCCFF99,0x99FF00
+    local colbg=0x99CCFF
+        
+    --for the clock
+    local temp = os.date("*t")
+    local hour=temp.hour
+    if hour>12 then hour=hour-12 end
+    local hpc,mpc,spc=hour/12,temp.min/60,temp.sec/60
+
+    
+    pie_settings= {
+
+        {--CIRCLE 4 : DISK SPACE
+            tableV=read_df(true,true),
+            xc=500,
+            yc=150 ,
+            int_radius=30,
+            radius=45,
+            type_arc="r",
+            proportional=true,
+            first_angle=-90,
+            last_angle=270, 
+            gradient_effect=true,
+            show_text=true,
+            line_lgth=100,
+            line_space=19,
+            txt_format="&l free &n",
+            font_color=colbg,    
+            tablebg={            
+                {colbg,0.5},
+                },
+            tablefg={            
+                {col0,1},
+                {col1,1},
+                {col2,1},
+                },
+        },        
+
+
+        {--CIRCLE 1 : ARCS 1 & 2 INTERNET SPEED
+            tableV={
+                {"dl","downspeedf","eth1",1000,"kb/s"},
+                {"ul","upspeedf","eth1",100,"kb/s"},
+                },
+            xc=300,
+            yc=200,
+            int_radius=30,
+            radius=45,
+            first_angle=-30,
+            last_angle=210,
+            type_arc="r",
+            --line_lgth=150,
+            line_width=0,
+            show_text=false,
+            font_color=colbg,
+            tablebg={
+                {colbg,0.5},
+                },
+            tablefg={
+                {col0,1},
+                {col1,1},
+                },
+        },        
+
+        
+            {--CIRCLE 2 : ARC 1 CPU 0
+            tableV={
+                {"cpu 0","cpu","cpu 0",100,"%"},
+                --{"cpu 1","cpu","cpu 1",100,"%"},
+                },
+            xc=300,
+            yc=350,
+            int_radius=30,
+            radius=45,
+            first_angle=-30,
+            last_angle=210,
+            type_arc="l",
+            show_text=false,
+            tablebg={
+                {colbg,0.5},
+                },
+            tablefg={
+                {col0,1},
+                },
+        },        
+
+--            {--CIRCLE 2 : ARC 2 CPU 1
+--            tableV={
+--                --{"cpu 0","cpu","cpu 0",100,"%"},
+--                {"cpu 1","cpu","cpu 1",100,"%"},
+--                },
+--            xc=200,
+--            yc=350,
+--            int_radius=30,
+--            radius=45,
+--            first_angle=90,
+--            last_angle=220,
+--            type_arc="l",
+--            inverse_l_arc=true,
+--            show_text=false,
+--            tablebg={
+--                {colbg,0.5},
+--                },
+--            tablefg={
+--                {col0,1},
+--                },
+--        },        
+        
+                
+
+    
+
+        {--CIRCLE  3 : MEMORY : ram
+            tableV={
+                {"mem","memperc","",100,"%"},
+                },
+            xc=400,
+            yc=370,
+            int_radius=30,
+            radius=45,
+            first_angle=-30,
+            last_angle=220,
+            type_arc="l",
+            inverse_l_arc=false,
+            proportional=false,
+            gradient_effect=true,
+            nb_decimals=0,
+            show_text=false,
+            tablebg={
+                {colbg,0.5},
+                },
+            tablefg={
+                {col0,1},
+                },
+        },                                
+              
+
+    }
+-------------------END OF PARAMETERS ---------------
+
+    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)
+
+    if tonumber(conky_parse('${updates}'))>5 then
+        for i in pairs(pie_settings) do
+            draw_pie(pie_settings[i])
+        end
+    end
+       cairo_surface_destroy(cs)
+    cairo_destroy(cr)
+end
+
+
+
+function string:split(delimiter)
+--source for the split function : http://www.wellho.net/resources/ex.php4?item=u108/split
+  local result = { }
+  local from  = 1
+  local delim_from, delim_to = string.find( self, delimiter, from  )
+  while delim_from do
+    table.insert( result, string.sub( self, from , delim_from-1 ) )
+    from  = delim_to + 1
+    delim_from, delim_to = string.find( self, delimiter, from  )
+  end
+  table.insert( result, string.sub( self, from  ) )
+  return result
+end
+
+
+function rgb_to_r_g_b(colour, alpha)
+    return ((colour / 0x10000) % 0x100) / 255., ((colour / 0x100) % 0x100) / 255., (colour % 0x100) / 255., alpha
+end
+
+function round(num, idp)
+    local mult = 10^(idp or 0)
+    return math.floor(num * mult + 0.5) / mult
+end
+
+function size_to_text(size,nb_dec)
+    local txt_v
+    if nb_dec<0 then nb_dec=0 end
+    size = tonumber(size)
+    if size>1024*1024*1024 then
+        txt_v=string.format("%."..nb_dec.."f G",size/1024/1024/1024)
+    elseif size>1024*1024 then 
+        txt_v=string.format("%."..nb_dec.."f M",size/1024/1024)
+    elseif size>1024 then 
+        txt_v=string.format("%."..nb_dec.."f K",size/1024)
+    else
+        txt_v=string.format("%."..nb_dec.."f B",size)
+    end
+    return txt_v
+end
+
+function text_to_bytes(txt_in)
+       local txt_modifier
+       local num_bytes
+       txt_modifier = string.match(txt_in,"%d(%a)")
+       num_bytes = string.gsub(txt_in,"%d(%a)","")
+       if txt_modifier == "G" then
+               num_bytes = num_bytes*1024*1024*1024
+       elseif txt_modifier == "M" then
+               num_bytes = num_bytes*1024*1024
+       elseif txt_modifier == "K" then
+               num_bytes = num_bytes*1024
+       elseif txt_modifier == "B" then
+               num_bytes = num_bytes
+       end
+               return num_bytes
+end
+
+
+
+function read_df(show_media,sort_table)
+    --read output of command df and return arrays of value for files systems
+    --reurn array of table {file syst, "", occupied space , total space , convert to G, M, K ...}
+    
+    local f = io.popen("df")
+
+    local results={}
+               table.insert(results,{"/home/user/MyDocs","",text_to_bytes(conky_parse("${fs_used /home/user/MyDocs}")),text_to_bytes(conky_parse("${fs_size /home/user/MyDocs}")),true})
+               table.insert(results,{"/home","",text_to_bytes(conky_parse("${fs_used /home}")),text_to_bytes(conky_parse("${fs_size /home}")),true})
+               table.insert(results,{"rootfs","",text_to_bytes(conky_parse("${fs_used /}")),text_to_bytes(conky_parse("${fs_size /}")),true})
+               table.insert(results,{"SD","",text_to_bytes(conky_parse("${fs_used /media/mmc1}")),text_to_bytes(conky_parse("${fs_size /media/mmc1}")),true})
+               --table.insert(results,{"/home/user/MyDocs2","","30","50",true})
+               --table.insert(results,{text_to_bytes(conky_parse("${fs_used /home/user/MyDocs}")),"","10","50",true})
+--    while true do
+--         local line = f:read("*l")
+--         if line == nil then break end
+--         while string.match(line,"  ") do
+--             line=string.gsub(line,"  "," ")
+--         end
+--        local arr_l=string.split(line," ")
+--        local match = string.match(arr_l[1],"/")
+--        
+--        if string.match(arr_l[1],"/") then
+--            if not show_media then arr_l[6]=string.gsub(arr_l[6],"/media/","",1) end
+--            if string.match(arr_l[1],"opt/") then break end
+--            table.insert(results,{arr_l[6],"",(arr_l[2]-arr_l[4])*1024,arr_l[2]*1024,true})
+--        end
+--    end
+--
+--    f:close()
+--    
+--    if sort_table then
+--        --how to sort table into table?
+--        local flagS=true
+--        while flagS do
+--            for k=2, #results do 
+--                flagS=false
+--                if tonumber(results[1][3])>tonumber(results[2][3]) then
+--                    local tmpV = results[1]
+--                    results[1] = results[2]
+--                    results[2] = tmpV
+--                    flagS=true
+--                end
+--                if tonumber(results[k][3])<tonumber(results[k-1][3]) then
+--                    local tmpV = results[k-1]
+--                    results[k-1] = results[k]
+--                    results[k] = tmpV
+--                    flagS=true
+--                end
+--            end
+--        end
+--    end
+    
+    return results --array {file syst, occupied space , total space }
+end
+
+
+function draw_pie(t)
+    
+    if t.tableV==nil then 
+        print ("No input values ...") 
+        return
+    else
+        tableV=t.tableV
+    end
+
+    if t.xc==nil then t.xc=conky_window.width/2 end
+    if t.yc==nil then t.yc=conky_window.height/2 end
+    if t.int_radius ==nil then t.int_radius =conky_window.width/6 end
+    if t.radius ==nil then t.radius =conky_window.width/4 end
+    if t.first_angle==nil then t.first_angle =0 end
+    if t.last_angle==nil then t.last_angle=360 end
+    if t.proportional==nil then t.proportional=false end
+    if t.tablebg==nil then t.tablebg={{0xFFFFFF,0.5},{0xFFFFFF,0.5}} end
+    if t.tablefg==nil then t.tablefg={{0xFF0000,1},{0x00FF00,1}} end
+    if t.gradient_effect==nil then t.gradient_effect=true end
+    if t.show_text==nil then t.show_text=true end
+    if t.line_lgth==nil then t.line_lgth=t.int_radius end
+    if t.line_space==nil then t.line_space=10 end
+    if t.line_width==nil then t.line_width=1 end
+    if t.extend_line==nil then t.extend_line=true end
+    if t.txt_font==nil then t.txt_font="Nokia Pure" end
+    if t.font_size==nil then t.font_size=12 end
+    --if t.font_color==nil then t.font_color=0xFFFFFF end
+    if t.font_alpha==nil then t.font_alpha = 1 end
+    if t.txt_offset==nil then t.txt_offset = 1 end
+    if t.txt_format==nil then t.txt_format = "&l : &v" end
+    if t.nb_decimals==nil then t.nb_decimals=1 end
+    if t.type_arc==nil then t.type_arc="l" end
+    if t.inverse_l_arc==nil then t.inverse_l_arc=false end
+    
+    
+    local function draw_sector(tablecolor,colorindex,pc,lastAngle,angle,radius,int_radius,gradient_effect,type_arc,inverse_l_arc)
+        --draw a portion of arc
+        radiuspc=(radius-int_radius)*pc+int_radius
+        angle0=lastAngle
+        val=1
+        if type_arc=="l" then 
+            val=pc;radiuspc=radius
+        end
+        angle1=angle*val
+
+        if type_arc=="l" and inverse_l_arc then 
+
+            cairo_save(cr)
+    
+            cairo_rotate(cr,angle0+angle)
+            
+            if gradient_effect then        
+                local pat = cairo_pattern_create_radial (0,0, int_radius, 0,0,radius)
+                cairo_pattern_add_color_stop_rgba (pat, 0, rgb_to_r_g_b(tablecolor[colorindex][1],0))
+                cairo_pattern_add_color_stop_rgba (pat, 0.5, rgb_to_r_g_b(tablecolor[colorindex][1],tablecolor[colorindex][2]))
+                cairo_pattern_add_color_stop_rgba (pat, 1, rgb_to_r_g_b(tablecolor[colorindex][1],0))
+                cairo_set_source (cr, pat)
+                cairo_pattern_destroy(pat)
+            else
+                cairo_set_source_rgba(cr,rgb_to_r_g_b(tablecolor[colorindex][1],tablecolor[colorindex][2]))
+            end
+            cairo_move_to(cr,0,-int_radius)
+            cairo_line_to(cr,0,-radiuspc)
+            cairo_rotate(cr,-math.pi/2)
+        
+            cairo_arc_negative(cr,0,0,radiuspc,0,-angle1)
+            cairo_rotate(cr,-math.pi/2-angle1)
+            cairo_line_to(cr,0,int_radius)
+            cairo_rotate(cr,math.pi/2)
+            cairo_arc(cr,0,0,int_radius,0,angle1)
+            cairo_close_path (cr);
+            cairo_fill(cr)
+
+            cairo_restore(cr)
+        else
+        
+            cairo_save(cr)
+    
+            cairo_rotate(cr,angle0)
+
+            if gradient_effect then        
+                local pat = cairo_pattern_create_radial (0,0, int_radius, 0,0,radius)
+                cairo_pattern_add_color_stop_rgba (pat, 0, rgb_to_r_g_b(tablecolor[colorindex][1],0))
+                cairo_pattern_add_color_stop_rgba (pat, 0.5, rgb_to_r_g_b(tablecolor[colorindex][1],tablecolor[colorindex][2]))
+                cairo_pattern_add_color_stop_rgba (pat, 1, rgb_to_r_g_b(tablecolor[colorindex][1],0))
+                cairo_set_source (cr, pat)
+                cairo_pattern_destroy(pat)
+            else
+                cairo_set_source_rgba(cr,rgb_to_r_g_b(tablecolor[colorindex][1],tablecolor[colorindex][2]))
+            end
+            cairo_move_to(cr,0,-int_radius)
+            cairo_line_to(cr,0,-radiuspc)
+            cairo_rotate(cr,-math.pi/2)
+        
+            cairo_arc(cr,0,0,radiuspc,0,angle1)
+            cairo_rotate(cr,angle1-math.pi/2)
+            cairo_line_to(cr,0,int_radius)
+            cairo_rotate(cr,math.pi/2)
+            cairo_arc_negative(cr,0,0,int_radius,0,-angle1)
+            cairo_close_path (cr);
+            cairo_fill(cr)
+
+            cairo_restore(cr)
+        end
+        
+
+    end
+
+    function draw_lines(idx,nbArcs,angle,table_colors,idx_color,adjust,line_lgth,length_txt,txt_offset,radius,line_width,line_space,font_color,font_alpha)
+        --draw lines
+        
+        local x0=radiuspc*math.sin(lastAngle+angle/2)
+        local y0=-radiuspc*math.cos(lastAngle+angle/2)
+        local x1=1.2*radius*math.sin(lastAngle+angle/2)
+        local y1=-1.2*radius*math.cos(lastAngle+angle/2)
+
+        local x2=line_lgth
+        local y2=y1
+        local x3,y3=nil,nil
+        if x0<=0 then
+            x2=-x2
+        end
+
+        if adjust then
+            if x0>0 and x2-x1<length_txt then x2=x1+length_txt end
+            if x0<=0 and x1-x2<length_txt then x2=x1-length_txt end            
+        end 
+        
+        if idx>1 then
+            local dY = math.abs(y2-lastPt2[2])
+            if dY < line_space and lastPt2[1]*x1>0 then
+                if x0>0 then
+                    y2 = line_space+lastPt2[2]
+                else
+                    y2 = -line_space+lastPt2[2]
+                end
+                if (y2>y1 and x0>0) or (y2<y1 and x0<0 )  then
+                    --x3 is for vertical segment if needed
+                    x3,y3=x2,y2                    
+                    x2=x1
+                    if x3>0 then x3=x3+txt_offset end
+                else
+                    Z=intercept({x0,y0},{x1,y1},{0,y2},{1,y2})
+                    x1,y1=Z[1],Z[2]
+                end
+            end
+        else
+            --remind x2,y2 of first value
+            x2first,y2first = x2,y2
+        end
+
+        if font_color==nil then
+            cairo_set_source_rgba(cr,rgb_to_r_g_b(table_colors[idx_color][1],table_colors[idx_color][2]))
+        else
+            local pat = cairo_pattern_create_linear (x2,y2, x0,y0)
+            cairo_pattern_add_color_stop_rgba (pat, 0, rgb_to_r_g_b(font_color,font_alpha))
+            cairo_pattern_add_color_stop_rgba (pat, 1, rgb_to_r_g_b(table_colors[idx_color][1],table_colors[idx_color][2]))
+            cairo_set_source (cr, pat)
+            cairo_pattern_destroy(pat)
+        end
+
+        
+        cairo_move_to(cr,x0,y0)
+        cairo_line_to(cr,x1,y1)
+        cairo_line_to(cr,x2,y2)
+        if x3~=nil then 
+            cairo_line_to(cr,x3,y3)
+            x2,y2=x3,y3    
+        end
+        cairo_set_line_width(cr,line_width)
+        cairo_stroke(cr)
+        --lastAngle=lastAngle+angle
+        return {x2,y2}
+    end
+    
+    function intercept(p11,p12,p21,p22)
+        --calculate interscetion of two lines and return coordinates
+        a1=(p12[2]-p11[2])/(p12[1]-p11[1])
+
+        a2=(p22[2]-p21[2])/(p22[1]-p21[1])
+
+        b1=p11[2]-a1*p11[1]
+
+        b2=p21[2]-a2*p21[1]
+
+        X=(b2-b1)/(a1-a2)
+
+        Y=a1*X+b1
+        return {X,Y}
+    end
+
+    --some checks
+    if t.first_angle>=t.last_angle then
+        local tmp_angle=t.last_angle
+        --t.last_angle=t.first_angle
+        --t.first_angle=tmp_angle
+        print ("inversed angles")
+    end
+
+    if t.last_angle-t.first_angle>360 and t.first_angle>0 then
+        t.last_angle=360+t.first_angle
+        print ("reduce angles")
+    end
+    
+    if t.last_angle+t.first_angle>360 and t.first_angle<=0 then
+        t.last_angle=360+t.first_angle
+        print ("reduce angles")
+    end
+    
+    if t.int_radius<0 then t.int_radius =0 end
+    if t.int_radius>t.radius then
+        local tmp_radius=t.radius
+        t.radius=t.int_radius
+        t.int_radius=tmp_radius
+        print ("inversed angles")
+    end
+    if t.int_radius==t.radius then
+        t.int_radius=0
+        print ("int radius set to 0")
+    end    
+    --end of checks
+    
+    cairo_save(cr)
+    cairo_translate(cr,t.xc,t.yc)
+    cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND)
+    cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND)
+    
+    local nbArcs=#tableV
+    local anglefull= (t.last_angle-t.first_angle)*math.pi/180
+    local fullsize = 0
+    for i= 1,nbArcs do
+        fullsize=fullsize+tableV[i][4]
+    end
+
+    local cb,cf,angle=0,0,anglefull/nbArcs
+    lastAngle=t.first_angle*math.pi/180
+    lastPt2={nil,nil}
+
+    for i =1, nbArcs do
+        if t.proportional then
+            angle=tableV[i][4]/fullsize*anglefull
+        end
+        --set colours
+        cb,cf=cb+1,cf+1
+        if cb>#t.tablebg then cb=1 end
+        if cf>#t.tablefg then cf=1 end
+        
+        if tableV[i][2]~="" then
+            str=string.format('${%s %s}',tableV[i][2],tableV[i][3])
+        else
+            str = tableV[i][3]
+        end
+        str=conky_parse(str)
+        value=tonumber(str)
+        if value==nil then value=0 end
+    
+        --draw sectors
+        draw_sector(t.tablebg,cb,1,lastAngle,angle,t.radius,t.int_radius,t.gradient_effect,t.type_arc,t.inverse_l_arc)
+        --print (t.tablefg,cf,tableV[i][2],tableV[i][3],lastAngle,angle,t.radius,t.int_radius)
+        --print (cf,tableV[i],tableV[i][2],tableV[i][3])
+        draw_sector(t.tablefg,cf,value/tableV[i][4],lastAngle,angle,t.radius,t.int_radius,t.gradient_effect,t.type_arc,t.inverse_l_arc)
+
+        if t.show_text then
+            --draw text
+            local txt_l   = tableV[i][1]
+            local txt_opc = round(100*value/tableV[i][4],t.nb_decimals).."%%"
+            local txt_fpc = round(100*(tableV[i][4]-value/tableV[i][4]),t.nb_decimals).."%%"
+            local txt_ov,txt_fv,txt_max
+            if tableV[i][5]==true then
+                txt_ov  = size_to_text(value,t.nb_decimals)
+                txt_fv  = size_to_text(tableV[i][4]-value,t.nb_decimals)
+                txt_max = size_to_text(tableV[i][4],t.nb_decimals)
+            else
+                if tableV[i][5]=="%" then tableV[i][5]="%%" end
+                txt_ov=string.format("%."..t.nb_decimals.."f ",value)..tableV[i][5]
+                txt_fv=string.format("%."..t.nb_decimals.."f",tableV[i][4]-value)..tableV[i][5]
+                txt_max=string.format("%."..t.nb_decimals.."f",tableV[i][4])..tableV[i][5]
+            end
+            txt_pc = string.format("%."..t.nb_decimals.."f",100*tableV[i][4]/fullsize).."%%"
+            local txt_out = t.txt_format
+            txt_out = string.gsub(txt_out,"&l",txt_l)  --label
+            txt_out = string.gsub(txt_out,"&o",txt_opc)--occ. %
+            txt_out = string.gsub(txt_out,"&f",txt_fpc)--free %
+            txt_out = string.gsub(txt_out,"&v",txt_ov) --occ. value
+            txt_out = string.gsub(txt_out,"&n",txt_fv) --free value
+            txt_out = string.gsub(txt_out,"&m",txt_max)--max
+            txt_out = string.gsub(txt_out,"&p",txt_pc)--percent
+            
+            local te=cairo_text_extents_t:create()
+            cairo_set_font_size(cr,t.font_size)
+            cairo_select_font_face(cr, t.txt_font, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL)
+            cairo_text_extents (cr,txt_out,te)
+
+            --draw lines 
+            lastPt2=draw_lines(i,nbArcs,angle,t.tablefg,cf,t.extend_line,t.line_lgth+t.radius, 
+                    te.width + te.x_bearing,t.txt_offset,t.radius,t.line_width,t.line_space,t.font_color,t.font_alpha)    
+        
+            local xA=lastPt2[1]
+            local yA=lastPt2[2]-t.line_width-t.txt_offset
+            if xA>0 then xA = xA-(te.width + te.x_bearing) end
+            cairo_move_to(cr,xA,yA)
+            cairo_show_text(cr,txt_out)
+        end
+        
+        lastAngle=lastAngle+angle
+    end
+    cairo_restore(cr)
+end
+
+
+--[[END OF PIE CHART WIDGET]]
diff --git a/data/strict.lua b/data/strict.lua
new file mode 100644 (file)
index 0000000..f04505e
--- /dev/null
@@ -0,0 +1,42 @@
+--
+-- strict.lua
+-- checks uses of undeclared global variables
+-- All global variables must be 'declared' through a regular assignment
+-- (even assigning nil will do) in a main chunk before being used
+-- anywhere or assigned to inside a function.
+--
+-- From Lua distribution (etc/strict.lua)
+--
+
+local getinfo, error, rawset, rawget = debug.getinfo, error, rawset, rawget
+
+local mt = getmetatable(_G)
+if mt == nil then
+  mt = {}
+  setmetatable(_G, mt)
+end
+
+mt.__declared = {}
+
+local function what ()
+  local d = getinfo(3, "S")
+  return d and d.what or "C"
+end
+
+mt.__newindex = function (t, n, v)
+  if not mt.__declared[n] then
+    local w = what()
+    if w ~= "main" and w ~= "C" then
+      print("assign to undeclared variable '"..n.."'")
+    end
+    mt.__declared[n] = true
+  end
+  rawset(t, n, v)
+end
+
+mt.__index = function (t, n)
+  if not mt.__declared[n] and what() ~= "C" then
+    print("variable '"..n.."' is not declared")
+  end
+  return rawget(t, n)
+end
diff --git a/data/testCairo.lua b/data/testCairo.lua
new file mode 100644 (file)
index 0000000..088156a
--- /dev/null
@@ -0,0 +1,236 @@
+--[[
+Ring Meters by londonali1010 (2009)
+
+This script draws percentage meters as rings. It is fully customisable; all options are described in the script.
+
+IMPORTANT: if you are using the 'cpu' function, it will cause a segmentation fault if it tries to draw a ring straight away. The if statement on line 145 uses a delay to make sure that this doesn't happen. It calculates the length of the delay by the number of updates since Conky started. Generally, a value of 5s is long enough, so if you update Conky every 1s, use update_num > 5 in that if statement (the default). If you only update Conky every 2s, you should change it to update_num > 3; conversely if you update Conky every 0.5s, you should use update_num > 10. ALSO, if you change your Conky, is it best to use "killall conky; conky" to update it, otherwise the update_num will not be reset and you will get an error.
+
+To call this script in Conky, use the following (assuming that you save this script to ~/scripts/rings.lua):
+    lua_load ~/scripts/rings-v1.2.1.lua
+    lua_draw_hook_pre ring_stats
+
+Changelog:
++ v1.2.1 -- Fixed minor bug that caused script to crash if conky_parse() returns a nil value (20.10.2009)
++ v1.2 -- Added option for the ending angle of the rings (07.10.2009)
++ v1.1 -- Added options for the starting angle of the rings, and added the "max" variable, to allow for variables that output a numerical value rather than a percentage (29.09.2009)
++ v1.0 -- Original release (28.09.2009)
+]]
+
+settings_table = {
+    {
+        -- 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.1,
+        -- "fg_colour" is the colour of the indicator part of the ring.
+        fg_colour=0xffffff,
+        -- "fg_alpha" is the alpha value of the indicator part of the ring.
+        fg_alpha=0.2,
+        -- "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=165, y=170,
+        -- "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 (e.g. more clockwise) than start_angle.
+        end_angle=360
+    },
+    {
+        name='time',
+        arg='%M.%S',
+        max=60,
+        bg_colour=0xffffff,
+        bg_alpha=0.1,
+        fg_colour=0xffffff,
+        fg_alpha=0.4,
+        x=165, y=170,
+        radius=56,
+        thickness=5,
+        start_angle=0,
+        end_angle=360
+    },
+    {
+        name='time',
+        arg='%S',
+        max=60,
+        bg_colour=0xffffff,
+        bg_alpha=0.1,
+        fg_colour=0xffffff,
+        fg_alpha=0.6,
+        x=165, y=170,
+        radius=62,
+        thickness=5,
+        start_angle=0,
+        end_angle=360
+    },
+    {
+        name='cpu',
+        arg='cpu0',
+        max=100,
+        bg_colour=0xffffff,
+        bg_alpha=0.1,
+        fg_colour=0xffffff,
+        fg_alpha=0.4,
+        x=165, y=170,
+        radius=84.5,
+        thickness=8,
+        start_angle=60,
+        end_angle=120
+    },
+    {
+        name='battery_percent',
+        arg='BAT1',
+        max=100,
+        bg_colour=0xffffff,
+        bg_alpha=0.1,
+        fg_colour=0xffffff,
+        fg_alpha=0.6,
+        x=165, y=170,
+        radius=72,
+        thickness=11,
+        start_angle=122,
+        end_angle=210
+    },
+    {
+        name='memperc',
+        arg='',
+        max=100,
+        bg_colour=0xffffff,
+        bg_alpha=0.1,
+        fg_colour=0xffffff,
+        fg_alpha=0.8,
+        x=165, y=170,
+        radius=83.5,
+        thickness=8,
+        start_angle=122,
+        end_angle=210
+    },
+    {
+        name='time',
+        arg='%d',
+        max=31,
+        bg_colour=0xffffff,
+        bg_alpha=0.1,
+        fg_colour=0xffffff,
+        fg_alpha=0.8,
+        x=165, y=170,
+        radius=70,
+        thickness=5,
+        start_angle=212,
+        end_angle=360
+    },
+    {
+        name='time',
+        arg='%m',
+        max=12,
+        bg_colour=0xffffff,
+        bg_alpha=0.1,
+        fg_colour=0xffffff,
+        fg_alpha=0.8,
+        x=165, y=170,
+        radius=76,
+        thickness=5,
+        start_angle=212,
+        end_angle=360
+    },
+    {
+        name='fs_used_perc',
+        arg='/',
+        max=150,
+        bg_colour=0xffffff,
+        bg_alpha=0.2,
+        fg_colour=0xffffff,
+        fg_alpha=0.3,
+        x=165, y=170,
+        radius=108.5,
+        thickness=3,
+        start_angle=-120,
+        end_angle=240
+    },
+    {
+        name='fs_used_perc',
+        arg='/',
+        max=100,
+        bg_colour=0xffffff,
+        bg_alpha=0.2,
+        fg_colour=0xffffff,
+        fg_alpha=0.3,
+        x=165, y=170,
+        radius=135,
+        thickness=50,
+        start_angle=-120,
+        end_angle=120
+    },
+}
+
+require 'cairo'
+
+function rgb_to_r_g_b(colour,alpha)
+    return ((colour / 0x10000) % 0x100) / 255., ((colour / 0x100) % 0x100) / 255., (colour % 0x100) / 255., alpha
+end
+
+function draw_ring(cr,t,pt)
+    local w,h=conky_window.width,conky_window.height
+
+    local xc,yc,ring_r,ring_w,sa,ea=pt['x'],pt['y'],pt['radius'],pt['thickness'],pt['start_angle'],pt['end_angle']
+    local bgc, bga, fgc, fga=pt['bg_colour'], pt['bg_alpha'], pt['fg_colour'], pt['fg_alpha']
+
+    local angle_0=sa*(2*math.pi/360)-math.pi/2
+    local angle_f=ea*(2*math.pi/360)-math.pi/2
+    local t_arc=t*(angle_f-angle_0)
+
+    -- Draw background ring
+
+    cairo_arc(cr,xc,yc,ring_r,angle_0,angle_f)
+    cairo_set_source_rgba(cr,rgb_to_r_g_b(bgc,bga))
+    cairo_set_line_width(cr,ring_w)
+    cairo_stroke(cr)
+
+    -- Draw indicator ring
+
+    cairo_arc(cr,xc,yc,ring_r,angle_0,angle_0+t_arc)
+    cairo_set_source_rgba(cr,rgb_to_r_g_b(fgc,fga))
+    cairo_stroke(cr)        
+end
+
+function 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>5 then
+        for i in pairs(settings_table) do
+            setup_rings(cr,settings_table[i])
+        end
+    end
+       cairo_surface_destroy(cs)
+    cairo_destroy(cr)
+end
diff --git a/data/text.lua b/data/text.lua
new file mode 100644 (file)
index 0000000..ad81b99
--- /dev/null
@@ -0,0 +1,558 @@
+--[[TEXT WIDGET v1.. by Wlourf 25/06/2010
+This widget can drawn texts set in the "text_settings" table with some parameters
+http://u-scripts.blogspot.com/2010/06/text-widget.html
+
+The parameters (all optionals) are :
+text        - text to display, default = "Conky is good for you"
+                         use conky_parse to display conky value ie text=conly_parse("${cpu cpu1}")
+            - coordinates below are relative to top left corner of the conky window
+x           - x coordinate of first letter (bottom-left), default = center of conky window
+y           - y coordinate of first letter (bottom-left), default = center of conky window
+h_align                - horizontal alignement of text relative to point (x,y), default="l"
+                         available values are "l": left, "c" : center, "r" : right
+v_align                - vertical alignment of text relative to point (x,y), default="b"
+                         available values "t" : top, "m" : middle, "b" : bottom
+font_name   - name of font to use, default = Free Sans
+font_size   - size of font to use, default = 14
+italic      - display text in italic (true/false), default=false
+oblique     - display text in oblique (true/false), default=false (I don' see the difference with italic!)
+bold        - display text in bold (true/false), default=false
+angle       - rotation of text in degrees, default = 0 (horizontal)
+colour      - table of colours for text, default = plain white {{1,0xFFFFFF,1}}
+                         this table contains one or more tables with format {P,C,A}
+              P=position of gradient (0 = beginning of text, 1= end of text)
+              C=hexadecimal colour 
+              A=alpha (opacity) of color (0=invisible,1=opacity 100%)
+              Examples :
+              for a plain color {{1,0x00FF00,0.5}}
+              for a gradient with two colours {{0,0x00FF00,0.5},{1,0x000033,1}}
+              or {{0.5,0x00FF00,1},{1,0x000033,1}} -with this one, gradient will start in the middle of the text
+              for a gradient with three colours {{0,0x00FF00,0.5},{0.5,0x000033,1},{1,0x440033,1}}
+                         and so on ...
+orientation    - in case of gradient, "orientation" defines the starting point of the gradient, default="ww"
+                         there are 8 available starting points : "nw","nn","ne","ee","se","ss","sw","ww"
+                         (n for north, w for west ...)
+                         theses 8 points are the 4 corners + the 4 middles of text's outline
+                         so a gradient "nn" will go from "nn" to "ss" (top to bottom, parallele to text)
+                         a gradient "nw" will go from "nw" to "se" (left-top corner to right-bottom corner)
+radial         - define a radial gradient (if present at the same time as "orientation", "orientation" will have no effect)
+                         this parameter is a table with 6 numbers : {xa,ya,ra,xb,yb,rb}
+                         they define two circle for the gradient :
+                         xa, ya, xb and yb are relative to x and y values above
+reflection_alpha    - add a reflection effect (values from 0 to 1) default = 0 = no reflection
+                      other values = starting opacity
+reflection_scale    - scale of the reflection (default = 1 = height of text)
+reflection_length   - length of reflection, define where the opacity will be set to zero
+                                         calues from 0 to 1, default =1
+skew_x,skew_y    - skew text around x or y axis
+                         
+
+Needs conky 1.8.0 
+
+To call this script in the conkyrc, in before-TEXT section:
+    lua_load /path/to/the/lua/script/text.lua
+    lua_draw_hook_pre draw_text
+v1.0   07/06/2010, Original release
+v1.1   10/06/2010      Add "orientation" parameter
+v1.2   15/06/2010  Add "h_align", "v_align" and "radial" parameters
+v1.3   25/06/2010  Add "reflection_alpha", "reflection_length", "reflection_scale", 
+                    "skew_x" et "skew_y"
+
+
+]]
+
+require 'cairo'
+
+function conky_draw_text()
+       local col0,col1,col2=0xFFFFCC,0xCCFF99,0x99FF00
+       local colbg=0x99CCFF
+    local text_settings={
+               {
+                               text=conky_parse("${time %I:%M%p %D}"),
+                               font_size=24,
+                               bold=true,
+                               font_name="Nokia Pure",
+                               h_align="l",
+                               v_align="t",
+                               x=5,
+                               y=5,
+                               reflection_alpha=0,
+                               reflection_length=0,
+ colour={
+         {0.98,    0xFF0000,1},
+         {0.99,    0xFFCC00,1},
+         {1.00,    0xFF0000,1},
+         },
+ radial={400,-700,0,100,-1000,1024}
+               }, 
+               {
+                               text=conky_parse("$sysname $kernel on $machine - $uptime"),
+                               font_size=16,
+                               bold=true,
+                               font_name="Nokia Pure",
+                               h_align="r",
+                               x=800,
+                               y=15,
+                               reflection_alpha=0,
+                               reflection_length=0,
+                               colour={{0,col0,0.75},{1,colbg,0.75}},
+
+               }, 
+               {
+                               text=conky_parse("$freq MHz"),
+                               font_name="Nokia Pure",
+                               font_size=16,
+                               h_align="l",
+                               v_align="t",
+                               bold=true,
+                               x=20,
+                               y=60,
+                               reflection_alpha=0,
+                               reflection_length=0,
+                               colour={{0,col0,1},{0.5,colbg,1}},
+                               orientation="nn",
+               },
+               {
+                   text=conky_parse("${battery_temp}").."\194\176",--yes i had to do the degree symbol like that...
+                       x=794,
+                   y=69,
+                   v_align="m",
+                   h_align="r",
+                   font_name="Nokia Pure",
+                   font_size=14,
+                       colour={{0,col0,1},{0.5,colbg,1}},
+                               orientation="nn",
+               reflection_alpha=0,
+               reflection_length=0,                    
+        }, 
+               {
+                   text=conky_parse("${battery_short} ${battery_volts}mV"),
+                       x=794,
+                   y=45,
+                   v_align="m",
+                   h_align="r",
+                   font_name="Nokia Pure",
+                   font_size=14,
+                       colour={{0,col0,1},{0.5,colbg,1}},
+                               orientation="nn",
+               reflection_alpha=0,
+               reflection_length=0,                    
+        }, 
+               {
+                   text=conky_parse("${cell_radio_dbm}".."dBm"),
+                       x=510,
+                   y=50,
+                   font_name="Nokia Pure",
+                   font_size=14,
+                       colour={{0,col0,1},{0.5,colbg,1}},
+                               orientation="nn",
+               reflection_alpha=0.0,
+               reflection_length=0.0,                  
+        },
+        {
+                   text=conky_parse('${cpu}').."%",
+                       x=223,
+                   y=65,
+                   v_align="t",
+                   h_align="l",
+                   font_name="Nokia Pure",
+                   font_size=18,
+                       colour={{0,col0,1},{0.5,colbg,1}},
+                               orientation="ww",
+               reflection_alpha=0,
+               reflection_length=0,                    
+        },  
+        {
+                   text=conky_parse('${memperc}').."%",
+                   x=223,
+                   y=91,
+                   v_align="t",
+                   font_name="Nokia Pure",
+                   font_size=18,
+                       colour={{0,col0,1},{0.5,colbg,1}},
+                               orientation="nn",
+                               reflection_alpha=0,
+                               reflection_length=0,
+        },
+        {
+                   text=conky_parse('${fs_used /} / ${fs_size /} (${fs_free /})'),
+                   x=5,
+                   y=115,
+                   v_align="t",
+                   font_name="Nokia Pure",
+                   font_size=16,
+                       colour={{conky_parse('${fs_used_perc /}')/100,0x000000,1},{1,0xFFFFFF,1}},
+                               orientation="ww",
+                               reflection_alpha=0,
+                               reflection_length=0,
+        },
+        {
+                   text="/",
+                   x=220,
+                   y=114,
+                   v_align="t",
+                   font_name="Nokia Pure",
+                   font_size=18,
+                       colour={{0,0x336633,1},{1,col0,1}},
+                       bold=true,
+                               orientation="ww",
+                               reflection_alpha=0,
+                               reflection_length=0,
+        },
+        {
+                   text=conky_parse('${fs_used /home} / ${fs_size /home} (${fs_free /home})'),
+                   x=5,
+                   y=135,
+                   v_align="t",
+                   font_name="Nokia Pure",
+                   font_size=16,
+                       colour={{conky_parse('${fs_used_perc /home}')/100,0x000000,1},{1,0xFFFFFF,1}},
+                               orientation="ww",
+                               reflection_alpha=0,
+                               reflection_length=0,
+        },
+        {
+                   text="/home",
+                   x=220,
+                   y=134,
+                   v_align="t",
+                   font_name="Nokia Pure",
+                   font_size=18,
+                       colour={{0,0x336633,1},{1,col0,1}},
+                       bold=true,
+                               orientation="ww",
+                               reflection_alpha=0,
+                               reflection_length=0,
+        },
+        {
+                   text=conky_parse('${fs_used /home/user/MyDocs} / ${fs_size /home/user/MyDocs} (${fs_free /home/user/MyDocs})'),
+                   x=5,
+                   y=155,
+                   v_align="t",
+                   font_name="Nokia Pure",
+                   font_size=16,
+                       colour={{conky_parse('${fs_used_perc /home/user/MyDocs}')/100-.1,0x000000,1},{1,0xFFFFFF,1}},
+                               orientation="ww",
+                               reflection_alpha=0,
+                               reflection_length=0,
+                               DrawMe=conky_parse("${if_mounted /home/user/MyDocs}1$endif")
+        },
+        {
+                   text="MyDocs",
+                   x=220,
+                   y=154,
+                   v_align="t",
+                   font_name="Nokia Pure",
+                   font_size=18,
+                       colour={{0,0x336633,1},{1,col0,1}},
+                       bold=true,
+                               orientation="ww",
+                               reflection_alpha=0,
+                               reflection_length=0,
+                               DrawMe=conky_parse("${if_mounted /home/user/MyDocs}1$endif")
+        },
+ --[[       {
+                   text=conky_parse('${fs_used /media/mmc1} / ${fs_size /media/mmc1} (${fs_free /media/mmc1})'),
+                   x=5,
+                   y=175,
+                   v_align="t",
+                   font_name="Nokia Pure",
+                   font_size=16,
+                       colour={{conky_parse('${fs_used_perc /media/mmc1}')/100-.1,0x000000,1},{1,0xFFFFFF,1}},
+                               orientation="ww",
+                               reflection_alpha=0,
+                               reflection_length=0,
+                               DrawMe=conky_parse("${if_mounted /media/mmc1}1$endif")
+        },
+        {
+                   text="SDCard",
+                   x=220,
+                   y=174,
+                   v_align="t",
+                   font_name="Nokia Pure",
+                   font_size=18,
+                       colour={{0,0x336633,1},{1,col0,1}},
+                       bold=true,
+                               orientation="ww",
+                               reflection_alpha=0,
+                               reflection_length=0,
+                               DrawMe=conky_parse("${if_mounted /media/mmc1}1$endif"),
+        },
+               ]]
+        {
+                   text=conky_parse('${wireless_essid wlan0}'),
+                       x=375,
+                   y=201,
+                   h_align="c",
+                   v_align="m",
+                   font_name="Nokia Pure",
+                   font_size=18,
+                       colour={{0,col0,1},{0.5,colbg,1}},
+                               orientation="nn",
+               reflection_alpha=0,
+               reflection_length=0,
+               DrawMe=conky_parse("${if_up wlan0}1${else}0$endif"),
+        },
+        {
+                   text="GPRS",
+                       x=430,
+                   y=201,
+                   h_align="l",
+                   v_align="m",
+                   font_name="Nokia Pure",
+                   font_size=18,
+                       colour={{0,col0,1},{0.5,colbg,1}},
+                               orientation="nn",
+               reflection_alpha=0,
+               reflection_length=0,
+               DrawMe=conky_parse("${if_up gprs0}1${else}0$endif"),
+        },
+        {
+                   text=conky_parse('${wireless_link_qual_perc wlan0}')..'%',
+                       x=400,
+                   y=228,
+                   h_align="l",
+                   v_align="m",
+                   font_name="Nokia Pure",
+                   font_size=14,
+                       colour={{0,col0,1},{0.5,colbg,1}},
+                               orientation="nn",
+               reflection_alpha=0,
+               reflection_length=0,
+               DrawMe=conky_parse("${if_up wlan0}1${else}0$endif"),
+        },
+        {
+                   text='Up '..conky_parse('${upspeedf wlan0}') + conky_parse('${upspeedf gprs0}'),
+                       x=225,
+                   y=223,
+                   h_align="l",
+                   v_align="m",
+                   font_name="LEDFont",
+                   font_size=22,
+                   bold=true,
+                       colour={{0,0xcc0066,1}},
+                               orientation="ww",
+               reflection_alpha=0,
+               reflection_length=0,
+               DrawMe=conky_parse("${if_up wlan0}1${else}0$endif"),
+        },
+        {
+                   text=conky_parse('${downspeedf wlan0}') + conky_parse('${downspeedf gprs0}')..' Down',
+                       x=650,
+                   y=223,
+                   h_align="r",
+                   v_align="m",
+                   font_name="LEDFont",
+                   font_size=22,
+                   bold=true,
+                       colour={{0,0xcc0066,1}},
+                               orientation="ww",
+               reflection_alpha=0,
+               reflection_length=0,
+               DrawMe=conky_parse("${if_up wlan0}1${else}0$endif"),
+        },
+   --[[     {
+                   text='Up '..conky_parse('${upspeed gprs0}'),
+                       x=225,
+                   y=223,
+                   h_align="l",
+                   v_align="m",
+                   font_name="LEDFont",
+                   font_size=22,
+                   bold=true,
+                       colour={{0,0xcc0066,1}},
+                               orientation="ww",
+               reflection_alpha=0,
+               reflection_length=0,
+               DrawMe=conky_parse("${if_up gprs0}1${else}0$endif"),
+        },
+        {
+                   text=conky_parse('${downspeed gprs0}')..' Down',
+                       x=650,
+                   y=223,
+                   h_align="r",
+                   v_align="m",
+                   font_name="LEDFont",
+                   font_size=22,
+                   bold=true,
+                       colour={{0,0xcc0066,1}},
+                               orientation="ww",
+               reflection_alpha=0,
+               reflection_length=0,
+               DrawMe=conky_parse("${if_up gprs0}1${else}0$endif"),
+        },]]  
+    }
+    if conky_window == nil then return end
+    if tonumber(conky_parse("$updates"))<3 then return end
+       local cs = cairo_xlib_surface_create(conky_window.display, conky_window.drawable, conky_window.visual, conky_window.width, conky_window.height)
+    for i,v in pairs(text_settings) do 
+       cr = cairo_create (cs)
+                       display_text(v)
+           cairo_destroy(cr)
+           cr = nil
+    end
+       cairo_surface_destroy(cs)
+end
+
+function rgb_to_r_g_b2(tcolour)
+    local colour,alpha=tcolour[2],tcolour[3]
+    return ((colour / 0x10000) % 0x100) / 255., ((colour / 0x100) % 0x100) / 255., (colour % 0x100) / 255., alpha
+end
+
+function display_text(t)
+       if t.DrawMe~=nil and t.DrawMe ~= "1" then return end
+       local function set_pattern(te)
+               --this function set the pattern
+               if #t.colour==1 then 
+                   cairo_set_source_rgba(cr,rgb_to_r_g_b2(t.colour[1]))
+               else
+                       local pat
+                       if t.radial==nil then
+                               local pts=linear_orientation(t,te)
+                               pat = cairo_pattern_create_linear (pts[1],pts[2],pts[3],pts[4])
+                       else
+                               pat = cairo_pattern_create_radial (t.radial[1],t.radial[2],t.radial[3],t.radial[4],t.radial[5],t.radial[6])
+                       end
+                   for i=1, #t.colour do
+                       cairo_pattern_add_color_stop_rgba (pat, t.colour[i][1], rgb_to_r_g_b2(t.colour[i]))
+                   end
+                   cairo_set_source (cr, pat)
+                       cairo_pattern_destroy(pat)
+               end
+    end
+    
+    --set default values if needed
+    if t.text==nil then t.text="Conky is good for you !" end
+    if t.x==nil then t.x = conky_window.width/2 end
+    if t.y==nil then t.y = conky_window.height/2 end
+    if t.colour==nil then t.colour={{1,0xFFFFFF,1}} end
+    if t.font_name==nil then t.font_name="Free Sans" end
+    if t.font_size==nil then t.font_size=14 end
+    if t.angle==nil then t.angle=0 end
+    if t.italic==nil then t.italic=false end
+    if t.oblique==nil then t.oblique=false end
+    if t.bold==nil then t.bold=false end
+    if t.radial ~= nil then
+       if #t.radial~=6 then 
+               print ("error in radial table")
+               t.radial=nil 
+       end
+    end
+    if t.orientation==nil then t.orientation="ww" end
+    if t.h_align==nil then t.h_align="l" end
+    if t.v_align==nil then t.v_align="b" end    
+    if t.reflection_alpha == nil then t.reflection_alpha=0 end
+    if t.reflection_length == nil then t.reflection_length=1 end
+    if t.reflection_scale == nil then t.reflection_scale=1 end
+    if t.rotx==nil then t.rotx=0 end
+    if t.roty==nil then t.roty=0 end    
+    cairo_translate(cr,t.x,t.y)
+    cairo_rotate(cr,t.angle*math.pi/180)
+    cairo_save(cr)       
+    local slant = CAIRO_FONT_SLANT_NORMAL
+    local weight = CAIRO_FONT_WEIGHT_NORMAL
+    if t.italic then slant = CAIRO_FONT_SLANT_ITALIC end
+    if t.oblique then slant = CAIRO_FONT_SLANT_OBLIQUE end
+    if t.bold then weight = CAIRO_FONT_WEIGHT_BOLD end
+    cairo_select_font_face(cr, t.font_name, slant,weight)
+    for i=1, #t.colour do    
+        if #t.colour[i]~=3 then 
+               print ("error in color table")
+               t.colour[i]={1,0xFFFFFF,1} 
+        end
+    end
+       local matrix0 = cairo_matrix_t:create()
+       tolua.takeownership(matrix0) 
+       local rotx,roty=t.rotx/t.font_size,t.roty/t.font_size
+       cairo_matrix_init (matrix0, 1,roty,rotx,1,0,0)
+       cairo_transform(cr,matrix0)
+       cairo_set_font_size(cr,t.font_size)
+       local te=cairo_text_extents_t:create()
+       tolua.takeownership(te) 
+    cairo_text_extents (cr,t.text,te)
+       set_pattern(te)
+    local mx,my=0,0
+    if t.h_align=="c" then
+           mx=-te.width/2
+    elseif t.h_align=="r" then
+           mx=-te.width
+       end
+    if t.v_align=="m" then
+           my=-te.height/2-te.y_bearing
+    elseif t.v_align=="t" then
+           my=-te.y_bearing
+       end
+       cairo_move_to(cr,mx,my)
+    cairo_show_text(cr,t.text)
+               
+   if t.reflection_alpha ~= 0 then 
+               local matrix1 = cairo_matrix_t:create()
+               tolua.takeownership(matrix1) 
+               cairo_set_font_size(cr,t.font_size)
+               cairo_matrix_init (matrix1,1,0,0,-1*t.reflection_scale,0,(te.height+te.y_bearing+my)*(1+t.reflection_scale))
+               cairo_set_font_size(cr,t.font_size)
+               te=nil
+               local te=cairo_text_extents_t:create()
+               tolua.takeownership(te) 
+               cairo_text_extents (cr,t.text,te)               
+               cairo_transform(cr,matrix1)
+               set_pattern(te)
+               cairo_move_to(cr,mx,my)
+               cairo_show_text(cr,t.text)
+               local pat2 = cairo_pattern_create_linear (0,
+                                                                               (te.y_bearing+te.height+my),
+                                                                               0,
+                                                                               te.y_bearing+my)
+               cairo_pattern_add_color_stop_rgba (pat2, 0,1,0,0,1-t.reflection_alpha)
+               cairo_pattern_add_color_stop_rgba (pat2, t.reflection_length,0,0,0,1)   
+               cairo_set_line_width(cr,0)
+               local dy=te.x_bearing
+               if dy<0 then dy=dy*(-1) end
+               cairo_rectangle(cr,mx+te.x_bearing,te.y_bearing+te.height+my,te.width+dy,-te.height*1.05)
+               cairo_clip_preserve(cr)
+               cairo_set_operator(cr,CAIRO_OPERATOR_CLEAR)
+               --cairo_stroke(cr)
+               cairo_mask(cr,pat2)
+               cairo_pattern_destroy(pat2)
+               cairo_set_operator(cr,CAIRO_OPERATOR_OVER)
+               te=nil
+    end
+end
+
+
+ function linear_orientation(t,te)
+       local w,h=te.width,te.height
+       local xb,yb=te.x_bearing,te.y_bearing
+       
+    if t.h_align=="c" then
+           xb=xb-w/2
+    elseif t.h_align=="r" then
+           xb=xb-w
+       end     
+    if t.v_align=="m" then
+           yb=-h/2
+    elseif t.v_align=="t" then
+           yb=0
+       end     
+       local p=0
+       if t.orientation=="nn" then
+               p={xb+w/2,yb,xb+w/2,yb+h}
+       elseif t.orientation=="ne" then
+               p={xb+w,yb,xb,yb+h}
+       elseif t.orientation=="ww" then
+               p={xb,h/2,xb+w,h/2}
+       elseif vorientation=="se" then
+               p={xb+w,yb+h,xb,yb}
+       elseif t.orientation=="ss" then
+               p={xb+w/2,yb+h,xb+w/2,yb}
+       elseif vorientation=="ee" then
+               p={xb+w,h/2,xb,h/2}             
+       elseif t.orientation=="sw" then
+               p={xb,yb+h,xb+w,yb}
+       elseif t.orientation=="nw" then
+               p={xb,yb,xb+w,yb+h}
+       end
+       return p
+end
+
index c93f0b5..69bfee8 100644 (file)
@@ -1,9 +1,23 @@
+conky (1.9.8-1) unstable; urgency=low
+
+  * New maemo6 release:
+    - initial release to support harmattan, don't install on maemo5! (sorry)
+      + double buffering doesn't work, screen will flicker, this is not a conky bug. Nokia didn't include the double buffer extension module for x11, ask them!
+      + temperature is not supported at the moment because bme doesn't report it anywhere, that was done with a 3rd party module on n900
+      + cairo / lua work, imlib2 works, but these things aren't necessarily in the repositories so please google them to find them for now. you won't be able to install without those!
+      + this app may crash when swiping it away, and may ignore the down swipe to close, i have no idea why. 
+      + read/write io stats is a kernel feature that titan put into the power kernel on n900, feel free to bug nokia or replace the kernel with a 3rd party one to fix those from being 0
+      + I spent lots of time fixing compiling issues and major issues in the lua and .conf files so didn't have time to optimize them for the 48 extra pixels of width or get everything perfect YET. Please be patient or contribute :)
+
+ -- Lance Colton <lance.colton@gmail.com>  Tue, 08 Nov 2011 21:00:00 -0700
+
 conky (1.9.7-1) unstable; urgency=low
 
   * New maemo release:
     - fixes for power kernel v47 
       + temperature and voltage are reported differently by this kernel and needed to be adjusted
       + temperature is now reported to the tenth of the degree and your conf file may need to be adjusted to account for this additional digit
+      + enabled cairo / lua scripting
 
  -- Lance Colton <lance.colton@gmail.com>  Mon, 23 May 2011 16:00:00 -0700
 
diff --git a/debian/conky-n900.docs b/debian/conky-n900.docs
deleted file mode 100644 (file)
index 7d677cb..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-AUTHORS
-README
-doc/docs.html 
-doc/variables.html 
-doc/config_settings.html
-doc/lua.html
diff --git a/debian/conky-n900.install b/debian/conky-n900.install
deleted file mode 100644 (file)
index 9e9e5fe..0000000
+++ /dev/null
@@ -1 +0,0 @@
-debian/conky.py usr/share/apport/package-hooks/
diff --git a/debian/conky-n900.menu b/debian/conky-n900.menu
deleted file mode 100644 (file)
index cb17490..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-?package(conky-n900):needs="text" section="Applications/System/Monitoring"\
-  title="Conky" command="/usr/bin/conky"
diff --git a/debian/conky-n950.docs b/debian/conky-n950.docs
new file mode 100644 (file)
index 0000000..7d677cb
--- /dev/null
@@ -0,0 +1,6 @@
+AUTHORS
+README
+doc/docs.html 
+doc/variables.html 
+doc/config_settings.html
+doc/lua.html
diff --git a/debian/conky-n950.install b/debian/conky-n950.install
new file mode 100644 (file)
index 0000000..9e9e5fe
--- /dev/null
@@ -0,0 +1 @@
+debian/conky.py usr/share/apport/package-hooks/
diff --git a/debian/conky-n950.menu b/debian/conky-n950.menu
new file mode 100644 (file)
index 0000000..17f5fd3
--- /dev/null
@@ -0,0 +1,2 @@
+?package(conky-n950):needs="text" section="Applications/System/Monitoring"\
+  title="Conky" command="/usr/bin/conky"
index ee1ea7f..810c533 100644 (file)
@@ -1,7 +1,7 @@
 Source: conky
 Section: user/desktop
 Priority: optional
-Maintainer: Darren Long darren.long@mac.com
+Maintainer: Lance Colton Lance.Colton@gmail.com
 XSBC-Original-Maintainer: Cesare Tirabassi <norsetto@ubuntu.com>
 Build-Depends: debhelper (>= 5.0.0), libtool, automake,
               pkg-config (>= 0.19), libx11-dev, libxft-dev,
@@ -10,35 +10,40 @@ Build-Depends: debhelper (>= 5.0.0), libtool, automake,
               libiw-dev[!kfreebsd-i386 !kfreebsd-amd64 !hurd-i386],
               libasound2-dev [!kfreebsd-i386 !kfreebsd-amd64 !hurd-i386],
               libkvm-dev [kfreebsd-i386 kfreebsd-amd64],
-              libdevstat-dev [kfreebsd-i386 kfreebsd-amd64],
-              libncurses5-dev, liblua5.1-0-dev, libdbus-1-dev, libcairo2-dev
+              libdevstat-dev [kfreebsd-i386 kfreebsd-amd64], libcurl4-openssl-dev,
+              libncurses5-dev, liblua5.1-0-dev, libdbus-1-dev, libcairo2-dev, tolua++
 Homepage: http://conky.sourceforge.net/
 Standards-Version: 3.8.4
 
-Package: conky-n900
+Package: conky-n950
 Architecture: armel
 Depends: ${shlibs:Depends}, ${misc:Depends}
 Recommends: 
 Suggests: moc, mpd
 Conflicts: conky-std, conky-cli
-Replaces: conky, conky-std, conky-cli, conky-all
-Description: Highly configurable system monitor (most features enabled)
- Conky is a system monitor that can display just about anything,
- either on your root desktop or in its own window.
+Replaces: conky, conky-std, conky-cli, conky-all, conky-n900
+Description: Highly configurable system monitor
+ Conky is a system monitor that can display just about anything.
  Conky has many built-in objects, as well as the ability to execute
  external programs or scripts (either external or through built-in
- lua support). 
+ lua support). It is designed for the desktop and ported to the maemo
+ platform. 
  .
- This is a full(ish) conky with most compile options enabled:
+ This is a full Conky with most compile options enabled, but since
+ you are running on a phone and this software is not really for phones
+ there are a few problems. Nokia cut some corners in the kernel that makes
+ the diskio stats less detailed and X11 is not able to double buffer.
+ Probably this will get fixed very soon but I cannot guarantee it. 
  .
- X11, XDamage, XDBE, Xft, MPD, MOC, OpenMP, math, hddtemp, portmon, RSS,
- Weather, wireless, IBM, eve-online, ALSA mixer,
- apcupsd, I/O stats, argb.
- .
- Maemo5: This port for maemo5 is intended to be run as a standalone
- app and not as a desktop widget.  The default config has been reworked
- for suitability for the N900 platform. The launcher checks for the file
+ Maemo6: This port for maemo6 is intended to be run as a standalone
+ app. The default config has been reworked for suitability for the N9
+ and N950 phones. The launcher checks for the file 
  /home/user/MyDocs/conky.conf and will run with that if it is present.
+ If you want to play with the config I would suggest that you 
+ copy all the files from /etc/conky to MyDocs and edit them there. 
+ You could also look for some to download and place them there.
+ DO NOT change the ones in the /etc/conky folder as the changes would
+ be lost when this app is updated next time.
 Xsbc-Bugtracker: https://bugs.maemo.org/enter_bug.cgi?product=conky
 XB-Maemo-Display-Name: Conky
 XB-Maemo-Icon-26:
diff --git a/debian/optify b/debian/optify
deleted file mode 100644 (file)
index 865faf1..0000000
+++ /dev/null
@@ -1 +0,0 @@
-auto
index 0dd80df..b12ba3a 100644 (file)
@@ -57,7 +57,7 @@ config-stamp:
 
        cd build-all && CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" \
        ../configure $(COMMON_CONFIGURE_FLAGS) \
-        --enable-rss --enable-weather-xoap \
+        --enable-rss --enable-weather-xoap LUA51_LIBS='-llua5.1 -lm' \
        --enable-eve --enable-lua=yes --enable-lua-cairo --enable-lua-imlib2 \
        --disable-static --enable-argb --enable-x11 --enable-imlib2 \
        $(LINUX_CONF_ARGS_ALL) $(ENABLE_NVIDIA)
@@ -81,7 +81,7 @@ clean:
 
        rm  -f configure.ac configure config.h.in src/config.h.in \
               src/defconfig.h compile install-sh missing ltmain.sh depcomp \
-              Makefile.in doc/Makefile.in src/Makefile.in \
+              Makefile.in doc/Makefile.in src/Makefile.in  src/dbus/Makefile.in \
               data/Makefile.in lua/Makefile.in \
               aclocal.m4 m4/libtool.m4 m4/ltversion.m4 \
               m4/lt~obsolete.m4 m4/ltoptions.m4 m4/ltsugar.m4
@@ -96,20 +96,20 @@ install: build
        dh_testroot
        dh_clean -k 
 
-       cd build-all && $(MAKE) install DESTDIR=$(CURDIR)/debian/conky-n900
-       mkdir -p debian/conky-n900/usr/share/icons/hicolor/scalable/apps/
-       cp -p debian/conkylogo64.png debian/conky-n900/usr/share/icons/hicolor/scalable/apps/conky.png
-       mkdir -p debian/conky-n900/usr/share/icons/hicolor/48x48/apps/
-       cp -p debian/conkylogo48.png debian/conky-n900/usr/share/icons/hicolor/48x48/apps/conky.png
-       mkdir -p debian/conky-n900/usr/share/applications/hildon/
-       cp -p debian/conky.desktop debian/conky-n900/usr/share/applications/hildon/conky.desktop
-       mkdir -p debian/conky-n900/usr/bin/
-       cp -p debian/conky.sh debian/conky-n900/usr/bin/
+       cd build-all && $(MAKE) install DESTDIR=$(CURDIR)/debian/conky-n950
+       mkdir -p debian/conky-n950/usr/share/icons/hicolor/scalable/apps/
+       cp -p debian/conkylogo64.png debian/conky-n950/usr/share/icons/hicolor/scalable/apps/conky.png
+       mkdir -p debian/conky-n950/usr/share/icons/hicolor/48x48/apps/
+       cp -p debian/conkylogo48.png debian/conky-n950/usr/share/icons/hicolor/48x48/apps/conky.png
+       mkdir -p debian/conky-n950/usr/share/applications/
+       cp -p debian/conky.desktop debian/conky-n950/usr/share/applications/conky.desktop
+       mkdir -p debian/conky-n950/usr/bin/
+       cp -p debian/conky.sh debian/conky-n950/usr/bin/
 
        # Clean up cruft left upstream
        rm -rf debian/conky-std/usr/lib debian/conky-cli/usr/lib \
-              debian/conky-n900/usr/lib/conky/*.la \
-              debian/conky-n900/usr/lib/conky/*.so.?
+              debian/conky-n950/usr/lib/conky/*.la \
+              debian/conky-n950/usr/lib/conky/*.so.?
 
 binary-indep: build install
 
@@ -128,7 +128,6 @@ binary-arch: build install
        dh_installdeb
        dh_shlibdeps
        dh_gencontrol
-       maemo-optify
        dh_md5sums
        dh_builddeb
 
index 0efed32..c1ea177 100644 (file)
@@ -6,10 +6,12 @@ do
        require 'misc'
        require 'luatraverse'
        require 'strict'
+       require 'box'
 
        --local count
        
        function conky_main() --conky will run this if you specified to load 'main' in the conf
+               conky_main_box()
                conky_main_bars()
                conky_main_graph()
                conky_draw_text()
index 6b942eb..675941e 100644 (file)
@@ -116,7 +116,7 @@ function conky_main_bars()
                        mid_colour={{0.5,0xffff00,1}},
                        DrawMe=conky_parse("${if_mounted /home/user/MyDocs}1$endif")
                },      
-               {
+               --[[{
                        name="fs_used",
                        arg="/media/mmc1",
                        max=conky_parse("${to_bytes ${fs_size /media/mmc1}}"),
@@ -131,7 +131,7 @@ function conky_main_bars()
                        smooth=true,
                        mid_colour={{0.5,0xffff00,1}},
                        DrawMe=conky_parse("${if_mounted /media/mmc1}1$endif")
-               },
+               },]]
                {
                        name="mem",
                        arg="",
diff --git a/lua_scripts/conky.conf b/lua_scripts/conky.conf
new file mode 100644 (file)
index 0000000..d5576f1
--- /dev/null
@@ -0,0 +1,92 @@
+#lua_load /home/user/MyDocs/testCairo.lua
+#lua_load ~/scripts/bargraph2/bargraph_eng.lua
+#lua_draw_hook_pre main_bars
+#lua_draw_hook_pre ring_stats
+#lua_load /home/user/MyDocs/bargraph_eng.lua
+#lua_load /home/user/MyDocs/piechart.lua
+#lua_load /home/user/MyDocs/Text.lua 
+#lua_load /home/user/MyDocs/graph.lua
+#lua_draw_hook_post main_pie
+#lua_draw_hook_pre main_bars
+#lua_draw_hook_pre main_graph
+#lua_draw_hook_post draw_text
+lua_load /home/user/MyDocs/LoadAll.lua
+lua_draw_hook_pre main
+
+
+# cpu red    > white                                                                                                
+# memory blue  > white                                                                                                   
+# disk green > white                                                                                                    
+#                                                                                                     
+#                                                                                                     
+#                                                                                                     
+# cool blue > cyan: 0000ff 00FFFF                                                                                  
+#                                                                                                     
+
+alignment top_left
+background no
+maximum_width 854
+border_width 1
+cpu_avg_samples 2
+default_outline_color white
+default_shade_color white
+diskio_avg_samples 10
+draw_borders no
+draw_graph_borders yes
+draw_outline no
+draw_shades no
+double_buffer yes
+gap_x 20
+gap_y 60
+minimum_size 5 5
+net_avg_samples 2
+no_buffers yes
+out_to_console no
+own_window yes
+own_window_class Conky
+own_window_type normal
+own_window_transparent no
+own_window_hints fullscreen
+#own_window_colour ff0000
+override_utf8_locale yes
+show_graph_scale no
+show_graph_range no
+short_units yes
+stippled_borders 0
+temperature_unit celsius
+update_interval 1.5
+update_interval_on_battery 4
+uppercase no
+use_spacer none
+use_xft yes
+xftfont Nokia Pure:size=11
+xftalpha 0.8
+
+default_color FFFFFF
+
+TEXT
+${image /home/user/MyDocs/lua/n950-kobol.jpg}
+
+
+${goto 265}${color 4072a5}Load1 avg: ${goto 517}${color 4072a5}Processes:$color $processes
+${color 4072a5}${goto 265}Load 1/5/15: $color$loadavg${goto 517}${color 4072a5}Running:${goto 620}$color$running_processes
+${voffset -10}
+${color 4072a5}${goto 315} Top I/O         READ  WRITE      %
+${color red}   ${goto 315} ${lua_parse top_io_colour 1}
+${color       }${goto 315} ${lua_parse top_io_colour 2}
+${color       }${goto 315} ${lua_parse top_io_colour 3}
+
+
+${voffset 10}
+${color 33cc99}CONNECTIONS [$color${tcp_portmon 1 65535 count}${color 33cc99}] (lport:rservice:rport):$color                                            ${goto 405}${tcp_portmon 1 65535 lservice 0}${goto 450}:${scroll 32 5${tcp_portmon 1 65535 rhost 0}}${goto 744}:${scroll 5 1 ${tcp_portmon 1 65535 rservice 0}}
+$color${tcp_portmon 1 65535 lservice 1}${goto 50}:${scroll 32 5${tcp_portmon 1 65535 rhost 1}}${goto 345}:${scroll 5 2${tcp_portmon 1 65535 rservice 1}}${goto 405}${tcp_portmon 1 65535 lservice 2}${goto 450}:${scroll 32 5${tcp_portmon 1 65535 rhost 2}}${goto 744}:${scroll 5 1 ${tcp_portmon 1 65535 rservice 2}}
+$color${tcp_portmon 1 65535 lservice 3}${goto 50}:${scroll 32 5${tcp_portmon 1 65535 rhost 3}}${goto 345}:${scroll 5 2${tcp_portmon 1 65535 rservice 3}}${goto 405}${tcp_portmon 1 65535 lservice 4}${goto 450}:${scroll 32 5${tcp_portmon 1 65535 rhost 4}}${goto 744}:${scroll 5 1 ${tcp_portmon 1 65535 rservice 4}}
+$color${tcp_portmon 1 65535 lservice 5}${goto 50}:${scroll 32 5${tcp_portmon 1 65535 rhost 5}}${goto 345}:${scroll 5 2${tcp_portmon 1 65535 rservice 5}}${goto 405}${tcp_portmon 1 65535 lservice 6}${goto 450}:${scroll 32 5${tcp_portmon 1 65535 rhost 6}}${goto 744}:${scroll 5 1 ${tcp_portmon 1 65535 rservice 6}}
+$color${tcp_portmon 1 65535 lservice 7}${goto 50}:${scroll 32 5${tcp_portmon 1 65535 rhost 7}}${goto 345}:${scroll 5 2${tcp_portmon 1 65535 rservice 7}}${goto 405}${tcp_portmon 1 65535 lservice 8}${goto 450}:${scroll 32 5${tcp_portmon 1 65535 rhost 8}}${goto 744}:${scroll 5 1 ${tcp_portmon 1 65535 rservice 8}}
+$color${tcp_portmon 1 65535 lservice 9}${goto 50}:${scroll 32 5${tcp_portmon 1 65535 rhost 9}}${goto 345}:${scroll 5 2${tcp_portmon 1 65535 rservice 9}}${goto 405}${tcp_portmon 1 65535 lservice 10}${goto 450}:${scroll 32 5${tcp_portmon 1 65535 rhost 10}}${goto 744}:${scroll 5 1 ${tcp_portmon 1 65535 rservice 10}}
+${voffset 10}${color 4072a5}Top CPU%          CPU%  MEM%       ${goto 257}${color 4072a5} | ${color 4072a5}Top Total Memory  RAM     VM                              ${goto 555}${color 4072a5}| ${color 4072a5}Top CPU TIME     MM:SS.cs
+${lua_parse top_cpu_colour 1}                     ${goto 257}${color 4072a5} | ${lua_parse top_mem_colour 1}                                                                                                                                                    ${goto 555}${color 4072a5}| ${color    }${top_time name 1}${top_time time 1} ${top_time cpu 1}
+$color${top name 2}${top cpu 2}${top mem 2}       ${goto 257}${color 4072a5} | ${lua_parse top_mem_colour 2}                                                                                                                                                                    ${goto 555}${color 4072a5}| ${color    }${top_time name 2}${top_time time 2} ${top_time cpu 2}
+$color${top name 3}${top cpu 3}${top mem 3}       ${goto 257}${color 4072a5} | ${lua_parse top_mem_colour 3}                                                                                                                                                                    ${goto 555}${color 4072a5}| ${color    }${top_time name 3}${top_time time 3} ${top_time cpu 3}
+$color${top name 4}${top cpu 4}${top mem 4}       ${goto 257}${color 4072a5} | ${lua_parse top_mem_colour 4}                                                                                                                                                                    ${goto 555}${color 4072a5}| ${color    }${top_time name 4}${top_time time 4} ${top_time cpu 4}
+$color${top name 5}${top cpu 5}${top mem 5}       ${goto 257}${color 4072a5} | ${lua_parse top_mem_colour 5}                                                                                                                                                                    ${goto 555}${color 4072a5}| ${color    }${top_time name 5}${top_time time 5} ${top_time cpu 5}
\ No newline at end of file
index 4ad46dd..dbff1d4 100644 (file)
@@ -92,133 +92,133 @@ require 'cairo'
 function set_settings()
        graph_settings={
            {
-           name="cpu",
-           arg="",
-           max=100,
-      y=85,
-      x=5,
-      autoscale=false,
-      width=215,
-      height=30,
-      nb_values=120,
-      fg_bd_size=2,
-      bg_colour = {{0,0x007AF6,0},{1,0x000000,0}},
-      --fg_bd_colour = { {0,0xFF0000,1},{0.5,0xFFA209,1},{1,0xFFFF00,1}},
-      fg_bd_colour = { {0,0xFF0000,1},{0.5,0xFF3300,1},{1,0xFFFFFF,1}},
-      --fg_colour = { {0,0xFF0000,1},{0.5,0xFFA209,1},{1,0xFFFF00,1}},
-      fg_colour = { {0,0x00CCFF,0.7},{0.5,0x0000FF,0.7},{1,0x000000,0.1}},
-      foreground=true,
-      fg_orientation="ne",
-      bg_bd_orientation="nn",
-      bg_orientation="ne",
-           },
+                       name="cpu",
+                       arg="",
+                       max=100,
+                       y=87,
+                       x=5,
+                       autoscale=false,
+                       width=215,
+                       height=29,
+                       nb_values=120,
+                       fg_bd_size=2,
+                       bg_colour = {{0,0x007AF6,0},{1,0x000000,0}},
+                       --fg_bd_colour = { {0,0xFF0000,1},{0.5,0xFFA209,1},{1,0xFFFF00,1}},
+                       fg_bd_colour = { {0,0xFF0000,1},{0.5,0xFF3300,1},{1,0xFFFFFF,1}},
+                       --fg_colour = { {0,0xFF0000,1},{0.5,0xFFA209,1},{1,0xFFFF00,1}},
+                       fg_colour = { {0,0x00CCFF,0.7},{0.5,0x0000FF,0.7},{1,0x000000,0.1}},
+                       foreground=true,
+                       fg_orientation="ne",
+                       bg_bd_orientation="nn",
+                       bg_orientation="ne",
+               },
            {
-           name="upspeedf",
-           arg="wlan0",
-           max=9999,
-      y=233,
-      x=5,
-      autoscale=true,
-      width=275,
-      height=35,
-      nb_values=120,
-      fg_bd_size=1,
-      bg_colour = {{0,0x007AF6,0},{1,0x000000,0}},
-      fg_bd_colour = { {0,0xFF0000,1},{0.5,0xFFA209,0.8},{1,0xFFFF00,0.6}},
-      fg_colour = { {0,0xFF0000,0.65},{0.5,0xFFA209,0.5},{1,0xFFFF00,0.3}},
-      foreground=true,
-      inverse=true,
-      DrawMe="${if_empty ${wireless_essid wlan0}}${else}1$endif",
-      bg_orientation="ww",
+                       name="upspeedf",
+                       arg="wlan0",
+                       max=9999,
+                       y=233,
+                       x=5,
+                       autoscale=true,
+                       width=275,
+                       height=35,
+                       nb_values=120,
+                       fg_bd_size=1,
+                       bg_colour = {{0,0x007AF6,0},{1,0x000000,0}},
+                       fg_bd_colour = { {0,0xFF0000,1},{0.5,0xFFA209,0.8},{1,0xFFFF00,0.6}},
+                       fg_colour = { {0,0xFF0000,0.65},{0.5,0xFFA209,0.5},{1,0xFFFF00,0.3}},
+                       foreground=true,
+                       inverse=true,
+                       DrawMe="${if_up wlan0}1${else}0$endif",
+                       bg_orientation="ww",
            },
            {
-           name="downspeedf",
-           arg="wlan0",
-           max=9999,
-      y=233,
-      x=525,
-      autoscale=true,
-      width=275,
-      height=35,
-      nb_values=120,
-      fg_bd_size=1,
-      bg_colour = {{0,0x007AF6,0},{1,0x000000,0}},
-      fg_bd_colour = { {0,0xFF0000,1},{0.5,0xFFA209,0.8},{1,0xFFFF00,0.6}},
-      fg_colour = { {0,0xFF0000,0.65},{0.5,0xFFA209,0.5},{1,0xFFFF00,0.3}},
-      foreground=true,
-      DrawMe="${if_empty ${wireless_essid wlan0}}${else}1$endif",
-      bg_orientation="ee",
+                       name="downspeedf",
+                       arg="wlan0",
+                       max=9999,
+                       y=233,
+                       x=525,
+                       autoscale=true,
+                       width=275,
+                       height=35,
+                       nb_values=120,
+                       fg_bd_size=1,
+                       bg_colour = {{0,0x007AF6,0},{1,0x000000,0}},
+                       fg_bd_colour = { {0,0xFF0000,1},{0.5,0xFFA209,0.8},{1,0xFFFF00,0.6}},
+                       fg_colour = { {0,0xFF0000,0.65},{0.5,0xFFA209,0.5},{1,0xFFFF00,0.3}},
+                       foreground=true,
+                       DrawMe="${if_up wlan0}1${else}0$endif",
+                       bg_orientation="ee",
            },
            {
-           name="upspeedf",
-           arg="gprs0",
-           max=9999,
-      y=230,
-      x=5,
-      autoscale=true,
-      width=275,
-      height=35,
-      nb_values=120,
-      fg_bd_size=1,
-      bg_colour = {{0,0x007AF6,0},{1,0x000000,0}},
-      fg_bd_colour = { {0,0xFF0000,1},{0.5,0xFFA209,1},{1,0xFFFF00,1}},
-      fg_colour = { {0,0xFF0000,1},{0.5,0xFFA209,1},{1,0xFFFF00,1}},
-      foreground=true,
-      inverse=true,
-      DrawMe="${if_up gprs0}1${else}0$endif",
-      bg_orientation="ww",
+                       name="upspeedf",
+                       arg="gprs0",
+                       max=9999,
+                       y=233,
+                       x=5,
+                       autoscale=true,
+                       width=275,
+                       height=35,
+                       nb_values=120,
+                       fg_bd_size=1,
+                       bg_colour = {{0,0x007AF6,0},{1,0x000000,0}},
+                       fg_bd_colour = { {0,0xFF0000,1},{0.5,0xFFA209,0.8},{1,0xFFFF00,0.6}},
+                       fg_colour = { {0,0xFF0000,0.65},{0.5,0xFFA209,0.5},{1,0xFFFF00,0.3}},
+                       foreground=true,
+                       inverse=true,
+                       DrawMe="${if_up gprs0}1${else}0$endif",
+                       bg_orientation="ww",
            },
            {
-           name="downspeedf",
-           arg="gprs0",
-           max=9999,
-      y=230,
-      x=525,
-      autoscale=true,
-      width=275,
-      height=35,
-      nb_values=120,
-      fg_bd_size=1,
-      bg_colour = {{0,0x007AF6,0},{1,0x000000,0}},
-      fg_bd_colour = { {0,0xFF0000,1},{0.5,0xFFA209,1},{1,0xFFFF00,1}},
-      fg_colour = { {0,0xFF0000,1},{0.5,0xFFA209,1},{1,0xFFFF00,1}},
-      foreground=true,
-      DrawMe="${if_up gprs0}1${else}0$endif",
-      bg_orientation="ee",
+                       name="downspeedf",
+                       arg="gprs0",
+                       max=9999,
+                       y=233,
+                       x=525,
+                       autoscale=true,
+                       width=275,
+                       height=35,
+                       nb_values=120,
+                       fg_bd_size=1,
+                       bg_colour = {{0,0x007AF6,0},{1,0x000000,0}},
+                       fg_bd_colour = { {0,0xFF0000,1},{0.5,0xFFA209,0.8},{1,0xFFFF00,0.6}},
+                       fg_colour = { {0,0xFF0000,0.65},{0.5,0xFFA209,0.5},{1,0xFFFF00,0.3}},
+                       foreground=true,
+                       DrawMe="${if_up gprs0}1${else}0$endif",
+                       bg_orientation="ee",
            },
            {
-           name="loadavg",
-           arg="1",
-           max=20,
-      y=95,
-      x=372,
-      autoscale=true,
-      width=140,
-      height=36,
-      nb_values=100,
-      fg_bd_size=0,
-      bg_colour = {{0,0x667AF6,0},{1,0x000000,0}},
-      fg_bd_colour =  { {0,0xdd0000,0.7},{0.5,0xdddd00,0.7},{1,0xFFFF00,0.7}},
-      fg_colour = { {0,0x000000,0.7},{0.5,0xdd0000,0.7},{1,0xff0000,0.7}},
-      foreground=true,
+                       name="loadavg",
+                       arg="1",
+                       max=20,
+                       y=95,
+                       x=372,
+                       autoscale=true,
+                       width=140,
+                       height=36,
+                       nb_values=100,
+                       fg_bd_size=0,
+                       bg_colour = {{0,0x667AF6,0},{1,0x000000,0}},
+                       fg_bd_colour =  { {0,0xdd0000,0.7},{0.5,0xdddd00,0.7},{1,0xFFFF00,0.7}},
+                       fg_colour = { {0,0x000000,0.7},{0.5,0xdd0000,0.7},{1,0xff0000,0.7}},
+                       foreground=true,
            },
            {
-           name="to_bytes ${diskio",
-           arg="mmcblk0}",
-           max=2500000,
-      y=187,
-      x=640,
-      autoscale=true,
-      width=160,
-      height=89,
-      nb_values=130,
-      fg_bd_size=0,
-      bg_colour = {{0,0x667AF6,0},{1,0x000000,0}},
-      fg_bd_colour =  { {0,0xdd0000,1},{0.5,0xdddd00,1},{1,0xFFFF00,1}},
-      fg_colour = { {1,0x111111,0.3},{0.5,0x33cc00,0.6},{0,0x00FF00,0.8}},
-      foreground=true,
-      bg_orientation="ne",
-      fg_orientation="ee",
+                       name="to_bytes ${diskio",
+                       arg="mmcblk0}",
+                       max=2500000,
+                       y=187,
+                       x=640,
+                       autoscale=true,
+                       width=160,
+                       height=89,
+                       nb_values=130,
+                       fg_bd_size=0,
+                       bg_colour = {{0,0x667AF6,0},{1,0x000000,0}},
+                       fg_bd_colour =  { {0,0xdd0000,1},{0.5,0xdddd00,1},{1,0xFFFF00,1}},
+                       fg_colour = { {1,0x111111,0.3},{0.5,0x33cc00,0.6},{0,0x00FF00,0.8}},
+                       foreground=true,
+                       bg_orientation="ne",
+                       fg_orientation="ee",
            },
     }
 end
diff --git a/lua_scripts/n900-kobol.jpg b/lua_scripts/n900-kobol.jpg
deleted file mode 100644 (file)
index d980669..0000000
Binary files a/lua_scripts/n900-kobol.jpg and /dev/null differ
diff --git a/lua_scripts/n950-kobol.jpg b/lua_scripts/n950-kobol.jpg
new file mode 100644 (file)
index 0000000..6d69cca
Binary files /dev/null and b/lua_scripts/n950-kobol.jpg differ
index e9c0464..5320cce 100644 (file)
@@ -31,7 +31,7 @@ line_space                    -- vertical space between two lines, default=10 pixels
 extend_line                    -- grow up the line (true/false) if length of text> line_length, default=true
 nb_decimals                    -- number of decimals for numbers, default=1
 show_text                      -- display text (true/false), default=true
-font_name                      -- font, default "Droid Sans Mono"
+font_name                      -- font, default "Nokia Pure"
 font_size                      -- font size, default=12
 font_color                     -- font color (for gradient) or nil (for constant color), default = nil
 font_alpha                     -- font alpha, default=1
@@ -68,7 +68,7 @@ function conky_main_pie()
 
 -- ------------------PARAMETERS TO SET-----------------------
     --theses parameters are called many times so I put them into variables
-    local font_name,font_size="Droid Sans Mono",14
+    local font_name,font_size="Nokia Pure",14
     local col0,col1,col2=0xFFFFCC,0xCCFF99,0x99FF00
     local colbg=0x99CCFF
         
@@ -365,7 +365,7 @@ function draw_pie(t)
     if t.line_space==nil then t.line_space=10 end
     if t.line_width==nil then t.line_width=1 end
     if t.extend_line==nil then t.extend_line=true end
-    if t.txt_font==nil then t.txt_font="Droid Sans Mono" end
+    if t.txt_font==nil then t.txt_font="Nokia Pure" end
     if t.font_size==nil then t.font_size=12 end
     --if t.font_color==nil then t.font_color=0xFFFFFF end
     if t.font_alpha==nil then t.font_alpha = 1 end
index 0f5fbfc..ad81b99 100644 (file)
@@ -72,7 +72,7 @@ function conky_draw_text()
                                text=conky_parse("${time %I:%M%p %D}"),
                                font_size=24,
                                bold=true,
-                               font_name="Droid Sans Mono",
+                               font_name="Nokia Pure",
                                h_align="l",
                                v_align="t",
                                x=5,
@@ -90,7 +90,7 @@ function conky_draw_text()
                                text=conky_parse("$sysname $kernel on $machine - $uptime"),
                                font_size=16,
                                bold=true,
-                               font_name="Droid Sans Mono",
+                               font_name="Nokia Pure",
                                h_align="r",
                                x=800,
                                y=15,
@@ -101,7 +101,7 @@ function conky_draw_text()
                }, 
                {
                                text=conky_parse("$freq MHz"),
-                               font_name="Droid Sans Mono",
+                               font_name="Nokia Pure",
                                font_size=16,
                                h_align="l",
                                v_align="t",
@@ -119,7 +119,7 @@ function conky_draw_text()
                    y=69,
                    v_align="m",
                    h_align="r",
-                   font_name="Droid Sans Mono",
+                   font_name="Nokia Pure",
                    font_size=14,
                        colour={{0,col0,1},{0.5,colbg,1}},
                                orientation="nn",
@@ -132,7 +132,7 @@ function conky_draw_text()
                    y=45,
                    v_align="m",
                    h_align="r",
-                   font_name="Droid Sans Mono",
+                   font_name="Nokia Pure",
                    font_size=14,
                        colour={{0,col0,1},{0.5,colbg,1}},
                                orientation="nn",
@@ -143,7 +143,7 @@ function conky_draw_text()
                    text=conky_parse("${cell_radio_dbm}".."dBm"),
                        x=510,
                    y=50,
-                   font_name="Droid Sans Mono",
+                   font_name="Nokia Pure",
                    font_size=14,
                        colour={{0,col0,1},{0.5,colbg,1}},
                                orientation="nn",
@@ -156,7 +156,7 @@ function conky_draw_text()
                    y=65,
                    v_align="t",
                    h_align="l",
-                   font_name="Droid Sans Mono",
+                   font_name="Nokia Pure",
                    font_size=18,
                        colour={{0,col0,1},{0.5,colbg,1}},
                                orientation="ww",
@@ -168,7 +168,7 @@ function conky_draw_text()
                    x=223,
                    y=91,
                    v_align="t",
-                   font_name="Droid Sans Mono",
+                   font_name="Nokia Pure",
                    font_size=18,
                        colour={{0,col0,1},{0.5,colbg,1}},
                                orientation="nn",
@@ -180,7 +180,7 @@ function conky_draw_text()
                    x=5,
                    y=115,
                    v_align="t",
-                   font_name="Droid Sans Mono",
+                   font_name="Nokia Pure",
                    font_size=16,
                        colour={{conky_parse('${fs_used_perc /}')/100,0x000000,1},{1,0xFFFFFF,1}},
                                orientation="ww",
@@ -192,7 +192,7 @@ function conky_draw_text()
                    x=220,
                    y=114,
                    v_align="t",
-                   font_name="Droid Sans Mono",
+                   font_name="Nokia Pure",
                    font_size=18,
                        colour={{0,0x336633,1},{1,col0,1}},
                        bold=true,
@@ -205,7 +205,7 @@ function conky_draw_text()
                    x=5,
                    y=135,
                    v_align="t",
-                   font_name="Droid Sans Mono",
+                   font_name="Nokia Pure",
                    font_size=16,
                        colour={{conky_parse('${fs_used_perc /home}')/100,0x000000,1},{1,0xFFFFFF,1}},
                                orientation="ww",
@@ -217,7 +217,7 @@ function conky_draw_text()
                    x=220,
                    y=134,
                    v_align="t",
-                   font_name="Droid Sans Mono",
+                   font_name="Nokia Pure",
                    font_size=18,
                        colour={{0,0x336633,1},{1,col0,1}},
                        bold=true,
@@ -230,7 +230,7 @@ function conky_draw_text()
                    x=5,
                    y=155,
                    v_align="t",
-                   font_name="Droid Sans Mono",
+                   font_name="Nokia Pure",
                    font_size=16,
                        colour={{conky_parse('${fs_used_perc /home/user/MyDocs}')/100-.1,0x000000,1},{1,0xFFFFFF,1}},
                                orientation="ww",
@@ -243,7 +243,7 @@ function conky_draw_text()
                    x=220,
                    y=154,
                    v_align="t",
-                   font_name="Droid Sans Mono",
+                   font_name="Nokia Pure",
                    font_size=18,
                        colour={{0,0x336633,1},{1,col0,1}},
                        bold=true,
@@ -252,12 +252,12 @@ function conky_draw_text()
                                reflection_length=0,
                                DrawMe=conky_parse("${if_mounted /home/user/MyDocs}1$endif")
         },
-        {
+ --[[       {
                    text=conky_parse('${fs_used /media/mmc1} / ${fs_size /media/mmc1} (${fs_free /media/mmc1})'),
                    x=5,
                    y=175,
                    v_align="t",
-                   font_name="Droid Sans Mono",
+                   font_name="Nokia Pure",
                    font_size=16,
                        colour={{conky_parse('${fs_used_perc /media/mmc1}')/100-.1,0x000000,1},{1,0xFFFFFF,1}},
                                orientation="ww",
@@ -270,7 +270,7 @@ function conky_draw_text()
                    x=220,
                    y=174,
                    v_align="t",
-                   font_name="Droid Sans Mono",
+                   font_name="Nokia Pure",
                    font_size=18,
                        colour={{0,0x336633,1},{1,col0,1}},
                        bold=true,
@@ -279,27 +279,28 @@ function conky_draw_text()
                                reflection_length=0,
                                DrawMe=conky_parse("${if_mounted /media/mmc1}1$endif"),
         },
+               ]]
         {
                    text=conky_parse('${wireless_essid wlan0}'),
-                       x=400,
+                       x=375,
                    y=201,
                    h_align="c",
                    v_align="m",
-                   font_name="Droid Sans Mono",
+                   font_name="Nokia Pure",
                    font_size=18,
                        colour={{0,col0,1},{0.5,colbg,1}},
                                orientation="nn",
                reflection_alpha=0,
                reflection_length=0,
-               DrawMe=conky_parse("${if_empty ${wireless_essid wlan0}}${else}1$endif"),
+               DrawMe=conky_parse("${if_up wlan0}1${else}0$endif"),
         },
         {
                    text="GPRS",
-                       x=400,
+                       x=430,
                    y=201,
-                   h_align="c",
+                   h_align="l",
                    v_align="m",
-                   font_name="Droid Sans Mono",
+                   font_name="Nokia Pure",
                    font_size=18,
                        colour={{0,col0,1},{0.5,colbg,1}},
                                orientation="nn",
@@ -311,18 +312,18 @@ function conky_draw_text()
                    text=conky_parse('${wireless_link_qual_perc wlan0}')..'%',
                        x=400,
                    y=228,
-                   h_align="c",
-                   v_align="l",
-                   font_name="Droid Sans Mono",
+                   h_align="l",
+                   v_align="m",
+                   font_name="Nokia Pure",
                    font_size=14,
                        colour={{0,col0,1},{0.5,colbg,1}},
                                orientation="nn",
                reflection_alpha=0,
                reflection_length=0,
-               DrawMe=conky_parse("${if_empty ${wireless_essid wlan0}}${else}1$endif"),
+               DrawMe=conky_parse("${if_up wlan0}1${else}0$endif"),
         },
         {
-                   text='Up '..conky_parse('${upspeed wlan0}'),
+                   text='Up '..conky_parse('${upspeedf wlan0}') + conky_parse('${upspeedf gprs0}'),
                        x=225,
                    y=223,
                    h_align="l",
@@ -334,10 +335,10 @@ function conky_draw_text()
                                orientation="ww",
                reflection_alpha=0,
                reflection_length=0,
-               DrawMe=conky_parse("${if_empty ${wireless_essid wlan0}}${else}1$endif"),
+               DrawMe=conky_parse("${if_up wlan0}1${else}0$endif"),
         },
         {
-                   text=conky_parse('${downspeed wlan0}')..' Down',
+                   text=conky_parse('${downspeedf wlan0}') + conky_parse('${downspeedf gprs0}')..' Down',
                        x=650,
                    y=223,
                    h_align="r",
@@ -349,9 +350,9 @@ function conky_draw_text()
                                orientation="ww",
                reflection_alpha=0,
                reflection_length=0,
-               DrawMe=conky_parse("${if_empty ${wireless_essid wlan0}}${else}1$endif"),
+               DrawMe=conky_parse("${if_up wlan0}1${else}0$endif"),
         },
-        {
+   --[[     {
                    text='Up '..conky_parse('${upspeed gprs0}'),
                        x=225,
                    y=223,
@@ -380,7 +381,7 @@ function conky_draw_text()
                reflection_alpha=0,
                reflection_length=0,
                DrawMe=conky_parse("${if_up gprs0}1${else}0$endif"),
-        },  
+        },]]  
     }
     if conky_window == nil then return end
     if tonumber(conky_parse("$updates"))<3 then return end
index e966a43..b811f0b 100644 (file)
@@ -180,12 +180,12 @@ libdbus_convenience_la_LDFLAGS=@R_DYNAMIC_LDFLAG@
 ## note that TESTS has special meaning (stuff to use in make check)
 ## so if adding tests not to be run in make check, don't add them to 
 ## TESTS
-if DBUS_BUILD_TESTS
-TESTS_ENVIRONMENT=DBUS_TEST_DATA=$(top_builddir)/test/data DBUS_TEST_HOMEDIR=$(top_builddir)/dbus
-TESTS=dbus-test
-else
+## if DBUS_BUILD_TESTS
+## TESTS_ENVIRONMENT=DBUS_TEST_DATA=$(top_builddir)/test/data DBUS_TEST_HOMEDIR=$(top_builddir)/dbus
+## TESTS=dbus-test
+## else
 TESTS=
-endif
+## endif
 
 ## we use noinst_PROGRAMS not check_PROGRAMS so that we build 
 ## even when not doing "make check"
index e394879..7bdaf73 100644 (file)
@@ -1583,11 +1583,11 @@ static char batteries[MAX_BATTERY_COUNT][32];
 //eg 4100
 static int last_battery_volts[MAX_BATTERY_COUNT];
 
-//eg 78
-static unsigned char last_cell_radio_dbm;
+//eg -78
+static dbus_int32_t last_cell_radio_dbm;
 
 //eg 100
-static unsigned char last_cell_radio_percent;
+static dbus_int32_t last_cell_radio_percent;
 
 //eg 'full' 'on' 'off'
 static char last_batt_charge_status[16];
@@ -1653,22 +1653,25 @@ DBusMessage *reply;
 
 void dbus_exit_app_view()
 {
+       //not needed in harmattan - swipe down or away and close (although it doesn't seem to be reliable to swipe)
+       
+       
        //dbus-send --type=signal --session     /com/nokia/hildon_desktop .
 
-       type = DBUS_BUS_SESSION;
-       //message_type = DBUS_MESSAGE_TYPE_SIGNAL;
-       dbus_error_init (&error);
-       connection = dbus_bus_get (type, &error);
-    message = dbus_message_new_signal ("/com/nokia/hildon_desktop", "com.nokia.hildon_desktop", "exit_app_view");
-    // send the message and flush the connection
-    if (!dbus_connection_send(connection, message, NULL)) {
-       fprintf(stderr, "Out Of Memory!\n");
-       exit(1);
-    }
-    dbus_connection_flush(connection);
-
-    // free the message
-    dbus_message_unref(message);
+//     type = DBUS_BUS_SESSION;
+//     //message_type = DBUS_MESSAGE_TYPE_SIGNAL;
+//     dbus_error_init (&error);
+//     connection = dbus_bus_get (type, &error);
+//    message = dbus_message_new_signal ("/com/nokia/hildon_desktop", "com.nokia.hildon_desktop", "exit_app_view");
+//    // send the message and flush the connection
+//    if (!dbus_connection_send(connection, message, NULL)) {
+//       fprintf(stderr, "Out Of Memory!\n");
+//       exit(1);
+//    }
+//    dbus_connection_flush(connection);
+//
+//    // free the message
+//    dbus_message_unref(message);
 
 }
 
@@ -1678,6 +1681,7 @@ void get_dbus_stuff(char *buffer,unsigned int intMax_length, int item)
        char path[128];
        char dest[128];
        char *args = "";
+       char *args2 = "";
        if (dbus_queue > 10)
        {
                fprintf (stderr, "too much dbus queuing\n");
@@ -1705,19 +1709,39 @@ void get_dbus_stuff(char *buffer,unsigned int intMax_length, int item)
       exit (1);
     }
        switch(item){
-       case DBUS_CELL_DBM:
-               snprintf(method,127,"get_signal_strength");
-               snprintf(path,127,"/com/nokia/phone/net");
-               snprintf(dest,127,"com.nokia.phone.net");
-               message = dbus_message_new_method_call (dest,path,"Phone.Net",method);
+       case DBUS_CELL_DBM:             
+               snprintf(method,127,"Get");
+               args = "com.nokia.csd.CSNet.SignalStrength";
+               args2 = "SignalDecibels";
+               snprintf(path,127,"/com/nokia/csd/csnet");
+               snprintf(dest,127,"com.nokia.csd.CSNet"); //service name
+               message = dbus_message_new_method_call (dest,path,"org.freedesktop.DBus.Properties",method);//dest,path,interface,method
                dbus_message_set_auto_start (message, TRUE);
+               if (!dbus_message_append_args(message,
+                       DBUS_TYPE_STRING, &args,
+                       DBUS_TYPE_STRING, &args2,
+                       DBUS_TYPE_INVALID))
+                               fprintf (stderr, "OOM appending args\n");
+               //dbus_message_iter_init_append(message, &iter);
+               //if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &args))
+               //      fprintf (stderr, "OOM appending args\n");
                break;
        case DBUS_CELL_PERCENT:
-               snprintf(method,127,"get_signal_strength");
-               snprintf(path,127,"/com/nokia/phone/net");
-               snprintf(dest,127,"com.nokia.phone.net");
-               message = dbus_message_new_method_call (dest,path,"Phone.Net",method);
+               snprintf(method,127,"Get");
+               args = "com.nokia.csd.CSNet.SignalStrength";
+               args2 = "SignalPercent";
+               snprintf(path,127,"/com/nokia/csd/csnet");
+               snprintf(dest,127,"com.nokia.csd.CSNet"); //service name
+               message = dbus_message_new_method_call (dest,path,"org.freedesktop.DBus.Properties",method);//dest,path,interface,method
                dbus_message_set_auto_start (message, TRUE);
+               if (!dbus_message_append_args(message,
+                       DBUS_TYPE_STRING, &args,
+                       DBUS_TYPE_STRING, &args2,
+                       DBUS_TYPE_INVALID))
+                               fprintf (stderr, "OOM appending args\n");
+               //dbus_message_iter_init_append(message, &iter);
+               //if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &args))
+               //      fprintf (stderr, "OOM appending args\n");
                break;
        case DBUS_HAL_BATTERY_CHRG_STATUS:
                // 'full' 'on' 'off'
@@ -1780,27 +1804,37 @@ void get_dbus_stuff(char *buffer,unsigned int intMax_length, int item)
        if (reply)
        {
                DBusMessageIter iter;
+               DBusMessageIter subiter;
                dbus_message_iter_init (reply, &iter);
-               //int type = dbus_message_iter_get_arg_type(&iter);
                int current_fieldnumber = 0;
                while (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_INVALID)
                {
-                       //fprintf (stderr,"dbus-monitor too dumb to decipher arg type '%c'\n", type);
+                       
                        current_fieldnumber++;
                        switch(item){
                        case DBUS_CELL_DBM:
-                               if (current_fieldnumber == 2)
-                               {
-                                       unsigned char val;
-                                       dbus_message_iter_get_basic(&iter, &val);
+                               if (current_fieldnumber == 1)
+                               {//this is a variant
+                                       if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_VARIANT){
+                                               fprintf (stderr,"DBUS_CELL_DBM got type '%c'; expected variant!\n", dbus_message_iter_get_arg_type(&iter));
+                                               break;
+                                       }
+                                       dbus_message_iter_recurse (&iter, &subiter);                            
+                                       dbus_int32_t val = 0;
+                                       if (dbus_message_iter_get_arg_type(&subiter) != DBUS_TYPE_INT32){
+                                               fprintf (stderr,"DBUS_CELL_DBM subiter got type '%c'; expected INT32!\n", dbus_message_iter_get_arg_type(&subiter));
+                                               break;
+                                       }
+                                       dbus_message_iter_get_basic(&subiter, &val);
                                        last_cell_radio_dbm = val;
                                }
                                break;
                        case DBUS_CELL_PERCENT:
                                if (current_fieldnumber == 1)
-                               {
-                                       unsigned char val;
-                                       dbus_message_iter_get_basic(&iter, &val);
+                               {//this is a variant
+                                       dbus_message_iter_recurse (&iter, &subiter);
+                                       dbus_int32_t val = 0;
+                                       dbus_message_iter_get_basic(&subiter, &val);
                                        last_cell_radio_percent = val;
                                }
                                break;