SEARCH

Enter your search query in the box above ^, or use the forum search tool.

You are not logged in.

#5201 2013-04-29 09:11:18

dura
Bloated Gimp
From: interzone
Registered: 2012-09-15
Posts: 2,106

Re: The New Monster Conky Thread

acpitemp is the conky object relevant to temperature (that I'm most familiar with anyway). How are you using it in your .conkyrc?

Offline

Help fund CrunchBang, donate to the project!

#5202 2013-04-29 13:32:45

TeoBigusGeekus
#! Die Hard
From: /Greece/Kastoria
Registered: 2012-04-28
Posts: 675

Re: The New Monster Conky Thread

Try with this:

${execpi 10 sensors | grep Core | sed 's/ (.*$//g' | sed 's/: *+/: +/g'}

Last edited by TeoBigusGeekus (2013-04-29 13:33:18)


Please make Autocad Civil 3D and Archicad work on Linux!
Please make Autocad Civil 3D and Archicad work on Linux!
Please make Autocad Civil 3D and Archicad work on Linux!
Please make Autocad Civil 3D and Archicad work on Linux!

Offline

#5203 2013-04-29 14:37:38

Sector11
77345 ¡#
From: SR11 Cockpit
Registered: 2010-05-05
Posts: 11,681
Website

Re: The New Monster Conky Thread

Dobbie03 wrote:

EDIT: Disregard, I worked it out, loadgraph is what I wanted big_smile

Interesting I'll have to test that myself. Thanks


#! Forum Moderator | To #! or not to #!?  That is the question!
#! Conky = 16 Threads & the Conky Archives | Conky PitStop | OHCG'er
StartPage -  protect your privacy   |   BBQLinux

Offline

#5204 2013-04-29 17:07:06

PackRat
#! Die Hard
From: USA
Registered: 2011-03-03
Posts: 1,291

Re: The New Monster Conky Thread

Sector11 wrote:
Dobbie03 wrote:

EDIT: Disregard, I worked it out, loadgraph is what I wanted big_smile

Interesting I'll have to test that myself. Thanks

I checked it out too. It was CPU intensive on my Debian Testing system (>10%); doesn't seem to be the case on Dobbie's Ubuntu system - 6-7% based on his screenshot. I'll have to read through the conkyrc I was using to try and spot something else in there.

Last edited by PackRat (2013-04-29 17:22:09)


"It does not require many words to speak the truth." - Chief Joseph, Nez Perce tribe

Offline

#5205 2013-04-29 17:20:38

JWJones
#! Member
From: Cascadia
Registered: 2009-02-23
Posts: 63

Re: The New Monster Conky Thread

Nothing too fancy here:

Screenshot_conky.jpg

# Hack your own Conky, don't leech, LEARN!!
# http://conky.sourceforge.net/
# http://conky.sourceforge.net/config_settings.html
# http://conky.sourceforge.net/variables.html
# http://conky.sourceforge.net/docs.html
#
#
# Reading all the documentation, looking @ other .conkyrc's
# and general knowledge of Linux will help you tweak this
# or create your own.
#
use_xft yes
xftfont DejaVu Sans:size=8
xftalpha 0.8
text_buffer_size 2048

update_interval 1

total_run_times 0

own_window yes
own_window_transparent yes
own_window_hints undecorated,below,sticky,skip_taskbar

double_buffer yes

minimum_size 200 0

draw_shades yes

draw_outline no

draw_borders no

stippled_borders 0

border_margin 5

border_width 1

default_color white
default_shade_color black
default_outline_color black
own_window_colour white

alignment top_right

gap_x 25
gap_y 25

no_buffers yes

uppercase no

cpu_avg_samples 2

net_avg_samples 2

override_utf8_locale yes

use_spacer none

TEXT
${alignc 35}${font DejaVu Sans:size=14}${execi 1 cat /etc/slackware-version}${font}
${alignc 25}${font DejaVu Sans:size=12}For the Subgenius${font}

Changelog: ${execi 1 lynx -dump ftp://slackware.oregonstate.edu/pub/slackware/slackware-14.0/ChangeLog.txt | head -1}

SYSTEM  ${hr 1}

Kernel: ${alignr}${kernel}
Uptime: ${alignr}${uptime}

Core 1:    ${cpu cpu1}% ${alignr}${freq_g cpu1} GHz  /  ${hwmon 0 temp 1} C
Core 2:    ${cpu cpu2}% ${alignr}${freq_g cpu2} GHz  /  ${hwmon 1 temp 1} C

Load Averages: ${alignr}$loadavg

Top 5 Processes                 PID   CPU%  MEM%
${top name 1} ${alignr}${top pid 1}    ${top cpu 1}    ${top mem 1}
${top name 2} ${alignr}${top pid 2}    ${top cpu 2}    ${top mem 2}
${top name 3} ${alignr}${top pid 3}    ${top cpu 3}    ${top mem 3}
${top name 4} ${alignr}${top pid 4}    ${top cpu 4}    ${top mem 4}
${top name 5} ${alignr}${top pid 5}    ${top cpu 5}    ${top mem 5}

GPU Temp: ${alignr}${execi 20 nvidia-settings -q gpucoretemp |grep Attribute |awk '{print $4}' |cut -c1-2} C

RAM:  ${alignr}$mem  /  ${alignr}$memmax
SWAP: ${alignr}$swap  /  ${alignr}$swapmax

MOUNT / HDD's  ${hr 1}

Root:      ${alignr}${fs_used /}  /  ${alignr}${fs_size /}
Available:   ${fs_free_perc /}%

Home:      ${alignr}${fs_used /home}  /  ${alignr}${fs_size /home}
Available:   ${fs_free_perc /home}%

NETWORK  ${hr 1}

Up:     ${alignr}${upspeed eth0}KB/s
Total:  ${alignr}${totalup eth0}

Down:   ${alignr}${downspeed eth0}KB/s
Total:  ${alignr}${totaldown eth0}
${hr 1}

${font DejaVu Sans:size=12}${time %H:%M:%S}${alignr}${time %A, %D}${font}

LinuxBBQ • Slackware • antiX
Thinkpad T61 – Intel Core2 Duo T7300 @ 2.00 GHz

Offline

#5206 2013-04-29 17:21:06

PackRat
#! Die Hard
From: USA
Registered: 2011-03-03
Posts: 1,291

Re: The New Monster Conky Thread

@jbolted -

In addition to this:

TeoBigusGeekus wrote:

Try with this:

${execpi 10 sensors | grep Core | sed 's/ (.*$//g' | sed 's/: *+/: +/g'}

scroll down and read through Method 1 for more ways to use grep, awk, sed with sensors in conky.


"It does not require many words to speak the truth." - Chief Joseph, Nez Perce tribe

Offline

#5207 2013-04-29 17:50:55

Sector11
77345 ¡#
From: SR11 Cockpit
Registered: 2010-05-05
Posts: 11,681
Website

Re: The New Monster Conky Thread

PackRat wrote:
Sector11 wrote:
Dobbie03 wrote:

EDIT: Disregard, I worked it out, loadgraph is what I wanted big_smile

Interesting I'll have to test that myself. Thanks

I checked it out too. It was CPU intensive on my Debian Testing system (>10%); doesn't seem to be the case on Dobbie's Ubuntu system - 6-7% based on his screenshot. I'll have to read through the conkyrc I was using to try and spot something else in there.


I checked it out this morning, I don't really see any difference at all.  I had to stress my system a bit to see some results (you can see them here).  And now I have a nice little "loadgraph" under my "load average".

EDIT:  Dobbie screenshot?   Where?

Last edited by Sector11 (2013-04-29 17:55:05)


#! Forum Moderator | To #! or not to #!?  That is the question!
#! Conky = 16 Threads & the Conky Archives | Conky PitStop | OHCG'er
StartPage -  protect your privacy   |   BBQLinux

Offline

#5208 2013-04-29 22:45:41

ichase
#! CrunchBanger
Registered: 2011-03-16
Posts: 137

Re: The New Monster Conky Thread

Been playing today.  Removed my processors from my info conky and modified one of wlourf's ring scripts from 2010 to add them outside the info conky.  Also utilized S11's modification to Mr Peachy's analog clock script for the analog clock above mobilediesel's date script.  Starting to get the hang of how these lua scripts work.  big_smile
8e7b21251692163.jpg

conky_cpu:

own_window yes
own_window_type desktop
own_window_transparent yes
own_window_hints undecorated,below,skip_taskbar,skip_pager
#own_window_colour white
own_window_class Conky
own_window_title Chronograph TEST
double_buffer yes

### ARGB can be used for real transparency
### NOTE that a composite manager is required for real transparency.
### This option will not work as desired (in most cases) in conjunction with
### own_window_type normal
#own_window_argb_visual yes

### When ARGB visuals are enabled, this use this to modify the alpha value
### Use: own_window_type normal
### Use: own_window_transparent no
### Valid range is 0-255, where 0 is 0% opacity, and 255 is 100% opacity.
#own_window_argb_value 5


minimum_size 275 650 ## width, height
maximum_width 275    ## width

gap_x 320
gap_y -25

### alignment values or top_left, bottom_right, etc
# tl, tm, tr
# ml, mm, mr
# bl, bm, br
#alignment tl
alignment top_right
use_xft yes
xftfont monofur:bold:size=14

xftalpha 1
# Force UTF8? requires XFT ###
override_utf8_locale yes

uppercase no
draw_shades no
default_shade_color black
draw_outline no # amplifies text if yes
default_outline_color black
default_color 86b5ea
color1 red
draw_borders no
# Stippled borders?
stippled_borders 0
# border margins
border_inner_margin 5
border_outer_margin 0
# border width
border_width 0
# graph borders
draw_graph_borders yes #no
#default_graph_size 15 40
background yes
use_spacer none
text_buffer_size 256
no_buffers yes
short_units yes
pad_percents 2
format_human_readable yes
short_units yes
imlib_cache_size 0
temperature_unit Fahrenheit
update_interval 1

###  Load Lua  ###########################################################

lua_load /home/ichase02/Scripts/rings_3.lua
lua_draw_hook_pre main_rings

##############################  End LUA Settings  ###

TEXT
#${lua conky_draw_bg 132 3 3 264 264 0x000000 0.5}
#${lua conky_draw_bg 98 37 37 196 196 0xFFFFFF 0.2}
#${lua conky_draw_bg 68 67 67 136 136 0x000000 0.4}
#${lua conky_draw_bg 35 100 100 70 70 0x000000 0.3}



${goto 148}${font monofur:bold:size=10}${color}AVG     
${voffset -5}${goto 132}${font monofur:size=8}${goto 190}${color1}${cpu cpu0}%







${goto 148}${font monofur:bold:size=10}${color}CPU1 
${voffset -5}${goto 132}${font monofur:size=8}${goto 190}${color1}${cpu cpu1}% 







${goto 148}${font monofur:bold:size=10}${color}CPU2
${voffset -5}${goto 132}${font monofur:size=8}${goto 190}${color1}${cpu cpu2}%







${goto 148}${font monofur:bold:size=10}${color}CPU3
${voffset -5}${goto 132}${font monofur:size=8}${goto 190}${color1}${cpu cpu3}%







${goto 148}${font monofur:bold:size=10}${color}CPU4
${voffset -5}${goto 132}${font monofur:size=8}${goto 190}${color1}${cpu cpu4}%

rings.lua:

--[[ RINGS with SECTORS widget
	v1.0 by wlourf (08.08.2010)
	this widget draws a ring with differents effects 
	http://u-scripts.blogspot.com/2010/08/rings-sectors-widgets.html
	
To call the script in a conky, use, before TEXT
	lua_load /path/to/the/script/rings.lua
	lua_draw_hook_pre main_rings
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 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:
xc,yc		- coordinates of the center of the ring,
			  default = middle of the conky window
radius		- external radius of the ring, in pixels,
			  default = quarter of the width of the conky window
thickness	- thickness of the ring, in pixels, default = 10 pixels
start_angle	- starting angle of the ring, in degrees, value can be negative,
			  default = 0 degree
end_angle	- ending angle of the ring, in degrees,
			  value must be greater than start_angle, default = 360 degrees
sectors		- number of sectors in the ring, default = 10
gap_sectors - gap between two sectors, in pixels, default = 1 pixel
cap			- the way to close a sector, available values are
				"p" for parallel , default value 
				"r" for radial (follow the radius)
inverse_arc	- if set to true, arc will be anticlockwise, default=false
border_size	- size of the border, in pixels, default = 0 pixel i.e. no border
fill_sector	- if set to true, each sector will be completely filled,
			  default=false, this parameter is inoperate if sectors=1
background	- if set to false, background will not be drawn, default=true
foreground	- if set to false, foreground will not be drawn, default=true

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_colour1	- colour table for background,
			  default = {{0,0x86b5ea,0.1},{0.5,0x86e5ea,0.5},{1,0x86b5ea,0.1}}
fg_colour1	- colour table for foreground,
			  default = {{0,0xFF0000,0.1},{0.5,0xFF0000,1},{1,0xFF0000,0.1}}
bd_colour1	- colour table for border,
			  default = {{0,0xFF0000,0.5},{0.5,0xFF0000,1},{1,0xFF0000,0.5}}			  

Seconds tables for radials gradients :
bg_colour2	- second colour table for background, default = no second colour
fg_colour2	- second colour table for foreground, default = no second colour
bd_colour2	- second colour table for border, default = no second colour

v1.0 (08 Aug. 2010) original release

]]


require 'cairo'
function conky_main_rings()
-- START PARAMETERS HERE
rings_settings={
		{
	name="cpu",
	arg="cpu0",
	max=100,
	xc=175,
	yc=95,
	start_angle=180,
	end_angle=-180,
	thickness=10,
	radius=55,
	sectors=130,
	gap_sectors=1,
	bg_colour1={{0.5,0x86b5ea,.15}},
	fg_colour1={{0.5,0x3ADF00,1}},
	fg_colour2={{0.5,0xFF0000,1}},
	},
			{
	name="cpu",
	arg="cpu1",
	max=100,
	xc=175,
	yc=210,
	start_angle=180,
	end_angle=-180,
	thickness=10,
	radius=55,
	sectors=130,
	gap_sectors=1,
	bg_colour1={{0.5,0x86b5ea,.15}},
	fg_colour1={{0.5,0x3ADF00,1}},
	fg_colour2={{0.5,0xFF0000,1}},
	},
			{
	name="cpu",
	arg="cpu2",
	max=100,
	xc=175,
	yc=325,
	start_angle=180,
	end_angle=-180,
	thickness=10,
	radius=55,
	sectors=130,
	gap_sectors=1,
	bg_colour1={{0.5,0x86b5ea,.15}},
	fg_colour1={{0.5,0x3ADF00,1}},
	fg_colour2={{0.5,0xFF0000,1}},
	},
			{
	name="cpu",
	arg="cpu3",
	max=100,
	xc=175,
	yc=440,
	start_angle=180,
	end_angle=-180,
	thickness=10,
	radius=55,
	sectors=130,
	gap_sectors=1,
	bg_colour1={{0.5,0x86b5ea,.15}},
	fg_colour1={{0.5,0x3ADF00,1}},
	fg_colour2={{0.5,0xFF0000,1}},
	},
			{
        name="cpu",
        arg="cpu4",
        max=100,
        xc=175,
        yc=555,
        start_angle=180,
        end_angle=-180,
        thickness=10,
        radius=55,
        sectors=130,
        gap_sectors=1,
        bg_colour1={{0.5,0x86b5ea,.15}},
        fg_colour1={{0.5,0x3ADF00,1}},
        fg_colour2={{0.5,0xFF0000,1}},
        },

}
--END OF PARAMETERS HERE

--main function

	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)

	if tonumber(conky_parse('${updates}'))>3 then
		for i in pairs(rings_settings) do
			draw_ring(rings_settings[i])
		end
	end

	cairo_destroy(cr)

end




function draw_ring(t)

	local function rgba_to_r_g_b_a(tcolour)
		colour,alpha=tcolour[2],tcolour[3]
		return ((colour / 0x10000) % 0x100) / 255., 
			((colour / 0x100) % 0x100) / 255., (colour % 0x100) / 255., alpha
	end
			
			
	local function calc_delta(tcol1,tcol2)
		--calculate deltas P R G B A to table_colour 1

		for x = 1, #tcol1 do
			tcol1[x].dA	= 0
			tcol1[x].dP = 0
	 		tcol1[x].dR = 0
			tcol1[x].dG = 0
			tcol1[x].dB = 0
			if tcol2~=nil and #tcol1 == #tcol2 then
				local r1,g1,b1,a1 = rgba_to_r_g_b_a(tcol1[x])
				local r2,g2,b2,a2 = rgba_to_r_g_b_a(tcol2[x])
				tcol1[x].dP = (tcol2[x][1]-tcol1[x][1])/t.sectors
		 		tcol1[x].dR = (r2-r1)/t.sectors
				tcol1[x].dG = (g2-g1)/t.sectors
				tcol1[x].dB = (b2-b1)/t.sectors
				tcol1[x].dA = (a2-a1)/t.sectors		
				
			end
		end
		
		return tcol1
	end

	--check values
	local function setup(t)
		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'")
			print ("for name=" .. t.name)
			print ("with arg=" .. t.arg)
			return
		end
		if t.name==nil then t.name="" end
		if t.arg==nil then t.arg="" 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.thickness ==nil then t.thickness = 10 end
		if t.radius ==nil then t.radius =conky_window.width/4 end
		if t.start_angle==nil then t.start_angle =0 end
		if t.end_angle==nil then t.end_angle=360 end
		if t.bg_colour1==nil then 
			t.bg_colour1={{0,0x00ffff,0.1},{0.5,0x00FFFF,0.5},{1,0x00FFFF,0.1}}
		end
		if t.fg_colour1==nil then
			t.fg_colour1={{0,0x00FF00,0.1},{0.5,0x00FF00,1},{1,0x00FF00,0.1}}
		end
		if t.bd_colour1==nil then
			t.bd_colour1={{0,0xFFFF00,0.5},{0.5,0xFFFF00,1},{1,0xFFFF00,0.5}}
		end
		if t.sectors==nil then t.sectors=10 end
		if t.gap_sectors==nil then t.gap_sectors=1 end 
		if t.fill_sector==nil then t.fill_sector=false end
		if t.sectors==1 then t.fill_sector=false end
		if t.border_size==nil then t.border_size=0 end
		if t.cap==nil then t.cap="p" end
		--some checks
		if t.thickness>t.radius then t.thickness=t.radius*0.1 end
		t.int_radius = t.radius-t.thickness

		--check colors tables 
		for i=1, #t.bg_colour1 do 
			if #t.bg_colour1[i]~=3 then t.bg_colour1[i]={1,0xFFFFFF,0.5} end
		end
		for i=1, #t.fg_colour1 do 
			if #t.fg_colour1[i]~=3 then t.fg_colour1[i]={1,0xFF0000,1} end
		end
		for i=1, #t.bd_colour1 do 
			if #t.bd_colour1[i]~=3 then t.bd_colour1[i]={1,0xFFFF00,1} end
		end
	
		if t.bg_colour2~=nil then
			for i=1, #t.bg_colour2 do 
				if #t.bg_colour2[i]~=3 then t.bg_colour2[i]={1,0xFFFFFF,0.5} end
			end
		end
		if t.fg_colour2~=nil then
			for i=1, #t.fg_colour2 do 
				if #t.fg_colour2[i]~=3 then t.fg_colour2[i]={1,0xFF0000,1} end
			end
		end
		if t.bd_colour2~=nil then
			for i=1, #t.bd_colour2 do 
				if #t.bd_colour2[i]~=3 then t.bd_colour2[i]={1,0xFFFF00,1} end
			end
		end 	
		
		if t.start_angle>=t.end_angle then
		 local tmp_angle=t.end_angle
		 t.end_angle= t.start_angle
		 t.start_angle = tmp_angle
		 -- print ("inversed angles")
			if t.end_angle-t.start_angle>360 and t.start_angle>0 then
				t.end_angle=360+t.start_angle
				print ("reduce angles")
			end
		
			if t.end_angle+t.start_angle>360 and t.start_angle<=0 then
				t.end_angle=360+t.start_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 radius")
			end
			if t.int_radius==t.radius then
				t.int_radius=0
				print ("int radius set to 0")
			end 
		end
		
		t.fg_colour1 = calc_delta(t.fg_colour1,t.fg_colour2)
		t.bg_colour1 = calc_delta(t.bg_colour1,t.bg_colour2)
		t.bd_colour1 = calc_delta(t.bd_colour1,t.bd_colour2)
	end
	
	--initialize table
	setup(t)
	--[[grid
	h=conky_window.height
	w=conky_window.width
	cairo_set_source_rgba(cr,1,1,1,1)
	cairo_set_line_width(cr,0.5)
	cairo_move_to(cr,0,t.yc)
	cairo_line_to(cr,w,t.yc)
	cairo_stroke(cr)
	cairo_move_to(cr,t.xc,0)
	cairo_line_to(cr,t.xc,h)
	cairo_stroke(cr)
	cairo_move_to(cr,t.xc,t.yc)
	cairo_line_to(cr,t.xc+200*math.sin(math.pi/4),t.yc-200*math.cos(math.pi/4))
	cairo_stroke(cr)
	cairo_move_to(cr,0,t.yc-t.radius)
	cairo_line_to(cr,w,t.yc-t.radius)
	cairo_stroke(cr)
	cairo_move_to(cr,0,t.yc-t.int_radius)
	cairo_line_to(cr,w,t.yc-t.int_radius)
	cairo_stroke(cr)
	cairo_move_to(cr,0,t.yc-t.gap_sectors)
	cairo_line_to(cr,w,t.yc-t.gap_sectors)
	cairo_stroke(cr)
	cairo_set_source_rgba(cr,1,0,0,0.5)
	cairo_arc(cr,t.xc,t.yc,t.radius,0,2*math.pi)
	cairo_stroke(cr)
	cairo_arc(cr,t.xc,t.yc,t.int_radius,0,2*math.pi)	
	cairo_stroke(cr)	
	cairo_set_source_rgba(cr,0,1,0,1)	
	cairo_move_to(cr,t.xc+t.gap_sectors,t.yc-t.gap_sectors)
	cairo_line_to(cr,t.xc+400*math.sin(math.pi/4),t.yc-400*math.cos(math.pi/4))
	cairo_stroke(cr)
	--END GRID
	]]
	
	--initialize cairo context
	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)

	--get value
	local value = 0
	if t.name ~="" then
		value = tonumber(conky_parse(string.format('${%s %s}', t.name, t.arg)))
	else
		value = tonumber(t.arg)
	end
	if value==nil then value =0 end

	--initialize sectors
	--angle of a sector :
	angleA = ((t.end_angle-t.start_angle)/t.sectors)*math.pi/180
	--value of a sector : 
	valueA = t.max/t.sectors
	--first angle of a sector : 
	lastAngle = t.start_angle*math.pi/180


	local function draw_sector(type_arc,angle0,angle,valpc, idx)
	 
		--this function draws a portion of arc
	 	--type of arc, angle0 = strating angle, angle= angle of sector,
	 	--valpc = percentage inside the sector, idx = sctor number #
		 if type_arc=="bg" then 		--background
			 if valpc==1 then return end
		 	tcolor=t.bg_colour1
		 elseif type_arc=="fg" then	--foreground
		 	if valpc==0 then return end
		 	tcolor=t.fg_colour1
		 elseif type_arc=="bd" then	--border
		 	tcolor=t.bd_colour1
		 end 

		--angles equivalents to gap_sector
		local ext_delta=math.atan(t.gap_sectors/(2*t.radius))
		local int_delta=math.atan(t.gap_sectors/(2*t.int_radius))

		--angles of arcs
		local ext_angle=(angle-ext_delta*2)*valpc
		local int_angle=(angle-int_delta*2)*valpc

		--define colours to use for this sector
		if #tcolor==1 then 
			--plain color
			local vR,vG,vB,vA = rgba_to_r_g_b_a(tcolor[1])
			cairo_set_source_rgba(cr,vR+tcolor[1].dR*idx,
									vG+tcolor[1].dG*idx,
									vB+tcolor[1].dB*idx,
									vA+tcolor[1].dA*idx	)
		else
			--radient color
			local pat=cairo_pattern_create_radial(0,0,t.int_radius,0,0,t.radius)
			for i=1, #tcolor do
				local vP,vR,vG,vB,vA = tcolor[i][1], rgba_to_r_g_b_a(tcolor[i])
				cairo_pattern_add_color_stop_rgba (pat, 
									vP+tcolor[i].dP*idx,
									vR+tcolor[i].dR*idx,
									vG+tcolor[i].dG*idx,
									vB+tcolor[i].dB*idx,
									vA+tcolor[i].dA*idx	)
			end
			cairo_set_source (cr, pat)
			cairo_pattern_destroy(pat)
		end

		--start drawing
		 cairo_save(cr)
		--x axis is parrallel to start of sector
		cairo_rotate(cr,angle0-math.pi/2)

		local ri,re = t.int_radius ,t.radius

		--point A 
		local angle_a
	
		if t.cap == "p" then 
			angle_a = int_delta
			if t.inverse_arc and type_arc ~="bg" then
				angle_a = angle-int_angle-int_delta
			end
			if not(t.inverse_arc) and type_arc =="bg" then
				angle_a = int_delta+int_angle
			end
		else --t.cap=="r"
			angle_a = ext_delta
			if t.inverse_arc and type_arc~="bg" then
				angle_a = angle-ext_angle-ext_delta
			end
			if not(t.inverse_arc) and type_arc=="bg" then
				angle_a = ext_delta+ext_angle
			end
		end
		local ax,ay = ri*math.cos(angle_a),ri*math.sin(angle_a)


		--point B
		local angle_b = ext_delta
		if t.cap == "p" then 
			if t.inverse_arc and type_arc ~="bg" then
				angle_b = angle-ext_angle-ext_delta
			end
			if not(t.inverse_arc) and type_arc=="bg" then
				angle_b = ext_delta+ext_angle
			end
		else
			if t.inverse_arc and type_arc ~="bg" then
				angle_b = angle-ext_angle-ext_delta
			end
			if not(t.inverse_arc) and type_arc=="bg" then
				angle_b = ext_delta+ext_angle
			end
		end
		local bx,by = re*math.cos(angle_b),re*math.sin(angle_b)

		-- EXTERNAL ARC B --> C
		if t.inverse_arc then
			if type_arc=="bg" then
				b0,b1= ext_delta, angle-ext_delta-ext_angle
			else
				b0,b1= angle-ext_angle-ext_delta, angle-ext_delta
			end
		else
			if type_arc=="bg" then
				b0,b1= ext_delta+ext_angle, angle-ext_delta
			else
				b0,b1= ext_delta, ext_angle+ext_delta
			end
		end
		
		---POINT D
		local angle_c 
		if t.cap == "p" then 
			angle_d = angle-int_delta
			if t.inverse_arc and type_arc=="bg" then
				angle_d = angle-int_delta-int_angle	
			end
			if not(t.inverse_arc) and type_arc~="bg" then
				angle_d=int_delta+int_angle
			end
		else
			angle_d = angle-ext_delta
			if t.inverse_arc and type_arc=="bg" then
				angle_d =angle-ext_delta-ext_angle
			end
			if not(t.inverse_arc) and type_arc~="bg" then
				angle_d = ext_angle+ext_delta
			end
		end
		local dx,dy = ri*math.cos(angle_d),ri*math.sin(angle_d)
		
		-- INTERNAL ARC D --> A
		if t.cap=="p" then	
			if t.inverse_arc then	
				if type_arc=="bg" then
					d0,d1= angle-int_delta-int_angle,int_delta
				else
					d0,d1= angle-int_delta, angle- int_angle-int_delta
				end
			else
				if type_arc=="bg" then
					d0,d1= angle-int_delta, int_delta+int_angle
				else
					d0,d1= int_delta+int_angle, int_delta
				end
			end
		else
			if t.inverse_arc then	
				if type_arc=="bg" then	
					d0,d1= angle-ext_delta-ext_angle,ext_delta
				else
					d0,d1= angle-ext_delta, angle- ext_angle-ext_delta
				end
			else
				if type_arc=="bg" then	
					d0,d1= angle-ext_delta,ext_delta+ext_angle
				else	
					d0,d1= ext_angle+ext_delta, ext_delta
				end
			end			
		end
			
		--draw sector
		cairo_move_to(cr,ax,ay)
		cairo_line_to(cr,bx,by)
		cairo_arc(cr,0,0,re,b0,b1)
		cairo_line_to(cr,dx,dy) 
		cairo_arc_negative(cr,0,0,ri,d0,d1)
		 cairo_close_path (cr);

		--stroke or fill sector
		 if type_arc=="bd" then
		 	cairo_set_line_width(cr,t.border_size)
		 	cairo_stroke(cr)
		 else
			 cairo_fill(cr)
		 end

		 cairo_restore(cr)

	 end
	--draw sectors
	local n0,n1,n2 = 1,t.sectors,1
	if t.inverse_arc then n0,n1,n2 = t.sectors,1,-1 end
	local index = 0
	for i = n0,n1,n2 do 
		index = index +1
		local valueZ=1
		local cstA, cstB = (i-1),i
		if t.inverse_arc then cstA,cstB = (t.sectors-i), (t.sectors-i+1) end
		
		if value>valueA *cstA and value<valueA*cstB then
			if not t.fill_sector then
				valueZ = (value-valueA*cstA)/valueA
			end
		else
			if value<valueA*cstB then valueZ=0 end
		end
		
		local start_angle= lastAngle+(i-1)*angleA
		if t.foreground ~= false then 
			draw_sector("fg",start_angle,angleA,valueZ, index)
		end
		if t.background ~= false then 
			draw_sector("bg",start_angle,angleA,valueZ, i)
		end
		if t.border_size>0 then draw_sector("bd",start_angle,angleA,1, i) end
	end

	cairo_restore(cr)
end


--[[END OF RING-SECTORS WIDGET]]


function axis(ctx,alpha)
	cairo_set_line_width(ctx,1)
	cairo_set_source_rgba(ctx,1,0,0,alpha)
	cairo_move_to(ctx,0,0)
	cairo_line_to(ctx,150,0)
	cairo_stroke(ctx)
	cairo_set_source_rgba(ctx,0,1,0,alpha)
	cairo_move_to(ctx,0,0)
	cairo_line_to(ctx,0,150)
	cairo_stroke(ctx)
end	

In case any one is interesting in Mr Peachy's and Sector 11's analog clock and don't want to go looking for it:
The conky running it:

# To use #! in a conky use: ${exec echo '#!'}
# killall conky && conky -c ~/Conky/S11_24_white.conky &

background yes
update_interval 1


###  Begin Window Settings  ##################################################
own_window yes
own_window_type desktop
own_window_transparent yes
own_window_colour 1E90FF
own_window_hints sticky,undecorated,below,skip_taskbar,skip_pager
#own_window_colour yellow
own_window_class 24HRClock
own_window_title 24HRClock

# Use the Xdbe extension? (eliminates flicker)
# It is highly recommended to use own window with this one
# so double buffer won't be so big.
double_buffer yes

### ARGB can be used for real transparency
### NOTE that a composite manager is required for real transparency.
### This option will not work as desired (in most cases) in conjunction with
### own_window_type override
#========================================
#own_window_argb_visual yes

### When ARGB visuals are enabled, this use this to modify the alpha value
### Valid range is 0-255, where 0 is 0% opacity, and 255 is 100% opacity.
#own_window_argb_value 128
#=========================================

minimum_size 128 128     ## width, height
maximum_width 128       ## width, usually a good idea to equal minimum width

alignment br
gap_x 100 # left-right
gap_y 80 # up-down

###################################################  End Window Settings  ###
###  Font Settings  #########################################################
# Use Xft (anti-aliased font and stuff)
use_xft yes
#xftfont Anonymous Pro:size=8
#xftfont WenQuanYi Macro Hei Mono:bold:size=8
xftfont WenQuanYi Zen Hei Mono:bold:size=8

# Alpha of Xft font. Must be a value at or between 1 and 0 ###
xftalpha 0
# Force UTF8? requires XFT ###
override_utf8_locale yes

uppercase no
######################################################  End Font Settings  ###
###  Color Settings  #########################################################
draw_shades yes
default_shade_color black

draw_outline no # amplifies text if yes
default_outline_color black

#default_color DCDCDC #Gainsboro
default_color FF8C00
color0 9ACD32 #YellowGreen
color1 778899 #LightSlateGrey
color2 FF8C00 #Darkorange
color3 7FFF00 #Chartreuse
color4 FFA07A #LightSalmon
color5 FFDEAD #NavajoWhite
color6 00BFFF #DeepSkyBlue
color7 00FFFF #Cyan 48D1CC #MediumTurquoise
color8 FFFF00 #Yellow
color9 FF0000 #Red
#####################################################  End Color Settings  ###
###  Borders Section  ########################################################
draw_borders no
# Stippled borders?
stippled_borders 0
# border margins
border_inner_margin 0
border_outer_margin 0
# border width
border_width 0
# graph borders
draw_graph_borders no #yes
default_graph_size 15 40
#####################################################  End Borders Secton  ###
###  Miscellaneous Section  ##################################################

# Boolean value, if true, Conky will be forked to background when started.
background yes

# Adds spaces around certain objects to stop them from moving other things
# around, this only helps if you are using a mono font
# Options: right, left or none
use_spacer none

# Default and Minimum size is 256 - needs more for single commands that
# "call" a lot of text IE: bash scripts
text_buffer_size 512

# Subtract (file system) buffers from used memory?
no_buffers yes

# change GiB to G and MiB to M
short_units yes

# Like it says, ot pads the decimals on % values
# doesn't seem to work since v1.7.1
pad_percents 2

default_bar_size 120 20 # reverse to commandline and no comma:  ${cpubar 20,102}

cpu_avg_samples 1
net_avg_samples 1

imlib_cache_size 0

##############################################  End Miscellaneous Section  ###
###  LUA Settings  ###########################################################
## Above and After TEXT - requires a composite manager or blinks.
##
# lua_load ~/Conky/LUA/draw-bg.lua
#TEXT
# ${lua conky_draw_bg 10 0 0 0 0 0x000000 0.6}
#
## ${lua conky_draw_bg corner_radius x_position y_position width height color alpha}
##
## OR Both above TEXT (No composite manager required - no blinking!)
#
# lua_load ~/Conky/LUA/draw-bg.lua
# lua_draw_hook_pre draw_bg 125 0 0 0 0 0x000000 0.4
#

############## 12-24 Hour Clock #######################
lua_load /home/ichase02/Scripts/luaclock2412.lua
lua_draw_hook_pre main

lua_load /home/ichase02/Scripts/transbg.lua
lua_draw_hook_post draw_bg 32 0 0 0 0 0x140C0B 0.16
#######################################################  End LUA Settings  ###

# The all important - How often conky refreshes.
# If you have a "Crey" try: 0.2 - smokin' - but watch the CPU useage go UP!


TEXT

And the lau script: Takes 2 scripts I believe S11 correct me if I am wrong.  1st is lauclock2412.lau 2nd is transbg.lua

--[[drawing a clock in conkyrc
by mrpeachy - 12 March 2010
Edited by Sector11 for personal use - 12 Mar 2012

lua_load /path/clock.lua
lua_draw_hook_pre main
TEXT
]]

require 'cairo'

function conky_main()
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)
--##############################################################################
--   SETTINGS AREA
--##############################################################################
-- image
-- how do I add images.
-- local cpu=conky_parse("${cpu}")
-- local red-1=conky_parse("${image ~/Conky/images/red_1.png -p 0,0 -s 35x35}")


--12 OR 24
-- local clock_type=24
local clock_type=12

--CLOCK SETTINGS
local clock_radius=64
local clock_centerx=64
local clock_centery=64

-- SET MARKS
--how many marks around edge
local number_marks=12 --24
--set mark length
local m_length=5
--set mark line width
local m_width=1
--set mark line cap type
local m_cap=CAIRO_LINE_CAP_ROUND
--set mark color and alpha,red blue green alpha
local mr,mg,mb,ma=1,1,1,1  --opaque white

--SET BORDER OPTIONS
local clock_border_width=0 --2
--set color and alpha for clock border
local cbr,cbg,cbb,cba=1,1,1,1  --full opaque white
--gap from clock border to hour marks
local b_to_m=5

--SECONDS HAND SETUP
--set length of seconds hand
local sh_length=12
--set hand width
local sh_width=1
--set hand line cap
local sh_cap=CAIRO_LINE_CAP_ROUND
--set seconds hand color
local shr,shg,shb,sha=0,1,1,0  --fully opaque cyan

--MINUTE HAND SETUP
--set length of minutes hand
local mh_length=56
--set hand width
local mh_width=1
--set hand line cap
local mh_cap=CAIRO_LINE_CAP_ROUND
--set minute hand color
local mhr,mhg,mhb,mha=1,1,1,1  --fully opaque white

--HOUR HAND SETUP
--set length of hour hand
local hh_length=40
--set hand width
local hh_width=2
--set hand line cap
local hh_cap=CAIRO_LINE_CAP_ROUND
--set hour hand color
local hhr,hhg,hhb,hha=1,1,1,1  --fully opaque white
--##############################################################################
--   END SETTINGS AREA
--##############################################################################

--DRAWING CODE
--draw border
cairo_set_source_rgba (cr,cbr,cbg,cbb,cba)
cairo_set_line_width (cr,clock_border_width)
cairo_arc (cr,clock_centerx,clock_centery,clock_radius,0,2*math.pi)
cairo_stroke (cr)

--DRAW MARKS
--stuff that can be moved outside of the loop, needs only be set once
--calculate end and start radius for marks
m_end_rad=clock_radius-b_to_m
m_start_rad=m_end_rad-m_length
--set line cap type
cairo_set_line_cap  (cr, m_cap)
--set line width
cairo_set_line_width (cr,m_width)
--set color and alpha for marks
cairo_set_source_rgba (cr,mr,mg,mb,ma)
--start for loop
for i=1,number_marks do
--drawing code using the value of i to calculate degrees
--calculate start point for 12 oclock mark
radius=m_start_rad
point=(math.pi/180)*((i-1)*(360/number_marks))
x=0+radius*(math.sin(point))
y=0-radius*(math.cos(point))
--set start point for line
cairo_move_to (cr,clock_centerx+x,clock_centery+y)
--calculate end point for 12 oclock mark
radius=m_end_rad
point=(math.pi/180)*((i-1)*(360/number_marks))
x=0+radius*(math.sin(point))
y=0-radius*(math.cos(point))
--set path for line
cairo_line_to (cr,clock_centerx+x,clock_centery+y)
--draw the line
cairo_stroke (cr)
end--of for loop

--TIME CALCULATIONS ###########################
if clock_type==12 then
hours=tonumber(os.date("%I")) --12 hour clock
--convert hours to seconds
h_to_s=hours*60*60
elseif clock_type==24 then
hours=tonumber(os.date("%H")) --24 hour clock
--convert hours to seconds
h_to_s=hours*60*60
end

minutes=tonumber(os.date("%M"))
--convert minutes to seconds
m_to_s=minutes*60
--get current seconds
seconds=tonumber(os.date("%S"))

--DRAW HOUR HAND ############################
--convert hours, minutes & seconds to seconds
hsecs=h_to_s+m_to_s+seconds
--calculate number of degrees for each hand per second
hsec_degs=hsecs*(360/(60*60*clock_type)) -- USING AN EQUATION INSTEAD OF TYPING THE CALCULATION IN BECAUSE THE RESULT OF 360/43200 HAS DECIMAL PLACES
--set radius we will use to calculate hand points
radius=hh_length
--set our starting line coordinates, the center of the circle
cairo_move_to (cr,clock_centerx,clock_centery)
--calculate coordinates for end of minutes hand
point=(math.pi/180)*hsec_degs
x=0+radius*(math.sin(point))
y=0-radius*(math.cos(point))
--describe the line we will draw
cairo_line_to (cr,clock_centerx+x,clock_centery+y)
--set up line attributes and draw line
cairo_set_line_width (cr,hh_width)
cairo_set_source_rgba (cr,hhr,hhg,hhb,hha)
cairo_set_line_cap  (cr, hh_cap)
cairo_stroke (cr)

--DRAW MINUTES HAND ############################
--convert minutes & seconds to seconds
msecs=m_to_s+seconds
--calculate degrees for the hand each second
msec_degs=msecs*0.1
--set radius we will use to calculate hand points
radius=mh_length
--set our starting line coordinates, the center of the circle
cairo_move_to (cr,clock_centerx,clock_centery)
--calculate coordinates for end of minutes hand
point=(math.pi/180)*msec_degs
x=0+radius*(math.sin(point))
y=0-radius*(math.cos(point))
--describe the line we will draw
cairo_line_to (cr,clock_centerx+x,clock_centery+y)
--set up line attributes and draw line
cairo_set_line_width (cr,mh_width)
cairo_set_source_rgba (cr,mhr,mhg,mhb,mha)
cairo_set_line_cap  (cr, mh_cap)
cairo_stroke (cr)

--DRAW SECOND HAND #############################
--calculate degrees for each second the hand moves
sec_degs=seconds*6
--set radius we will use to calculate hand points
radius=sh_length
--set our starting line coordinates, the center of the circle
cairo_move_to (cr,clock_centerx,clock_centery)
--calculate coordinates for end of second hand
point=(math.pi/180)*sec_degs
x=0+radius*(math.sin(point))
y=0-radius*(math.cos(point))
--describe the line we will draw
cairo_line_to (cr,clock_centerx+x,clock_centery+y)
--set up line attributes and draw line
cairo_set_line_width (cr,sh_width)
cairo_set_source_rgba (cr,shr,shg,shb,sha)
cairo_set_line_cap  (cr, sh_cap)
cairo_stroke (cr)

--##############################################################################
cairo_destroy(cr)
cairo_surface_destroy(cs)
cr=nil
end-- end main function

And transbg.lua:

--[[Background originally by londonali1010 (2009)
    ability to set any size for background mrpeachy 2011
    ability to set variables for bg in conkyrc dk75

the change is that if you set width and/or height to 0
then it assumes the width and/or height of the conky window

so:

Above and After TEXT  (requires a composite manager or it blinks!)

 lua_load ~/wea_conky/draw_bg.lua
 TEXT
 ${lua conky_draw_bg 10 0 0 0 0 0x000000 0.4}

OR Both above TEXT (no composite manager required - no blinking!)

 lua_load ~/wea_conky/draw_bg.lua
 lua_draw_hook_pre draw_bg 10 0 0 0 0 0x000000 0.5
 TEXT

Note
${lua conky_draw_bg 20 0 0 0 0 0x000000 0.4}
  See below:        1  2 3 4 5 6        7

${lua conky_draw_bg corner_radius x_position y_position width height color alpha}

covers the whole window and will change if you change the minimum_size setting

1 = 20             corner_radius
2 = 0             x_position
3 = 0             y_position
3 = 0             width
5 = 0             height
6 = 0x000000      color
7 = 0.4           alpha

]]

require 'cairo'
local    cs, cr = nil
function rgb_to_r_g_b(colour,alpha)
return ((colour / 0x10000) % 0x100) / 255., ((colour / 0x100) % 0x100) / 255., (colour % 0x100) / 255., alpha
end
function conky_draw_bg(r,x,y,w,h,color,alpha)
if conky_window == nil then return end
if cs == nil then cairo_surface_destroy(cs) end
if cr == nil then cairo_destroy(cr) 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)
w=w
h=h
if w=="0" then w=tonumber(conky_window.width) end
if h=="0" then h=tonumber(conky_window.height) end
cairo_set_source_rgba (cr,rgb_to_r_g_b(color,alpha))
--top left mid circle
local xtl=x+r
local ytl=y+r
--top right mid circle
local xtr=(x+r)+((w)-(2*r))
local ytr=y+r
--bottom right mid circle
local xbr=(x+r)+((w)-(2*r))
local ybr=(y+r)+((h)-(2*r))
--bottom right mid circle
local xbl=(x+r)
local ybl=(y+r)+((h)-(2*r))
-----------------------------
cairo_move_to (cr,xtl,ytl-r)
cairo_line_to (cr,xtr,ytr-r)
cairo_arc(cr,xtr,ytr,r,((2*math.pi/4)*3),((2*math.pi/4)*4))
cairo_line_to (cr,xbr+r,ybr)
cairo_arc(cr,xbr,ybr,r,((2*math.pi/4)*4),((2*math.pi/4)*1))
cairo_line_to (cr,xbl,ybl+r)
cairo_arc(cr,xbl,ybl,r,((2*math.pi/4)*1),((2*math.pi/4)*2))
cairo_line_to (cr,xtl-r,ytl)
cairo_arc(cr,xtl,ytl,r,((2*math.pi/4)*2),((2*math.pi/4)*3))
cairo_close_path(cr)
cairo_fill (cr)
------------------------------------------------------------
cairo_surface_destroy(cs)
cairo_destroy(cr)
return ""
end

Offline

#5209 2013-04-30 01:55:42

PackRat
#! Die Hard
From: USA
Registered: 2011-03-03
Posts: 1,291

Re: The New Monster Conky Thread

@Sector11 - in the April screenshot thread.

Last edited by PackRat (2013-04-30 01:56:08)


"It does not require many words to speak the truth." - Chief Joseph, Nez Perce tribe

Offline

#5210 2013-04-30 02:09:25

Sector11
77345 ¡#
From: SR11 Cockpit
Registered: 2010-05-05
Posts: 11,681
Website

Re: The New Monster Conky Thread

ichase wrote:

Been playing today.

Booteeful!  Brings a tear to me eye!  lol  lol


#! Forum Moderator | To #! or not to #!?  That is the question!
#! Conky = 16 Threads & the Conky Archives | Conky PitStop | OHCG'er
StartPage -  protect your privacy   |   BBQLinux

Offline

#5211 2013-04-30 02:16:27

Sector11
77345 ¡#
From: SR11 Cockpit
Registered: 2010-05-05
Posts: 11,681
Website

Re: The New Monster Conky Thread

PackRat wrote:

Thank you, I missed that...

Been running mine all day, no real strain on my CPU:
actBJDxH.jpg


#! Forum Moderator | To #! or not to #!?  That is the question!
#! Conky = 16 Threads & the Conky Archives | Conky PitStop | OHCG'er
StartPage -  protect your privacy   |   BBQLinux

Offline

#5212 2013-04-30 02:30:29

PackRat
#! Die Hard
From: USA
Registered: 2011-03-03
Posts: 1,291

Re: The New Monster Conky Thread

@Sector11 -

I found the typo in the conkyrc - too many 0's in the max_user_text.

Got it back to normal now:

April_1367288726_1600x900.jpg

Last edited by PackRat (2013-04-30 02:33:45)


"It does not require many words to speak the truth." - Chief Joseph, Nez Perce tribe

Offline

#5213 2013-04-30 02:49:56

Sector11
77345 ¡#
From: SR11 Cockpit
Registered: 2010-05-05
Posts: 11,681
Website

Re: The New Monster Conky Thread

PackRat wrote:

@Sector11 -

I found the typo in the conkyrc - too many 0's in the max_user_text.

lol  lol  ... and they say 0 = nothing.  RIGHT!

Good catch.


#! Forum Moderator | To #! or not to #!?  That is the question!
#! Conky = 16 Threads & the Conky Archives | Conky PitStop | OHCG'er
StartPage -  protect your privacy   |   BBQLinux

Offline

#5214 2013-04-30 13:49:47

captdavid1949
Member
From: Deltaville VA
Registered: 2012-09-22
Posts: 42
Website

Re: The New Monster Conky Thread

After much searching, and pulling of hair I decided to post this question in the #! forums (Where I first learned of Conky) even though this is running on a Fedora box. Sure there is a very simple solution, but like the jitterbug, it has plumb evaded me....

Very simple conky which includes monitoring used/available space on drives. One internal drive mounted on boot, and external usb drive which may or may not be mounted at any given time.

${color}/root${color}${alignr}${fs_used /} / ${fs_size /}    ${color}${alignr}${fs_free_perc /} % Free
${if_mounted /run/media/david/External_Drive_1}${color}External-1${color}${alignr}${fs_used /run/media/david/External_Drive_1} / ${fs_size /run/media/david/External_Drive_1}    ${color}${alignr}${fs_free_perc /run/media/david/External_Drive_1} % Free${endif}

Everything works as advertised as my external drive is always mounted in the same place, with the same name. What I need is a pointer to a "simple" (external?) script to parse the   /run/media/david/  directory for new mounts and pass them to conky if found.
In my current setup any hot-plugged usb device will not be auto mounted, but when mounted it will be in this directory. Depending on the device, the actual mount directory name could be whatever. Eg: a 4gig stick could be mounted as  /run/media/david/ 176E9D8C7FB9084E or  /run/media/david/ misc_files  or  /run/media/david/ foo.  How  to pass the info to conky ?

TIA for suggestions


"When you're up to your ass in alligators, its difficult to remember your initial objective was to drain the swamp"

Offline

#5215 2013-04-30 14:14:03

PackRat
#! Die Hard
From: USA
Registered: 2011-03-03
Posts: 1,291

Re: The New Monster Conky Thread

@captdavid1949 -

I think if_existing is the conky variable you want to use.

Some examples from Conky Pitstop.


"It does not require many words to speak the truth." - Chief Joseph, Nez Perce tribe

Offline

#5216 2013-04-30 14:36:02

ragamatrix
#! CrunchBanger
From: Horgen Switzerland
Registered: 2012-12-05
Posts: 234

Re: The New Monster Conky Thread

mrpeachy wrote:
ragamatrix wrote:

@mr peachy
Thanks to incorporate this function. Is it possible to add thermos for each day forecast (like high and low temp of the day) ?
What is the value for thermo day 1, day 2, day 3....etc to add here ? :

thermometer ({x=100,y=50,numbers=1,lines=1,f="sans",fs=12,label=weather_location,scale=0.5,units="C",tcol=tcol,val=val})

ad a [x] local function ? [

local temp=tonumber(day[x].low)

yes, you would set your values up and then use them in the thermometer

val=high_temp[1]
tcol=get_color({val,{0,0x00ffff},{10,0x00ff00},{20,0xffff00},{30,0xff7f00},{40,0xff0000}})
thermometer ({x=100.5,y=300,numbers=0,lines=0,f="sans",fs=12,label=weather_location,scale=1,units="C",tcol=tcol,val=val})

val=low_temp[1]
tcol=get_color({val,{0,0x00ffff},{10,0x00ff00},{20,0xffff00},{30,0xff7f00},{40,0xff0000}})
thermometer ({x=200.5,y=300,numbers=0,lines=0,f="sans",fs=12,label=weather_location,scale=1,units="C",tcol=tcol,val=val})

val=high_temp[2]
tcol=get_color({val,{0,0x00ffff},{10,0x00ff00},{20,0xffff00},{30,0xff7f00},{40,0xff0000}})
thermometer ({x=300.5,y=300,numbers=0,lines=0,f="sans",fs=12,label=weather_location,scale=1,units="C",tcol=tcol,val=val})

val=low_temp[2]
tcol=get_color({val,{0,0x00ffff},{10,0x00ff00},{20,0xffff00},{30,0xff7f00},{40,0xff0000}})
thermometer ({x=400,y=300,numbers=0,lines=0,f="sans",fs=12,label=weather_location,scale=1,units="C",tcol=tcol,val=val})

etc

@lionhead - all you have to do is cut and paste the 2 functions, get_color and thermometer and paste them into whatever script you want to use them in

Hello mr peachy;
I've tried what you shown but no success for me.... errors and no thermo displaying. Only the one for the current T°C
I didn't understand how displying with these lua lines codes :

--Thermo j+10
val=low_temp[1]
tcol=get_color({val,{0,0x00ffff},{10,0x00ff00},{20,0xffff00},{30,0xff7f00},{40,0xff0000}})
thermometer ({x=1650,y=150,numbers=0,lines=0,f="sans",fs=12,label=weather_location,scale=1,units="C",tcol=tcol,val=val})

val=high_temp[2]
tcol=get_color({val,{0,0x00ffff},{10,0x00ff00},{20,0xffff00},{30,0xff7f00},{40,0xff0000}})
thermometer ({x=1750,y=150,numbers=0,lines=0,f="sans",fs=12,label=weather_location,scale=1,units="C",tcol=tcol,val=val})

errors:

Conky: llua_do_call: function conky_weather execution failed: ...pement/revolutionary_clocks/template_meteo_barre.lua:332: attempt to compare string with number
Conky: llua_do_call: function conky_weather execution failed: ...

Offline

#5217 2013-04-30 15:16:12

Sector11
77345 ¡#
From: SR11 Cockpit
Registered: 2010-05-05
Posts: 11,681
Website

Re: The New Monster Conky Thread

PackRat wrote:

@captdavid1949 -

I think if_existing is the conky variable you want to use.

Some examples from Conky Pitstop.

Totally forgotten about uncertain's use of if_existing for mounting drives.  And while it works it is really to be used for files:

if_existing     file (string)
     if FILE exists, display everything between if_existing and the matching $endif. The optional second parameter checks for FILE containing the specified string and prints everything between $if_existing and the matching $endif.

Both if_mounted (made for this) and if_existing work for me though.

${if_mounted /media/disk}
External HDD is plugged in and mounted!${else}Ext HDD not mounted${endif}${if_existing /media/disk}
mount exists${else}mount non-existing${endif}

One problem ... you must "hard code" the mount points, if someone gives you a USB to look at it probably won't catch it.

BUT ....

@ captdavid1949

mrpeachy wrote a LUA script that is right up your ally.  It will monitor everything!

In my daily conky I use the regular conky calls for my internal drive, it's always mounted, and I use the section of the script that goes beyond my internal drive for all "external mounted devices"  Shown is my external HDD mounted:
acqKlhjd.jpg

The conky code necessary for this:

### mount.lua ##################################################################
#
##instructions
##load script
##lua_load ~/path_to/mounted.lua
lua_load /media/5/Conky/LUA/mounted.lua
## first lua command below text:
## ${lua get_mounted_data interval}, where interval is a number.  This starts data gathering
## to get output:
## ${lua mount partition_number data_type}, where partition number is a number
## data_type can be
## total - shows total number of partitions mounted, requires a partition_number also, use 1, could be used in an if_match
## fsys - shows filesystem
## size - shows space used in appropriate units
## free - shows free space in appropriate units
## use% - shows % used
## mount - shows mountpoint
#######################################################  End LUA Settings  ###

### ${execi 30 ~/bin/conky_min}\

update_interval 1
TEXT
${lua get_mounted_data 3}${lua conky_draw_bg 20 0 0 0 0 0x000000 0.4}\

{snip }

${font}${color}External Mounted fsys ${color7}${hr}${color}
${goto 5}${color}Size${goto 60}${color0}Free${goto 110}${color4}Used${goto 160}
${color5}${lua mount 6 mount}
${goto 5}${color}${lua mount 6 size}${goto 60}${color0}${lua mount 6 free}${goto 110}${color4}${lua mount 6 use%}${goto 160}${color5}${lua mount 6 fsys 9}
${color5}${lua mount 7 mount}
${goto 5}${color}${lua mount 7 size}${goto 60}${color0}${lua mount 7 free}${goto 110}${color4}${lua mount 7 use%}${goto 160}${color5}${lua mount 7 fsys 9}
${alignc}${color9}${execi 15 du -sh ~/.local/share/Trash/files/ | awk '{print $1}' | sed '/^4.0K/ d'  | sed 's/$/ of trash!/'}

And on another conky it shows my Internal partitions as well as external mounted partitions, I mounted two more to show more mounts:
adsKPQ2k.jpg
abyhJIJy.jpg

mounted.lua by mrpeachy

--[[partitions for conky by mrpeachy

##instructions
##load script
lua_load ~/lua/mounted.lua
## first lua command below text:
## ${lua get_mounted_data interval}, where interval is a number.  This starts data gathering
## to get output:
## ${lua mount partition_number data_type text_length}, where partition number is a number
## text_length is optional, lets you specify the max number of characters the function returns. only affects fsys and mount data options
## data_type can be
## total - shows total number of partitions mounted, requires a partition_number also, use 1, could be used in an if_match
## fsys - shows filesystem
## size - shows space used in appropriate units
## free - shows free space in appropriate units
## use% - shows % used
## mount - shows mountpoint

TEXT
CPU %: ${cpu cpu0} ${lua get_mounted_data 10}
TOTAL PARTITIONS MOUNTED: ${lua mount 1 total}
FSYS${goto 100}SIZE${goto 200}USED%${goto 300}MOUNT
${lua mount 1 fsys}${goto 100}${lua mount 1 size}${goto 200}${lua mount 1 use%}${goto 300}${lua mount 1 mount 10}
${lua mount 2 fsys}${goto 100}${lua mount 2 size}${goto 200}${lua mount 2 use%}${goto 300}${lua mount 2 mount 10}
${lua mount 3 fsys}${goto 100}${lua mount 3 size}${goto 200}${lua mount 3 use%}${goto 300}${lua mount 3 mount 10}
${lua mount 4 fsys}${goto 100}${lua mount 4 size}${goto 200}${lua mount 4 use%}${goto 300}${lua mount 4 mount 10}

]]

conky_start=1
function conky_get_mounted_data(interval)
local updates=tonumber(conky_parse("${updates}"))
timer=(updates % interval)
if timer==0 or conky_start==1 then
fsys={}
size={}
used={}
avail={}
uperc={}
mount={}
local file = io.popen("df -h")
	for line in file:lines() do
		if string.find(line,"/dev/")~=nil then
		local s,f,fs=string.find(line,"^([%d%a%p]*)%s")
		table.insert(fsys,fs)
		local s,f,sz=string.find(line,"%s*([%d%a%p]*)%s",f)
		table.insert(size,sz)
		local s,f,us=string.find(line,"%s*([%d%a%p]*)%s",f)
		table.insert(used,us)
		local s,f,av=string.find(line,"%s*([%d%a%p]*)%s",f)
		table.insert(avail,av)
		local s,f,up=string.find(line,"%s*([%d%a%p]*)%s",f)
		table.insert(uperc,up)
		local s,f,mn=string.find(line,"%s*([%d%a%p]*)%s*$",f)
		table.insert(mount,mn)
		end
	end
file:close()
conky_start=nil
end--timed section
return ""
end

function conky_mount(n,d,c)--n=partition_number,d=data_type,c=number of characters to return
d=tostring(d)
n=tonumber(n)
c=tonumber(c) or 0
if d=="total" then
data=#fsys or 1
elseif d=="fsys" then
data=fsys[n] or ""
	if c~=0 then
	data=string.sub(data,1,c) or ""
	end
elseif d=="size" then
data=size[n] or ""
elseif d=="used" then
data=used[n] or ""
elseif d=="free" then
data=avail[n] or ""
elseif d=="use%" then
data=uperc[n] or ""
elseif d=="mount" then
data=mount[n] or ""
	if c~=0 then
	data=string.sub(data,1,c) or ""
	end
else
data="check data type"
end
return data
end--end main function

#! Forum Moderator | To #! or not to #!?  That is the question!
#! Conky = 16 Threads & the Conky Archives | Conky PitStop | OHCG'er
StartPage -  protect your privacy   |   BBQLinux

Offline

#5218 2013-04-30 16:02:54

mrpeachy
20% cooler
From: The Everfree Forest
Registered: 2009-11-08
Posts: 3,460

Re: The New Monster Conky Thread

ragamatrix wrote:

@mr peachy
Thanks to incorporate this function. Is it possible to add thermos for each day forecast (like high and low temp of the day) ?
What is the value for thermo day 1, day 2, day 3....etc to add here ? :

attempt to compare string with number

ah... i forgot to tonumber those temp setting
- this is what that error is often caused by
do this for each instance:

val=tonumber(low_temp[1])

Offline

#5219 2013-04-30 23:22:09

captdavid1949
Member
From: Deltaville VA
Registered: 2012-09-22
Posts: 42
Website

Re: The New Monster Conky Thread

@sector11

Both if_mounted (made for this) and if_existing work for me though.

Yeah, if you notice in my original post (#5214) I am using "if-mounted" in my current config file for the external drive which may or may not be mounted and there for show up in  /run/media/david/  or not.
Works as advertised although earlier config using "if_existing works just as well.  Why that is,  I have my thoughts, but subject for another day.

One problem ... you must "hard code" the mount points, if someone gives you a USB to look at it probably won't catch it.

There lies the rub....   Fixed drive is a gimme.  External drive is hard coded, will always be the same name, same path.
But, have maybe 10 or 12 usb pendrive/stick/whatever laying around. More or less, the same style and colors..... Want to  be able to stick the stick in the port, do a one-click mount (can do that already).
The  stick mounts in  /run/media/david/ foo  (foo varies). Script parses   /run/media/david/  for sub directories and pass info to conky  to deal with as ${fs_used  /run/media/david/ foo }  ${fs_used  /run/media/david/ foo2}  etc.....
Would eliminate the need for the existing if-mounted call in existing config as well since it would show up in the directory parse.    In other words,  parsing  /run/media/david/  would pass any seen subdirectories  to conky as ${fs_[function]  /run/media/david/ foo-1} (new line) ${fs_[function]  /run/media/david/ foo-2}  (new line) ${fs_[function] /run/media/david/ foo-3} ......etc.

mrpeachy wrote a LUA script that is right up your ally.  It will monitor everything!

Mr Peachy writes some wonderful stuff, but way beyond my needs or learning curve. What I am hoping for is a simple bash (or python etc if you must) script to do the simple function described above

If I wasn't so simple myself, I could probably figure it out.
Once again from the top....
Script to run in conky each time it updates
Parse  /run/media/david/  and  pass any subdirectories to conkey as:
${fs_[function]  /run/media/david/ foo-1} (new line) ${fs_[function] /run/media/david/ foo-2}  (new line) ${fs_[function]  /run/media/david/ foo-3} ......etc.
That's it......
seems simple, but beyond my abilities
TIA
david


"When you're up to your ass in alligators, its difficult to remember your initial objective was to drain the swamp"

Offline

#5220 2013-05-01 02:54:35

mrpeachy
20% cooler
From: The Everfree Forest
Registered: 2009-11-08
Posts: 3,460

Re: The New Monster Conky Thread

captdavid1949 wrote:

Script to run in conky each time it updates
Parse  /run/media/david/  and  pass any subdirectories to conkey as:
${fs_[function]  /run/media/david/ foo-1} (new line) ${fs_[function] /run/media/david/ foo-2}  (new line) ${fs_[function]  /run/media/david/ foo-3} ......etc.
That's it......
seems simple, but beyond my abilities
TIA
david

unfortunately conky cant do that as the conkyrc isn't an actual script, its a configuration

take a look at the code that sector11 posted and you'll see it is one of the shortest/simplest lua scripts i have written smile

all it is doing is running

df -h

and extracting the info into tables
then you access the tables in a way similar to regular conkyrc objects

if you need help getting lua scripts running with conky then it pretty easy, sector11 has all the info to get things running in the conkyrc at the top of the script

Last edited by mrpeachy (2013-05-01 02:55:54)

Offline

#5221 2013-05-01 04:45:35

captdavid1949
Member
From: Deltaville VA
Registered: 2012-09-22
Posts: 42
Website

Re: The New Monster Conky Thread

Tks guys....  appreciate it.


"When you're up to your ass in alligators, its difficult to remember your initial objective was to drain the swamp"

Offline

#5222 2013-05-01 11:07:54

ragamatrix
#! CrunchBanger
From: Horgen Switzerland
Registered: 2012-12-05
Posts: 234

Re: The New Monster Conky Thread

@mr peachy
edit:
Is it possible to write mini and maxi for the thermo of each day rather than the weather location ?
I've found big_smile

What do you think about use these thermo functions "changing colors" for cpu, ram, hd net activity ?

Last edited by ragamatrix (2013-05-01 15:00:19)

Offline

#5223 2013-05-01 13:30:16

Sector11
77345 ¡#
From: SR11 Cockpit
Registered: 2010-05-05
Posts: 11,681
Website

Re: The New Monster Conky Thread

captdavid1949 wrote:

Tks guys....  appreciate it.

The thing I did is I is not run them in sequence ... here's my df -h with no external devices mounted - I always boot this way unless doing an install of a test ISO: (media/6 and media/7)

01 May 13 | 09:53:31 ~
         $ df -h
Filesystem      Size  Used Avail Use% Mounted on
rootfs           15G  7.3G  6.7G  53% /
udev             10M     0   10M   0% /dev
tmpfs           597M  416K  596M   1% /run
/dev/sda1        15G  7.3G  6.7G  53% /
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           2.0G     0  2.0G   0% /run/shm
/dev/sda5       166G   42G  115G  27% /media/5
/dev/sda7        16G  109M   15G   1% /media/7
/dev/sda6        16G  4.7G  9.7G  33% /media/6
/dev/sda2        15G  6.6G  7.4G  48% /home

01 May 13 | 09:53:31 ~
         $

Code to call those plus 3 externals:

TEXT
${lua get_mounted_data 3}\
${color6}fsys${color} = ${lua mount 1 total}${goto 85}${color8}Size${goto 130}${color7}Free${goto 180}${color1}Used${goto 220}${color}Mount
${color6}${lua mount 1 fsys 9}${goto 85}${color8}${lua mount 1 size}${goto 130}${color7}${lua mount 1 free}${goto 180}${color1}${lua mount 1 use%}${goto 220}${color}${lua mount 1 mount}
${color6}${lua mount 5 fsys 9}${goto 85}${color8}${lua mount 5 size}${goto 130}${color7}${lua mount 5 free}${goto 180}${color1}${lua mount 5 use%}${goto 220}${color}${lua mount 5 mount}
${color6}${lua mount 2 fsys 9}${goto 85}${color8}${lua mount 2 size}${goto 130}${color7}${lua mount 2 free}${goto 180}${color1}${lua mount 2 use%}${goto 220}${color}${lua mount 2 mount}
${color6}${lua mount 4 fsys 9}${goto 85}${color8}${lua mount 4 size}${goto 130}${color7}${lua mount 4 free}${goto 180}${color1}${lua mount 4 use%}${goto 220}${color}${lua mount 4 mount}
${color6}${lua mount 3 fsys 9}${goto 85}${color8}${lua mount 3 size}${goto 130}${color7}${lua mount 3 free}${goto 180}${color1}${lua mount 3 use%}${goto 220}${color}${lua mount 3 mount}
External mounts (I have space for 4 RARELY use 3):
${color6}${lua mount 6 fsys 9}${goto 85}${color8}${lua mount 6 size}${goto 130}${color7}${lua mount 6 free}${goto 180}${color1}${lua mount 6 use%}${goto 220}${color}${lua mount 6 mount}
${color6}${lua mount 7 fsys 9}${goto 85}${color8}${lua mount 7 size}${goto 130}${color7}${lua mount 7 free}${goto 180}${color1}${lua mount 7 use%}${goto 220}${color}${lua mount 7 mount}
${color6}${lua mount 8 fsys 9}${goto 85}${color8}${lua mount 8 size}${goto 130}${color7}${lua mount 8 free}${goto 180}${color1}${lua mount 8 use%}${goto 220}${color}${lua mount 8 mount}

All I did was resort the order they display to get / and /home together and have m/5 m/6 and m/7 to display in order

adgdtkvh.jpg

A simplified start

${lua mount 1 fsys 9}etc etc
${lua mount 5 fsys 9}etc etc
${lua mount 2 fsys 9}etc etc
${lua mount 4 fsys 9}etc etc
${lua mount 3 fsys 9}etc etc
External mounts (I have space for 4 RARELY use 3):
${lua mount 6 fsys 9}etc etc
${lua mount 7 fsys 9}etc etc
${lua mount 8 fsys 9}etc etc

Maybe that will help a bit more.  If you run into any problems, just ask.


#! Forum Moderator | To #! or not to #!?  That is the question!
#! Conky = 16 Threads & the Conky Archives | Conky PitStop | OHCG'er
StartPage -  protect your privacy   |   BBQLinux

Offline

#5224 2013-05-01 13:44:16

mrpeachy
20% cooler
From: The Everfree Forest
Registered: 2009-11-08
Posts: 3,460

Re: The New Monster Conky Thread

ragamatrix wrote:

@mr peachy
Is it possible to write mini and maxi for the thermo of each day rather than the weather location ?

What do you think about use these thermo functions "changing colors" for cpu, ram, hd net activity ?

you can change the label by changing
label=weather_location
make label= whatever it is you want to show

as for the get_color function, that has the potential to colorize a range of different outputs
with some modification it could be used with conky_parse and return a color setting to conky before other conky objects

or simply provide a color for lua generated bars

Offline

Help fund CrunchBang, donate to the project!

#5225 2013-05-01 15:01:51

ragamatrix
#! CrunchBanger
From: Horgen Switzerland
Registered: 2012-12-05
Posts: 234

Re: The New Monster Conky Thread

@mr peachy
Thanks again for your kind explanations  cool

Offline

Board footer

Powered by FluxBB

Copyright © 2012 CrunchBang Linux.
Proudly powered by Debian. Hosted by Linode.
Debian is a registered trademark of Software in the Public Interest, Inc.

Debian Logo