SEARCH

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

You are not logged in.

#1076 2014-01-17 02:32:26

falldown
#! Samurai
Registered: 2011-09-01
Posts: 1,727

Re: interactive conky

Sorry to anyone subscribed to this thread, but ^ BUMP^
This masterpiece was buried...

Offline

Be excellent to each other!

#1077 2014-12-07 06:42:28

Inodoro Pereyra
#! Die Hard
From: Back in Buenos Aires
Registered: 2013-07-01
Posts: 844

Re: interactive conky

Ok, I realize this is an old thread, but since Falldown brought it back to life not that long ago, maybe I can get away with it... wink

I'm trying to turn most of my conkys into interactive ones, so I can have them available without taking up that much screen space. So as a first attempt, I copied/pasted MrPeachy's lua script from this thread's first post, and made the suggested mods to one of my conkys. However, when I start it, it only shows like a normal conky, no interaction whatsoever.
I tried to go to the interactive conky how to, but the link is broken.

So, what am I doing wrong?

Here's my code:

clicky.lua

--[[click with mouse over lua by mrpeachy - thanks to barrybarrykelly for the xdotool method and gmonti for finding the deb files for the xdotool
in conkyrc, in addition to regular settings:

own_window_title clicky
lua_load ~/.conky/clicky.lua
lua_draw_hook_pre main
TEXT

3/13/12
]]

require 'cairo'

click_start=1-- this starts the clickfunction
buttons={}--this table ini9tially holds the values from the buttons

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)
local updates=tonumber(conky_parse('${updates}'))
if updates>5 then
--#################################################################################################
localx,localy,localnowx,localnowy=clickfunction()--this line activates the clickfunction and sets the click coordinates
--#################################################################################################
--SET DEFAULTS ##########################################################
--set defaults do not localise these defaults if you use a seperate display script
default_font="mono"--font must be in quotes
default_font_size=10
default_color=0xffffff--white
default_alpha=1--fully opaque
default_image_width=50
default_image_height=50
--#################################################################################################
--button setup - this section for an on/off button 
local button_name="cpu"
local blx=100.5--bottom left x coordinate of click area, the .5 makes the 1 pixel box line sharp
local bly=100.5--bottom left x coordinate of click area
local height=20--height of click area
local width=30--width of click area

--setup cpu section position, when setting up cpu function everything is relative to these points
local cpu_blx=blx+width+2
local cpu_bly=100.5
local overlap=width
--##############################################################
--calculate if click was inside box and set actions#############
--best to keep the button calculations seperate to the actions##
if localx>=blx and localx<=blx+width and localy<=bly and localy>=bly-height and buttons[tostring(button_name)]~=1 then
buttons[tostring(button_name)]=1
elseif localx>=blx and localx<=blx+width and localy<=bly and localy>=bly-height and buttons[tostring(button_name)]==1 then
buttons[tostring(button_name)]=0
elseif localx<blx and localx>blx+width and localy<bly and localy>bly-height and buttons[tostring(button_name)]~=1 then
buttons[tostring(button_name)]=0 end
--end of calculations ##########################################

--mouseover
if buttons["coresmo"]==1 or localnowx>=blx and localnowx<=blx+width and localnowy<=bly and localnowy>=bly-height then
    if buttons[tostring(button_name)]~=1 then
    cpusection(cpu_blx,cpu_bly,overlap)
    end
end

if localnowx>=blx and localnowx<=blx+width and localnowy<=bly and localnowy>=bly-height then
color={0,0,0,1}
fill=1
buttondraw(blx,bly,height,width,color,fill)
end

--##############################################################
--button on off
if buttons[tostring(button_name)]==1 then
color={1,0,0,1}--if button is clicked on it will be drawn red
fill=0
buttondraw(blx,bly,height,width,color,fill)
cpusection(cpu_blx,cpu_bly,overlap)
else
color={1,1,0,1}--if button is clicked on it will be drawn red
fill=0
buttondraw(blx,bly,height,width,color,fill)
end--button on off
out({x=105,y=95,txt="CPU"})
--#########################################################################################################
end-- if updates>5
cairo_destroy(cr)
cairo_surface_destroy(cs)
cr=nil
end-- end main function

function cpusection(cpu_blx,cpu_bly,overlap)
--button setup - this section for an on/off button 
local button_name="cores"
local blx=cpu_blx--bottom left x coordinate of click area, the .5 makes the 1 pixel box line sharp
local bly=cpu_bly--bottom left x coordinate of click area
local height=20--height of click area
local width=60--width of click area
--setup cpu section position, when setting up cpu function everything is relative to these points
local cores_blx=blx+width+15
local cores_bly=bly
--##############################################################
--calculate if click was inside box and set actions#############
--best to keep the button calculations seperate to the actions##
if localx>=blx and localx<=blx+width and localy<=bly and localy>=bly-height and buttons[tostring(button_name)]~=1 then
buttons[tostring(button_name)]=1
elseif localx>=blx and localx<=blx+width and localy<=bly and localy>=bly-height and buttons[tostring(button_name)]==1 then
buttons[tostring(button_name)]=0
elseif localx<blx and localx>blx+width and localy<bly and localy>bly-height and buttons[tostring(button_name)]~=1 then
buttons[tostring(button_name)]=0 end
--end of calculations ##########################################
--mouseover
if buttons["processmo"]==1 or localnowx>=blx-overlap and localnowx<=blx+width and localnowy<=bly and localnowy>=bly-height then
buttons[tostring(button_name.."mo")]=1
--buttons["cpumo"]=1
--elseif localnowx<blx-overlap or localnowx>blx+width or localnowy>bly or localnowy<bly-height then
--buttons[tostring(button_name.."mo")]=0
else
buttons[tostring(button_name.."mo")]=0
end--mouseover

if localnowx>=blx and localnowx<=blx+width and localnowy<=bly and localnowy>=bly-height then
color={0,0,0,1}
fill=1
buttondraw(blx,bly,height,width,color,fill)
--so that cpu isnt drawn twice
    if buttons[tostring(button_name)]~=1 then
    coressection(cores_blx,cores_bly)
    end
end
--##############################################################
--button on off
if buttons[tostring(button_name)]==1 then
color={1,0,0,1}--if button is clicked on it will be drawn red
fill=0
buttondraw(blx,bly,height,width,color,fill)
coressection(cores_blx,cores_bly)
else
color={0,1,1,1}
fill=0
buttondraw(blx,bly,height,width,color,fill)
end--button on off
out({x=blx+5,y=bly-5,txt="CPU%:"..conky_parse("${cpu}")})
--##############################################################
--##############################################################
--##############################################################
--##############################################################
--##############################################################
--button controlling processes section
--button setup - this section for an on/off button 
local button_name="process"
local blx=blx--bottom left x coordinate of click area, the .5 makes the 1 pixel box line sharp
local bly=bly+height+2--bottom left x coordinate of click area
local height=20--height of click area
local width=60--width of click area
--setup cpu section position, when setting up cpu function everything is relative to these points
local process_blx=blx+width+15
local process_bly=bly
--##############################################################
--calculate if click was inside box and set actions#############
--best to keep the button calculations seperate to the actions##
if localx>=blx and localx<=blx+width and localy<=bly and localy>=bly-height and buttons[tostring(button_name)]~=1 then
buttons[tostring(button_name)]=1
elseif localx>=blx and localx<=blx+width and localy<=bly and localy>=bly-height and buttons[tostring(button_name)]==1 then
buttons[tostring(button_name)]=0
elseif localx<blx and localx>blx+width and localy<bly and localy>bly-height and buttons[tostring(button_name)]~=1 then
buttons[tostring(button_name)]=0 end
--end of calculations ##########################################
--mouseover
if localnowx>=blx and localnowx<=blx+width and localnowy<=bly and localnowy>=bly-height-height then
buttons[tostring(button_name.."mo")]=1
elseif localnowx<blx or localnowx>blx+width or localnowy>bly or localnowy<bly-height-height then
buttons[tostring(button_name.."mo")]=0
end--mouseover

if localnowx>=blx and localnowx<=blx+width and localnowy<=bly and localnowy>=bly-height then
color={0,0,0,1}
fill=1
buttondraw(blx,bly,height,width,color,fill)
--so that cpu isnt drawn twice
    if buttons[tostring(button_name)]~=1 then
    processsection(cores_blx,cores_bly)
    end
end
--##############################################################
--button on off
if buttons[tostring(button_name)]==1 then
color={1,0,0,1}--if button is clicked on it will be drawn red
fill=0
buttondraw(blx,bly,height,width,color,fill)
processsection(cores_blx,cores_bly)
else
color={0,1,1,1}
fill=0
buttondraw(blx,bly,height,width,color,fill)
end--button on off
out({x=blx+5,y=bly-5,txt="PRO#:"..conky_parse("${processes}")})
end--cpu section

function coressection(blx,bly)
out({x=blx,y=bly-5,txt="CPU1:"..conky_parse("${cpu cpu1}").."%"})
out({x=blx,y=bly+15,txt="CPU2:"..conky_parse("${cpu cpu2}").."%"})
out({x=blx,y=bly+35,txt="CPU3:"..conky_parse("${cpu cpu3}").."%"})
--out({c=0x00ff00,x=255,y=155,txt="CPU:"..conky_parse("${cpu cpu4}").."%"})
end--coressection

function processsection(blx,bly)
out({x=blx+100,y=bly-5,txt="PROC1:"..conky_parse("${top name 1}")})
out({x=blx+100,y=bly+15,txt="PROC2:"..conky_parse("${top name 2}")})
out({x=blx+100,y=bly+35,txt="PROC3:"..conky_parse("${top name 3}")})
--out({c=0x00ff00,x=255,y=155,txt="CPU:"..conky_parse("${cpu cpu4}").."%"})
end--coressection

--button drawing function
function buttondraw(blx,bly,height,width,color,fill)
cairo_set_line_width (cr,1)
cairo_set_source_rgba (cr,color[1],color[2],color[3],color[4])
cairo_rectangle (cr,blx,bly,width,-height)
if fill==0 then
cairo_stroke (cr)
elseif fill==1 then
cairo_fill (cr)
end
end--of buttondraw function
function xout(txj)--c,a,f,fs,x,y,txt,j ##################################################
c=nil
c=(txj.c or default_color)
a=nil
a=(txj.a or default_alpha)
f=nil
f=(txj.f or default_font)
fs=nil
fs=(txj.fs or default_font_size)
x=nil
x=(txj.x or 0)
y=nil
y=(txj.y or 0)
txt=nil
txt=(txj.txt or "set txt")
j=nil
j=(txj.j or "l")
    local function col(c,a)
    return ( (c/0x10000) % 0x100)/255,( (c/0x100) % 0x100)/255,(c % 0x100)/255,a
    end--local function
cairo_select_font_face (cr, f, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cr, fs)
local text=string.gsub(txt," ","_")
extents=cairo_text_extents_t:create()
cairo_text_extents(cr,text,extents)
local wx=extents.width
cairo_set_source_rgba (cr,col(c,a))
if j=="l" then
cairo_move_to (cr,x,y)
adx=wx
elseif j=="c" then
cairo_move_to (cr,x-(wx/2),y)
adx=wx/2
elseif j=="r" then
cairo_move_to (cr,x-wx,y)
adx=0
end
cairo_show_text (cr,txt)
cairo_stroke (cr)
nextx=nil
nextx=adx+x
return nextx
end--function xout ###################################################################
function out(tx)--####################################################################
c=nil
c=(tx.c or default_color)
a=nil
a=(tx.a or default_alpha)
f=nil
f=(tx.f or default_font)
fs=nil
fs=(tx.fs or default_font_size)
x=nil
x=(tx.x or 0)
y=nil
y=(tx.y or 0)
txt=nil
txt=(tx.txt or "set txt")
local function col(c,a)
return ( (c/0x10000) % 0x100)/255,( (c/0x100) % 0x100)/255,(c % 0x100)/255,a
end--local function
cairo_select_font_face (cr, f, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cr, fs)
cairo_set_source_rgba (cr,col(c,a))
cairo_move_to (cr,x,y)
cairo_show_text (cr,txt)
cairo_stroke (cr)
end--function out ###################################################################
function image(im)--#################################################################
x=nil
x=(im.x or 0)
y=nil
y=(im.y or 0)
w=nil
w=(im.w or default_image_width)
h=nil
h=(im.h or default_image_height)
file=nil
file=tostring(im.file)
if file==nil then print("set image file") end
---------------------------------------------
local show = imlib_load_image(file)
if show == nil then return end
imlib_context_set_image(show)
if tonumber(w)==0 then 
width=imlib_image_get_width() 
else
width=tonumber(w)
end
if tonumber(h)==0 then 
height=imlib_image_get_height() 
else
height=tonumber(h)
end
imlib_context_set_image(show)
local scaled=imlib_create_cropped_scaled_image(0, 0, imlib_image_get_width(), imlib_image_get_height(), width, height)
imlib_free_image()
imlib_context_set_image(scaled)
imlib_render_image_on_drawable(x, y)
imlib_free_image()
show=nil
end--function image ##################################################################
--clickfunction, this runs xdotool and xwininfo and reads the coordinates of clicks
function clickfunction()
--start click logging and calculations ##########################################
if click_start==1 then
xdot=conky_parse("${if_running xdotool}1${else}0${endif}")
if tonumber(xdot)==1 then
os.execute("killall xdotool && echo 'xdo killed' &")
end
os.execute("xdotool search --name 'clicky' behave %@ mouse-click getmouselocation >> /tmp/xdo &")
local f = io.popen("xwininfo -name 'clicky' | grep 'Absolute'")
geometry = f:read("*a")
f:close()
local geometry=string.gsub(geometry,"[\n]","")
s,f,abstlx=string.find(geometry,"X%p%s*(%d*)")
s,f,abstly=string.find(geometry,"Y%p%s*(%d*)")
click_start=nil
end--if click_start=1 ######################################
--click calculations #################################
local f=io.open("/tmp/xdo")
click=f:read()
f:close()
if click~=nil then
local f = io.open("/tmp/xdo","w")
f:write("")
f:close() 
end--if click=nil
if click==nil then click="x:0 y:0 " end
--print (click)
local s,f,mousex=string.find(click,"x%p(%d*)%s")
local s,f,mousey=string.find(click,"y%p(%d*)%s")
localx=tonumber(mousex)-abstlx
localy=tonumber(mousey)-abstly
--get now location
os.execute("xdotool getmouselocation > /tmp/xdonow ")
local f=io.open("/tmp/xdonow")
mousenow=f:read()
f:close()
local s,f,mousenowx=string.find(mousenow,"x%p(%d*)%s")
local s,f,mousenowy=string.find(mousenow,"y%p(%d*)%s")
localnowx=tonumber(mousenowx)-abstlx
localnowy=tonumber(mousenowy)-abstly
--END CLICK CALCULATIONS #################################
return localx,localy,localnowx,localnowy
end--function

dates.conky

# killall conky && conky -c /home/bernardo/.conky/dates.conky &
# Kindly modified by Sector11 for a friend

background yes

cpu_avg_samples 1
net_avg_samples 2
temperature_unit celsius

double_buffer yes
no_buffers yes
text_buffer_size 2048

gap_x 38
gap_y 10
minimum_size 320 0
maximum_width 320
own_window yes
own_window_type normal
own_window_transparent yes
own_window_argb_visual yes
own_window_argb_value 0
own_window_class conky
own_window_title clicky
own_window_hints sticky,undecorated,skip_taskbar,skip_pager,below
border_inner_margin 0
border_outer_margin 0
alignment bottom_left


draw_shades no
draw_outline no
draw_borders no
draw_graph_borders no

override_utf8_locale yes
use_xft yes
##xftfont caviar dreams:size=7
xftfont Monospace:bold:size=8.5
xftalpha 1.0


# Defining colors
default_color FFFFFF

color1 FF0000	#Red
color2 EEE8AA	#PaleGoldenrod
color3 8FBC8F	#DarkSeaGreen
color4 FF7500	#Orange
color5 7FFF00	#Chartreuse
color6 0000CD	#Medium blue


update_interval 120

lua_load /home/bernardo/.conky/clicky.lua
lua_draw_hook_pre main

TEXT


${font Monospace:size=10}28 Mar 2013 ${goto 80} ${color4}${execi 1800 conkyDateDiff 20130328} ago${color}${alignr}Days${font :pixelsize=3}
${color6}${hr 1}${font :pixelsize=2}
${hr 1}${color}${font :pixelsize=2}
${color1}${font}ICH${color}${goto 65}04/03/65${goto 120}${color5}${execi 1800 conkyDateDiff 19650304}${alignr}${color}${color3}${execi 1800 conkyDaysDiff 19650304}${color}${font :pixelsize=3}
${color6} ${hr 1}${color}${font :pixelsize=2}
${color1}${font}ABIGAIL${color}${goto 65}12/07/73${goto 120}${color}${color5}${execi 1800 conkyDateDiff 19730712}${alignr}${color3}${execi 1800 conkyDaysDiff 19730712}${color}
${color1}DAYANA${color}${goto 65}08/05/87${goto 120}${color5}${execi 1800 conkyDateDiff 19870508}${alignr}${color}${color3}${execi 1800 conkyDaysDiff 19870508}${color}
${color1}LETICIA${color}${goto 65}07/03/97${goto 120}${color5}${execi 1800 conkyDateDiff 19970307}${alignr}${color}${color3}${execi 1800 conkyDaysDiff 19970307}${color}
${color1}FREDERICK${color}${goto 65}01/12/98${goto 120}${color5}${execi 1800 conkyDateDiff 19981201}${alignr}${color}${color3}${execi 1800 conkyDaysDiff 19981201}${color}${font :pixelsize=3}
${color6} ${hr 1}${color}${font :pixelsize=2}
${color1}${font}EDGAR${color}${goto 65}01/02/64${goto 120}${color5}${execi 1800 conkyDateDiff 19640201}${alignr}${color}${color3}${execi 1800 conkyDaysDiff 19640201}${color}
${color1}ANALIA${color}${goto 65}31/01/74${goto 120}${color5}${execi 1800 conkyDateDiff 19740131}${alignr}${color}${color3}${execi 1800 conkyDaysDiff 19740131}${color}
${color1}DAIANA${color}${goto 65}18/07/89${goto 120}${color5}${execi 1800 conkyDateDiff 19890718}${alignr}${color}${color3}${execi 1800 conkyDaysDiff 19890718}${color}
${color1}FLORENCIA${color}${goto 65}05/04/91${goto 120}${color5}${execi 1800 conkyDateDiff 19910405}${alignr}${color}${color3}${execi 1800 conkyDaysDiff 19910405}${color}
${color1}CAMILA${color}${goto 65}29/11/94${goto 120}${color5}${execi 1800 conkyDateDiff 19941129}${alignr}${color}${color3}${execi 1800 conkyDaysDiff 19941129}${color}
${color1}JOAQUIN${color}${goto 65}21/09/01${goto 120}${color5}${execi 1800 conkyDateDiff 20010921}${alignr}${color}${color3}${execi 1800 conkyDaysDiff 20010921}${color}
${color1}ARIANA${color}${goto 65}29/11/99${goto 120}${color5}${execi 1800 conkyDateDiff 19991129}${alignr}${color}${color3}${execi 1800 conkyDaysDiff 19991129}${color}
${color1}NICOLAS${color}${goto 65}09/01/03${goto 120}${color5}${execi 1800 conkyDateDiff 20030109}${alignr}${color}${color3}${execi 1800 conkyDaysDiff 20030109}${color}${font :pixelsize=3}
${color6} ${hr 1}${color}${font :pixelsize=2}
${color1}${font}MYRIAN${color}${color}${goto 65}05/03/71${goto 120}${color5}${execi 1800 conkyDateDiff 19710305}${color}${color3}${alignr}${execi 1800 conkyDaysDiff 19710305}${color}
${color1}MARCELO${color}${goto 65}27/04/67${goto 120}${color5}${execi 1800 conkyDateDiff 19670427}${alignr}${color}${color3}${execi 1800 conkyDaysDiff 19670427}${color}
${color1}MELANIE${color}${goto 65}18/04/02${goto 120}${color5}${execi 1800 conkyDateDiff 20020418}${alignr}${color}${color3}${execi 1800 conkyDaysDiff 20020418}${color}
${color1}MARTINA${color}${goto 65}07/01/05${goto 120}${color5}${execi 1800 conkyDateDiff 20050107}${alignr}${color}${color3}${execi 1800 conkyDaysDiff 20050107}${color}${font :pixelsize=3}
${color6} ${hr 1}${color}${font :pixelsize=2}
${color1}${font}ERNESTO${color}${goto 65}29/12/58${goto 120}${color5}${execi 1800 conkyDateDiff 19581229}${alignr}${color}${color3}${execi 1800 conkyDaysDiff 19581229}${color}
${color1}MAXI${color}${goto 65}03/07/89${goto 120}${color5}${execi 1800 conkyDateDiff 19890703}${alignr}${color}${color3}${execi 1800 conkyDaysDiff 19890703}
${color1}CHRISTIAN${color}${goto 65}13/03/93${goto 120}${color5}${execi 1800 conkyDateDiff 19930313}${alignr}${color}${color3}${execi 1800 conkyDaysDiff 19930313}
${color1}RODRIGO${color}${goto 65}02/12/94${goto 120}${color5}${execi 1800 conkyDateDiff 19941202}${alignr}${color}${color3}${execi 1800 conkyDaysDiff 19941202}${font :pixelsize=3}
${color6} ${hr 1}${color}${font}

Offline

#1078 2014-12-07 07:27:07

damo
#! gimpbanger
From: N51.5 W002.8 (mostly)
Registered: 2011-11-24
Posts: 5,434

Re: interactive conky

What error messages, if any, do you get if you start the conky in a terminal (NB always a good idea with any application giving difficulty wink )


BunsenLabs Group on deviantArt
damo's gallery on deviantArt
Openbox themes
Forum Moderator smile

Offline

#1079 2014-12-07 07:47:05

Inodoro Pereyra
#! Die Hard
From: Back in Buenos Aires
Registered: 2013-07-01
Posts: 844

Re: interactive conky

damo wrote:

What error messages, if any, do you get if you start the conky in a terminal (NB always a good idea with any application giving difficulty wink )

Oops, sorry. I did open it on the terminal, but forgot to put it up here... :8

Here:

bernardo@bernardo:~$ killall conky && conky -c /home/bernardo/.conky/dates.conky &
[1] 27363
bernardo@bernardo:~$ Conky: forked to background, pid is 27367

Conky: desktop window (131) is root window
Conky: window type - normal
Conky: drawing to created window (0x2800002)
Conky: drawing to double buffer

[1]+  Done                    killall conky && conky -c /home/bernardo/.conky/dates.conky
bernardo@bernardo:~$ 

No errors as far as I know...

Offline

#1080 2014-12-07 08:41:25

damo
#! gimpbanger
From: N51.5 W002.8 (mostly)
Registered: 2011-11-24
Posts: 5,434

Re: interactive conky

And if you don't fork it to background, is there any output when you click on the conky?

conky -c /home/bernardo/.conky/dates.conky

BunsenLabs Group on deviantArt
damo's gallery on deviantArt
Openbox themes
Forum Moderator smile

Offline

#1081 2014-12-07 09:03:50

Inodoro Pereyra
#! Die Hard
From: Back in Buenos Aires
Registered: 2013-07-01
Posts: 844

Re: interactive conky

damo wrote:

And if you don't fork it to background, is there any output when you click on the conky?

conky -c /home/bernardo/.conky/dates.conky

Nope, nothing.

2014_12_07_1417942826_1600x900_scrot.jpg

The thing is, there's no button to click on. But even if I click on the conky itself, nothing happens... sad

Offline

#1082 2014-12-07 09:11:54

damo
#! gimpbanger
From: N51.5 W002.8 (mostly)
Registered: 2011-11-24
Posts: 5,434

Re: interactive conky

Maybe a misunderstanding here? If you run the command

conky -c /home/bernardo/.conky/dates.conky

and leave the terminal open, is there any output in the terminal when you click on the conky?

(A common problem with conky & lua is that the user doesn't ensure that the path to the lua file is correct in the "lua_load" line)

Last edited by damo (2014-12-07 09:12:53)


BunsenLabs Group on deviantArt
damo's gallery on deviantArt
Openbox themes
Forum Moderator smile

Offline

#1083 2014-12-07 09:19:04

Inodoro Pereyra
#! Die Hard
From: Back in Buenos Aires
Registered: 2013-07-01
Posts: 844

Re: interactive conky

I understood you. I did both, and the terminal is always open in my computer. In neither case did anything new show in it.
However, now that I TERMINATED the conky, it showed this:

bernardo@bernardo:~$ conky -c /home/bernardo/.conky/dates.conky
Conky: desktop window (131) is root window
Conky: window type - normal
Conky: drawing to created window (0x2c00002)
Conky: drawing to double buffer
findclient: 12583732
findclient: 12583731
findclient: 12614138
findclient: 12614137
findclient: 12614138
findclient: 12614137
findclient: 12614138
findclient: 12614137
findclient: 12614138
findclient: 12614137
findclient: 12614138
findclient: 12614137
findclient: 12614138
findclient: 12614137
findclient: 12614138
findclient: 12614137
findclient: 12614138
findclient: 12614137
findclient: 12614138
findclient: 12614137
findclient: 12614138
findclient: 12614137
findclient: 12614138
findclient: 12614137
Conky: received SIGINT or SIGTERM to terminate. bye!
Conky: received SIGINT or SIGTERM to terminate. bye!
bernardo@bernardo:~$ 

Does it make any difference?  neutral

Offline

#1084 2014-12-07 11:40:29

ohnonot
...again
Registered: 2012-05-22
Posts: 2,205

Re: interactive conky

^ no not really.

debugging conky is a pita....

in your conky config, make sure:

background no

so it doesn't fork itself to background when you start it from the terminal.
also make sure that all conky processes are dead - don't use "killall conky && conky ....", use the "killall conky" in a seperate command.

conky also has a debugging switch, so starting it: "conky -D -c /wherever/your/config/file" should give more output. but i have never tried that.

fwiw, sometimes conky will somehow be affected by the last time it was started, even if i killed it twice.
i guess it's caching something somewhere and uses the old cache; i had to restart X or maybe even reboot to fix it.
conky is a strange beast.

Offline

#1085 2014-12-07 12:10:47

Head_on_a_Stick
CatMod
From: A world of pure imagination
Registered: 2014-01-21
Posts: 4,797

Offline

#1086 2014-12-07 22:22:56

Inodoro Pereyra
#! Die Hard
From: Back in Buenos Aires
Registered: 2013-07-01
Posts: 844

Re: interactive conky

ohnonot wrote:

^ no not really.

debugging conky is a pita....

in your conky config, make sure:

background no

so it doesn't fork itself to background when you start it from the terminal.
also make sure that all conky processes are dead - don't use "killall conky && conky ....", use the "killall conky" in a seperate command.

conky also has a debugging switch, so starting it: "conky -D -c /wherever/your/config/file" should give more output. but i have never tried that.

fwiw, sometimes conky will somehow be affected by the last time it was started, even if i killed it twice.
i guess it's caching something somewhere and uses the old cache; i had to restart X or maybe even reboot to fix it.
conky is a strange beast.

Ok, here's what I got.
I followed your instructions, and there's been a few changes. First, here's the terminal output:

bernardo@bernardo:~$ conky -D -c /home/bernardo/.conky/dates.conky
DEBUG(0) [../../src/conky.c:5338]: reading contents from config file '/home/bernardo/.conky/dates.conky'
Conky: desktop window (131) is root window
DEBUG(0) [../../src/x11.c:240]: Found ARGB Visual
Conky: window type - normal
Conky: drawing to created window (0x2800002)
Conky: drawing to double buffer
findclient: 12583870
findclient: 12583869
findclient: 12584435
findclient: 12584434
findclient: 12584435
findclient: 12584434
findclient: 12584435
findclient: 12584434
findclient: 12584435
findclient: 12584434
findclient: 12584435
findclient: 12584434
findclient: 12584435
findclient: 12584434
findclient: 12584435
findclient: 12584434
findclient: 12585125
findclient: 12585124
Conky: '/home/bernardo/.conky/dates.conky' modified, reloading...
DEBUG(0) [../../src/conky.c:4543]: reading contents from config file '/home/bernardo/.conky/dates.conky'
DEBUG(0) [../../src/conky.c:5338]: reading contents from config file '/home/bernardo/.conky/dates.conky'
DEBUG(1) [../../src/core.c:1225]: no templates to replace
Conky: desktop window (131) is root window
DEBUG(0) [../../src/x11.c:240]: Found ARGB Visual
Conky: window type - normal
Conky: drawing to created window (0x2800002)
Conky: drawing to double buffer
DEBUG(1) [../../src/core.c:1225]: no templates to replace
DEBUG(1) [../../src/conky.c:2399]: evaluated '${updates}' to '7'
DEBUG(1) [../../src/core.c:1225]: no templates to replace
DEBUG(1) [../../src/conky.c:2399]: evaluated '${if_running xdotool}1${else}0${endif}' to '1'
xdo killed
findclient: 12585402
findclient: 12585401
DEBUG(1) [../../src/core.c:1225]: no templates to replace
DEBUG(1) [../../src/conky.c:2399]: evaluated '${updates}' to '8'
findclient: 12583169
findclient: 12583168

DEBUG(1) [../../src/core.c:1225]: no templates to replace
DEBUG(1) [../../src/conky.c:2399]: evaluated '${updates}' to '9'
findclient: 12584253
findclient: 12584252
findclient: 12585499
findclient: 12585498
findclient: 12585499
findclient: 12585498
findclient: 12585499
findclient: 12585498
findclient: 12585499
findclient: 12585498
findclient: 12585499
findclient: 12585498
findclient: 12585499
findclient: 12585498
DEBUG(1) [../../src/core.c:1225]: no templates to replace
DEBUG(1) [../../src/conky.c:2399]: evaluated '${updates}' to '10'
findclient: 12585125
findclient: 12585124
DEBUG(1) [../../src/core.c:1225]: no templates to replace
DEBUG(1) [../../src/core.c:354]: Adding $cpu for CPU 0
DEBUG(1) [../../src/conky.c:2399]: evaluated '${cpu}' to ''
DEBUG(1) [../../src/core.c:1225]: no templates to replace
DEBUG(1) [../../src/conky.c:2399]: evaluated '${processes}' to '0'
findclient: 12585499
findclient: 12585498
findclient: 12585499
findclient: 12585498
findclient: 12585499
findclient: 12585498
findclient: 12585499
findclient: 12585498
findclient: 12585499
findclient: 12585498
findclient: 12585499
findclient: 12585498
findclient: 12585499
findclient: 12585498
findclient: 12585499
findclient: 12585498
findclient: 12585499
findclient: 12585498
findclient: 12585499
findclient: 12585498
DEBUG(1) [../../src/core.c:1225]: no templates to replace
DEBUG(1) [../../src/conky.c:2399]: evaluated '${updates}' to '11'
findclient: 12583870
findclient: 12583869
DEBUG(1) [../../src/core.c:1225]: no templates to replace
DEBUG(1) [../../src/conky.c:2399]: evaluated '${updates}' to '12'
findclient: 12583870
findclient: 12583869
DEBUG(1) [../../src/core.c:1225]: no templates to replace
DEBUG(1) [../../src/conky.c:2399]: evaluated '${updates}' to '13'
findclient: 12583870
findclient: 12583869
DEBUG(1) [../../src/core.c:1225]: no templates to replace
DEBUG(1) [../../src/conky.c:2399]: evaluated '${updates}' to '14'
findclient: 12583870
findclient: 12583869
findclient: 12585499
findclient: 12585498
findclient: 12585499
findclient: 12585498
findclient: 12585499
findclient: 12585498
findclient: 12585499
findclient: 12585498
DEBUG(1) [../../src/core.c:1225]: no templates to replace
DEBUG(1) [../../src/conky.c:2399]: evaluated '${updates}' to '15'
DEBUG(1) [../../src/core.c:1225]: no templates to replace
DEBUG(1) [../../src/core.c:354]: Adding $cpu for CPU 0
DEBUG(1) [../../src/conky.c:2399]: evaluated '${cpu}' to '1'
DEBUG(1) [../../src/core.c:1225]: no templates to replace
DEBUG(1) [../../src/conky.c:2399]: evaluated '${processes}' to '146'

Second, to my surprise, this time the buttons DID show up on the screen (look inside the conky):

2014_12_07_1417990679_1600x900_scrot.jpg

They're not clickable, though, and if I move the conky around, the buttons move with it. But it's a start, isn't it? tongue

@Head_on_a_Stick: I'm sure it's easy for you, but I don't have a clue what to do with it... :8  8o

Offline

#1087 2014-12-07 23:07:20

ohnonot
...again
Registered: 2012-05-22
Posts: 2,205

Re: interactive conky

i'm sorry if i gave the impression that i have a solution to this.

all i can say, your output shows no errors, not even warnings.

@HoaS: dzen2: functionality 11 out of 10, eyecandy.... well if you call terminal colors eyecandy, say 1 out of 10.

Offline

#1088 2014-12-07 23:38:11

Inodoro Pereyra
#! Die Hard
From: Back in Buenos Aires
Registered: 2013-07-01
Posts: 844

Re: interactive conky

ohnonot wrote:

i'm sorry if i gave the impression that i have a solution to this.

all i can say, your output shows no errors, not even warnings.

Oh, ok. sad
Thank you anyway for trying...

Offline

#1089 2014-12-08 10:11:41

Head_on_a_Stick
CatMod
From: A world of pure imagination
Registered: 2014-01-21
Posts: 4,797

Re: interactive conky

ohnonot wrote:

@HoaS: dzen2: functionality 11 out of 10, eyecandy.... well if you call terminal colors eyecandy, say 1 out of 10.

I was thinking of using conky's "^ca()" attribute to hook in the dzen2 functionality while keeping conky as the display:

^ca(1,<path to dzen script>)<Button Name>^ca()

https://wiki.archlinux.org/index.php/Dz … and_popups

Offline

#1090 2014-12-08 11:33:59

Sector11
#!'er to BL'er
From: SR11 Cockpit
Registered: 2010-05-05
Posts: 15,667
Website

Re: interactive conky

Wish I knew more about LUA.  I'm at a loss here ... I just tweak them.   sad


·  ↓   ↓   ↓   ↓   ↓   ↓  ·
BunsenLabs Forums now Open for Registration
·  ↑   ↑   ↑   ↑   ↑   ↑  · BL ModSquad

Offline

#1091 2014-12-08 12:34:47

boisei0
#! CrunchBanger
From: Gaanderen, Netherlands
Registered: 2013-07-16
Posts: 193

Re: interactive conky

As a daily user/modifier of interactive Conky scripts, I'll have a look at it. Although I really like the idea of the interactive script and the work MrPeachy did to create them, I do not like his coding style. It makes it really hard to find mistakes in the code.

If I correctly remember, this is one of the older versions of the interactive Conky. You did not follow the full instructions. Try adding the line

own_window_title clicky

to your dates.conky and test again. In the version you used, the Conky name is hardcoded in the script.

You might want to debug with this slightly better readable version of clicky.lua:

--[[click with mouse over lua by mrpeachy - thanks to barrybarrykelly for the xdotool method and gmonti for finding the deb files for the xdotool
in conkyrc, in addition to regular settings:

own_window_title clicky_conky
lua_load ~/.conky/clicky.lua
lua_draw_hook_pre main
TEXT

3/13/12
]]

require 'cairo'

click_start=1-- this starts the clickfunction
buttons={}--this table initially holds the values from the buttons

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)
    local updates=tonumber(conky_parse('${updates}'))
    if updates>5 then
        --#################################################################################################
        localx,localy,localnowx,localnowy=clickfunction()--this line activates the clickfunction and sets the click coordinates
        --#################################################################################################
        --SET DEFAULTS ##########################################################
        --set defaults do not localise these defaults if you use a seperate display script
        default_font="mono"--font must be in quotes
        default_font_size=10
        default_color=0xffffff--white
        default_alpha=1--fully opaque
        default_image_width=50
        default_image_height=50
        --#################################################################################################
        --button setup - this section for an on/off button 
        local button_name="cpu"
        local blx=100.5--bottom left x coordinate of click area, the .5 makes the 1 pixel box line sharp
        local bly=100.5--bottom left x coordinate of click area
        local height=20--height of click area
        local width=30--width of click area

        --setup cpu section position, when setting up cpu function everything is relative to these points
        local cpu_blx=blx+width+2
        local cpu_bly=100.5
        local overlap=width
        --##############################################################
        --calculate if click was inside box and set actions#############
        --best to keep the button calculations seperate to the actions##
        if localx>=blx and localx<=blx+width and localy<=bly and localy>=bly-height and buttons[tostring(button_name)]~=1 then
            buttons[tostring(button_name)]=1
        elseif localx>=blx and localx<=blx+width and localy<=bly and localy>=bly-height and buttons[tostring(button_name)]==1 then
            buttons[tostring(button_name)]=0
        elseif localx<blx and localx>blx+width and localy<bly and localy>bly-height and buttons[tostring(button_name)]~=1 then
            buttons[tostring(button_name)]=0 
        end
        --end of calculations ##########################################

        --mouseover
        if buttons["coresmo"]==1 or localnowx>=blx and localnowx<=blx+width and localnowy<=bly and localnowy>=bly-height then
            if buttons[tostring(button_name)]~=1 then
                cpusection(cpu_blx,cpu_bly,overlap)
            end
        end

        if localnowx>=blx and localnowx<=blx+width and localnowy<=bly and localnowy>=bly-height then
            color={0,0,0,1}
            fill=1
            buttondraw(blx,bly,height,width,color,fill)
        end

        --##############################################################
        --button on off
        if buttons[tostring(button_name)]==1 then
            color={1,0,0,1}--if button is clicked on it will be drawn red
            fill=0
            buttondraw(blx,bly,height,width,color,fill)
            cpusection(cpu_blx,cpu_bly,overlap)
        else
            color={1,1,0,1}--if button is clicked on it will be drawn red
            fill=0
            buttondraw(blx,bly,height,width,color,fill)
        end--button on off
        out({x=105,y=95,txt="CPU"})
        --#########################################################################################################
    end-- if updates>5
    cairo_destroy(cr)
    cairo_surface_destroy(cs)
    cr=nil
end-- end main function

function cpusection(cpu_blx,cpu_bly,overlap)
    --button setup - this section for an on/off button 
    local button_name="cores"
    local blx=cpu_blx--bottom left x coordinate of click area, the .5 makes the 1 pixel box line sharp
    local bly=cpu_bly--bottom left x coordinate of click area
    local height=20--height of click area
    local width=60--width of click area
    --setup cpu section position, when setting up cpu function everything is relative to these points
    local cores_blx=blx+width+15
    local cores_bly=bly
    --##############################################################
    --calculate if click was inside box and set actions#############
    --best to keep the button calculations seperate to the actions##
    if localx>=blx and localx<=blx+width and localy<=bly and localy>=bly-height and buttons[tostring(button_name)]~=1 then
        buttons[tostring(button_name)]=1
    elseif localx>=blx and localx<=blx+width and localy<=bly and localy>=bly-height and buttons[tostring(button_name)]==1 then
        buttons[tostring(button_name)]=0
    elseif localx<blx and localx>blx+width and localy<bly and localy>bly-height and buttons[tostring(button_name)]~=1 then
        buttons[tostring(button_name)]=0 
    end
    --end of calculations ##########################################
    --mouseover
    if buttons["processmo"]==1 or localnowx>=blx-overlap and localnowx<=blx+width and localnowy<=bly and localnowy>=bly-height then
        buttons[tostring(button_name.."mo")]=1
        --buttons["cpumo"]=1
        --elseif localnowx<blx-overlap or localnowx>blx+width or localnowy>bly or localnowy<bly-height then
        --buttons[tostring(button_name.."mo")]=0
    else
        buttons[tostring(button_name.."mo")]=0
    end--mouseover

    if localnowx>=blx and localnowx<=blx+width and localnowy<=bly and localnowy>=bly-height then
        color={0,0,0,1}
        fill=1
        buttondraw(blx,bly,height,width,color,fill)
        --so that cpu isnt drawn twice
        if buttons[tostring(button_name)]~=1 then
            coressection(cores_blx,cores_bly)
        end
    end
    --##############################################################
    --button on off
    if buttons[tostring(button_name)]==1 then
        color={1,0,0,1}--if button is clicked on it will be drawn red
        fill=0
        buttondraw(blx,bly,height,width,color,fill)
        coressection(cores_blx,cores_bly)
    else
        color={0,1,1,1}
        fill=0
        buttondraw(blx,bly,height,width,color,fill)
    end--button on off
    out({x=blx+5,y=bly-5,txt="CPU%:"..conky_parse("${cpu}")})
    --##############################################################
    --##############################################################
    --##############################################################
    --##############################################################
    --##############################################################
    --button controlling processes section
    --button setup - this section for an on/off button 
    local button_name="process"
    local blx=blx--bottom left x coordinate of click area, the .5 makes the 1 pixel box line sharp
    local bly=bly+height+2--bottom left x coordinate of click area
    local height=20--height of click area
    local width=60--width of click area
    --setup cpu section position, when setting up cpu function everything is relative to these points
    local process_blx=blx+width+15
    local process_bly=bly
    --##############################################################
    --calculate if click was inside box and set actions#############
    --best to keep the button calculations seperate to the actions##
    if localx>=blx and localx<=blx+width and localy<=bly and localy>=bly-height and buttons[tostring(button_name)]~=1 then
        buttons[tostring(button_name)]=1
    elseif localx>=blx and localx<=blx+width and localy<=bly and localy>=bly-height and buttons[tostring(button_name)]==1 then
        buttons[tostring(button_name)]=0
    elseif localx<blx and localx>blx+width and localy<bly and localy>bly-height and buttons[tostring(button_name)]~=1 then
        buttons[tostring(button_name)]=0
    end
    --end of calculations ##########################################
    --mouseover
    if localnowx>=blx and localnowx<=blx+width and localnowy<=bly and localnowy>=bly-height-height then
        buttons[tostring(button_name.."mo")]=1
    elseif localnowx<blx or localnowx>blx+width or localnowy>bly or localnowy<bly-height-height then
        buttons[tostring(button_name.."mo")]=0
    end--mouseover

    if localnowx>=blx and localnowx<=blx+width and localnowy<=bly and localnowy>=bly-height then
        color={0,0,0,1}
        fill=1
        buttondraw(blx,bly,height,width,color,fill)
        --so that cpu isnt drawn twice
        if buttons[tostring(button_name)]~=1 then
            processsection(cores_blx,cores_bly)
        end
    end
    --##############################################################
    --button on off
    if buttons[tostring(button_name)]==1 then
        color={1,0,0,1}--if button is clicked on it will be drawn red
        fill=0
        buttondraw(blx,bly,height,width,color,fill)
        processsection(cores_blx,cores_bly)
    else
        color={0,1,1,1}
        fill=0
        buttondraw(blx,bly,height,width,color,fill)
    end--button on off
    out({x=blx+5,y=bly-5,txt="PRO#:"..conky_parse("${processes}")})
end--cpu section

function coressection(blx,bly)
    out({x=blx,y=bly-5,txt="CPU1:"..conky_parse("${cpu cpu1}").."%"})
    out({x=blx,y=bly+15,txt="CPU2:"..conky_parse("${cpu cpu2}").."%"})
    out({x=blx,y=bly+35,txt="CPU3:"..conky_parse("${cpu cpu3}").."%"})
    --out({c=0x00ff00,x=255,y=155,txt="CPU:"..conky_parse("${cpu cpu4}").."%"})
end--coressection

function processsection(blx,bly)
    out({x=blx+100,y=bly-5,txt="PROC1:"..conky_parse("${top name 1}")})
    out({x=blx+100,y=bly+15,txt="PROC2:"..conky_parse("${top name 2}")})
    out({x=blx+100,y=bly+35,txt="PROC3:"..conky_parse("${top name 3}")})
    --out({c=0x00ff00,x=255,y=155,txt="CPU:"..conky_parse("${cpu cpu4}").."%"})
end--coressection

--button drawing function
function buttondraw(blx,bly,height,width,color,fill)
    cairo_set_line_width (cr,1)
    cairo_set_source_rgba (cr,color[1],color[2],color[3],color[4])
    cairo_rectangle (cr,blx,bly,width,-height)
    if fill==0 then
        cairo_stroke (cr)
    elseif fill==1 then
        cairo_fill (cr)
    end
end--of buttondraw function

function xout(txj)--c,a,f,fs,x,y,txt,j ##################################################
    c=nil
    c=(txj.c or default_color)
    a=nil
    a=(txj.a or default_alpha)
    f=nil
    f=(txj.f or default_font)
    fs=nil
    fs=(txj.fs or default_font_size)
    x=nil
    x=(txj.x or 0)
    y=nil
    y=(txj.y or 0)
    txt=nil
    txt=(txj.txt or "set txt")
    j=nil
    j=(txj.j or "l")
    
    local function col(c,a)
        return ( (c/0x10000) % 0x100)/255,( (c/0x100) % 0x100)/255,(c % 0x100)/255,a
    end--local function
    
    cairo_select_font_face (cr, f, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
    cairo_set_font_size (cr, fs)
    local text=string.gsub(txt," ","_")
    extents=cairo_text_extents_t:create()
    cairo_text_extents(cr,text,extents)
    local wx=extents.width
    cairo_set_source_rgba (cr,col(c,a))
    if j=="l" then
        cairo_move_to (cr,x,y)
    adx=wx
    elseif j=="c" then
        cairo_move_to (cr,x-(wx/2),y)
        adx=wx/2
    elseif j=="r" then
        cairo_move_to (cr,x-wx,y)
        adx=0
    end
    cairo_show_text (cr,txt)
    cairo_stroke (cr)
    nextx=nil
    nextx=adx+x
    return nextx
end--function xout ###################################################################

function out(tx)--####################################################################
    c=nil
    c=(tx.c or default_color)
    a=nil
    a=(tx.a or default_alpha)
    f=nil
    f=(tx.f or default_font)
    fs=nil
    fs=(tx.fs or default_font_size)
    x=nil
    x=(tx.x or 0)
    y=nil
    y=(tx.y or 0)
    txt=nil
    txt=(tx.txt or "set txt")
    
    local function col(c,a)
        return ( (c/0x10000) % 0x100)/255,( (c/0x100) % 0x100)/255,(c % 0x100)/255,a
    end--local function
    
    cairo_select_font_face (cr, f, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
    cairo_set_font_size (cr, fs)
    cairo_set_source_rgba (cr,col(c,a))
    cairo_move_to (cr,x,y)
    cairo_show_text (cr,txt)
    cairo_stroke (cr)
end--function out ###################################################################

function image(im)--#################################################################
    x=nil
    x=(im.x or 0)
    y=nil
    y=(im.y or 0)
    w=nil
    w=(im.w or default_image_width)
    h=nil
    h=(im.h or default_image_height)
    file=nil
    file=tostring(im.file)
    if file==nil then print("set image file") end
    ---------------------------------------------
    local show = imlib_load_image(file)
    if show == nil then return end
    imlib_context_set_image(show)
    if tonumber(w)==0 then 
        width=imlib_image_get_width() 
    else
        width=tonumber(w)
    end
    if tonumber(h)==0 then 
        height=imlib_image_get_height() 
    else
        height=tonumber(h)
    end
    imlib_context_set_image(show)
    local scaled=imlib_create_cropped_scaled_image(0, 0, imlib_image_get_width(), imlib_image_get_height(), width, height)
    imlib_free_image()
    imlib_context_set_image(scaled)
    imlib_render_image_on_drawable(x, y)
    imlib_free_image()
    show=nil
end--function image ##################################################################

--clickfunction, this runs xdotool and xwininfo and reads the coordinates of clicks
function clickfunction()
    --start click logging and calculations ##########################################
    if click_start==1 then
        xdot=conky_parse("${if_running xdotool}1${else}0${endif}")
        if tonumber(xdot)==1 then
            os.execute("killall xdotool && echo 'xdo killed' &")
        end
        os.execute("xdotool search --name 'clicky' behave %@ mouse-click getmouselocation >> /tmp/xdo &")
        local f = io.popen("xwininfo -name 'clicky' | grep 'Absolute'")
        geometry = f:read("*a")
        f:close()
        local geometry=string.gsub(geometry,"[\n]","")
        s,f,abstlx=string.find(geometry,"X%p%s*(%d*)")
        s,f,abstly=string.find(geometry,"Y%p%s*(%d*)")
        click_start=nil
    end--if click_start=1 ######################################
    --click calculations #################################
    local f=io.open("/tmp/xdo")
    click=f:read()
    f:close()
    if click~=nil then
        local f = io.open("/tmp/xdo","w")
        f:write("")
        f:close() 
    end--if click=nil
    if click==nil then click="x:0 y:0 " end
    --print (click)
    local s,f,mousex=string.find(click,"x%p(%d*)%s")
    local s,f,mousey=string.find(click,"y%p(%d*)%s")
    localx=tonumber(mousex)-abstlx
    localy=tonumber(mousey)-abstly
    --get now location
    os.execute("xdotool getmouselocation > /tmp/xdonow ")
    local f=io.open("/tmp/xdonow")
    mousenow=f:read()
    f:close()
    local s,f,mousenowx=string.find(mousenow,"x%p(%d*)%s")
    local s,f,mousenowy=string.find(mousenow,"y%p(%d*)%s")
    localnowx=tonumber(mousenowx)-abstlx
    localnowy=tonumber(mousenowy)-abstly
    --END CLICK CALCULATIONS #################################
    return localx,localy,localnowx,localnowy
end--function

YAWS (cli weather script with conkyForecast syntax) | Bitbucket | Github | Blog
Member of the Unofficial #! Emergency Tinfoil Hat Distribution Center
Emergency Tinfoil Hat Conky Alert System development team

Offline

#1092 2014-12-08 13:55:28

Sector11
#!'er to BL'er
From: SR11 Cockpit
Registered: 2010-05-05
Posts: 15,667
Website

Re: interactive conky

@ ohnonot

I quoted you herebig_smile
Have coffee - bring mug.


·  ↓   ↓   ↓   ↓   ↓   ↓  ·
BunsenLabs Forums now Open for Registration
·  ↑   ↑   ↑   ↑   ↑   ↑  · BL ModSquad

Offline

#1093 2014-12-08 21:26:10

Inodoro Pereyra
#! Die Hard
From: Back in Buenos Aires
Registered: 2013-07-01
Posts: 844

Re: interactive conky

@Boisei0: I replaced the clicky.lua with yours. so far, no difference.
The window_title clicky line is already there, and the conky is not being forked to background.
I'm running it with

conky -D -c /home/bernardo/.conky/dates.conky

and gives me no error codes, yet there's no button showing on the screen, and, of course, nothing is clickable.

Now, I have a question: should I add/change anything to the lua script, or should I use it just as it is?

Offline

#1094 2014-12-08 21:34:24

Naik
#! Die Hard
From: Leipzig
Registered: 2012-11-16
Posts: 595

Re: interactive conky

Only a thought, but

Inodoro Pereyra`s Conky -D wrote:

[...]
DEBUG(1) [../../src/conky.c:2399]: evaluated '${if_running xdotool}1${else}0${endif}' to '1'
xdo killed
[...]

Is it intended to kill xdo? I think it isn`t...

naik --greetz


*kaum macht man es richtig, funktioniert es sofort*

Offline

#1095 2014-12-08 22:16:06

Inodoro Pereyra
#! Die Hard
From: Back in Buenos Aires
Registered: 2013-07-01
Posts: 844

Re: interactive conky

Naik wrote:

Only a thought, but

Inodoro Pereyra`s Conky -D wrote:

[...]
DEBUG(1) [../../src/conky.c:2399]: evaluated '${if_running xdotool}1${else}0${endif}' to '1'
xdo killed
[...]

Is it intended to kill xdo? I think it isn`t...

naik --greetz

I... don't know what you're talking about. :8

My terminal output when I just ran the conky with Boisei0's lua is:

bernardo@bernardo:~$ killall conky
Conky: received SIGINT or SIGTERM to terminate. bye!
bernardo@bernardo:~$ conky -D -c /home/bernardo/.conky/dates.conky
DEBUG(0) [../../src/conky.c:5338]: reading contents from config file '/home/bernardo/.conky/dates.conky'
Conky: desktop window (131) is root window
DEBUG(0) [../../src/x11.c:240]: Found ARGB Visual
Conky: window type - normal
Conky: drawing to created window (0x1a00002)
Conky: drawing to double buffer
^CConky: received SIGINT or SIGTERM to terminate. bye!
[1]+  Done                    killall conky && conky -c /home/bernardo/.conky/dates.conky
bernardo@bernardo:~$ 

At the same time, I found no lines in the lua script like the one you posted...  sad

Offline

#1096 2014-12-09 10:04:11

boisei0
#! CrunchBanger
From: Gaanderen, Netherlands
Registered: 2013-07-16
Posts: 193

Re: interactive conky

In this version of the script, xdotool is not stopped when closing the Conky. Instead, it checks at the start if xdotool is (still) running. If yes, it is killed, then restarted. Relevant code starting at line 339:

    if click_start==1 then
        xdot=conky_parse("${if_running xdotool}1${else}0${endif}")
        if tonumber(xdot)==1 then
            os.execute("killall xdotool && echo 'xdo killed' &")
        end
        os.execute("xdotool search --name 'clicky' behave %@ mouse-click getmouselocation >> /tmp/xdo &")

In one of the later versions, like posted somewhere near page 8 13, if I recall correctly, there are functions called conky_start_xdo and conky_stop_xdo:

function conky_start_xdo(rc_info)
	click_data_file=rc_info or click_data_file
	os.execute("pkill -f 'xdotool search --sync --classname conky behave %@ mouse-click getmouselocation'")
	os.execute("xdotool search --sync --classname 'conky' behave %@ mouse-click getmouselocation 2> /dev/null >> "..click_data_file.." &")
	rc_info=nil
end--of function start_xdo

function conky_stop_xdo()
	os.execute("pkill -f 'xdotool search --sync --classname conky behave %@ mouse-click getmouselocation'")
end--of function stop_xdo

They are called with a hook from the conky itself:

lua_startup_hook start_xdo /tmp/xdo
lua_shutdown_hook stop_xdo

You might want to search for the newer version, and modify your script to use that one. I did modify the original button script heavily, and do not have a 'blank' one available.

Last edited by boisei0 (2014-12-09 10:36:43)


YAWS (cli weather script with conkyForecast syntax) | Bitbucket | Github | Blog
Member of the Unofficial #! Emergency Tinfoil Hat Distribution Center
Emergency Tinfoil Hat Conky Alert System development team

Offline

#1097 2014-12-10 02:05:58

Inodoro Pereyra
#! Die Hard
From: Back in Buenos Aires
Registered: 2013-07-01
Posts: 844

Re: interactive conky

Thank you Boisei0 (and everybody) for the replies.

I downloaded the files on page 13, post #322. Now, I've been trying to follow the instructions to set those files up, especially the buttons.lua, with no success whatsoever. So I have a few questions.
But first, I apologize if those questions seem stupid to you guys. I'm not a programmer, just a regular end user, and, to be honest, that how-to seems aimed at people who wouldn't need it to start with (at least from my absolutely uninformed point of view).

Either way, here we go (I'm gonna number the questions, so it's easier for you to answer them):

This is the buttons.lua script:

--[[buttons by mrpeachy - thanks to barrybarrykelly for the xdotool method, gmonti for finding the deb files for the xdotool and arclance for xdotool error catching
see here for instructions: http://crunchbanglinux.org/forums/post/245759/#p245759
]]

conky_name="interactiveconkyrc"
click_data_file ="/home/mcdowall/Dropbox/Public/interactive_conky/xdo"

--setup buttons here
function button_settings()


end--function button_settings

require 'cairo'
require 'imlib2'
function conky_start_xdo(rc_info)--######################################################################################################################
click_data_file=rc_info or click_data_file
os.execute("pkill -f 'xdotool search --sync --classname conky behave %@ mouse-click getmouselocation'")
os.execute("xdotool search --sync --classname 'conky' behave %@ mouse-click getmouselocation 2> /dev/null >> "..click_data_file.." &")
rc_info=nil
end--of function ##################################################################################################################################

function conky_stop_xdo()--######################################################################################################################
os.execute("pkill -f 'xdotool search --sync --classname conky behave %@ mouse-click getmouselocation'")
end--of function ##################################################################################################################################

buttons={}--######################################################################################################################################
click_table={}--##################################################################################################################################
start=1
function conky_get_mouse(rc_info)--###############################################################################################################
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 rc_info~=nil then
rc_info=loadstring("return" .. rc_info)()
end
--start click logging and calculations #####################################
--##########################################################################
if start==1 then
current_update=tonumber(conky_parse("${updates}"))
start=0
end
local updates=tonumber(conky_parse("${updates}"))
if updates==(current_update or 0)+5 then
local click_data_file=rc_info[2] or click_data_file
local conky_name=rc_info[1] or conky_name
print ("own_window_title="..conky_name)
local f=io.popen("xwininfo -all -int -tree -name '"..conky_name.."'")
windata = f:read("*a")
f:close()
local windata=string.lower(windata)
local s,f,x=string.find(windata,"absolute%supper%pleft%sx%p%s*(%p*%d*)")
local s,f,y=string.find(windata,"absolute%supper%pleft%sy%p%s*(%p*%d*)")
local s,f,p=string.find(windata,"parent%swindow%sid%p%s(%d*)%s")
local s,f,w=string.find(windata,"xwininfo%p%swindow%sid%p%s(%d*)%s")
xwin={x,y,p,w,click_data_file}--don't blank with nil
print (xwin[1],xwin[2],xwin[3],xwin[4],xwin[5])
elseif updates<(current_update or 0)+5 then
local click_data_file=rc_info[2] or click_data_file
xwin={0,0,0,0,click_data_file}
end--if updates== ###########################################################
--click calculations ########################################################
--get now location and window id ############################################
local f = io.popen("xdotool getmouselocation 2> /dev/null")
mousenow=(f:read())
f:close()
local mousenow=string.lower(mousenow or "x:0 y:0 window:0 ")
local s,f,mousenowx=string.find(mousenow,"x%p(%d*)%s")
local s,f,mousenowy=string.find(mousenow,"y%p(%d*)%s")
local s,f,xwinid=string.find(mousenow,"window%p(%d*)")
local localnowx=(tonumber(mousenowx) or 0)-xwin[1]
local localnowy=(tonumber(mousenowy) or 0)-xwin[2]
--read file if windowid matches
if tonumber(xwin[3])==tonumber(xwinid) or tonumber(xwin[4])==tonumber(xwinid) then
	local f = io.open(xwin[5])
        click = f:read()
        f:close()
	--get click location
	if click==nil then click="x:0 y:0 window:0 " else print (click) end
	local s,f,mousex=string.find(click,"x%p(%d*)%s")
	local s,f,mousey=string.find(click,"y%p(%d*)%s")
	local localx=(tonumber(mousex) or 0)-xwin[1]
	local localy=(tonumber(mousey) or 0)-xwin[2]
	click_table[1]=localx
	click_table[2]=localy
	click_table[3]=localnowx
	click_table[4]=localnowy
	click=nil
	--blank file
	local f = io.open(xwin[5],"w")
	f:write("")
	f:close() 
else
	click_table[1]=0
	click_table[2]=0
	click_table[3]=0
	click_table[4]=0
end--window id matching
button_settings()
mousenow=nil
windata=nil
rc_info=nil
f=nil
cairo_destroy(cr)
cairo_surface_destroy(cs)
cr=nil
return ""
end-- end getmouse function ######################################################################################################################
--################################################################################################################################################

function do_button(bd)
if bd.btype==nil then
bd=loadstring("return" .. bd)()
end
local localx=click_table[1]	or 0
local localy=click_table[2]	or 0
local localnowx=click_table[3]	or 0
local localnowy=click_table[4]	or 0
local button_name=bd.bname
local st_type=bd.st_type	or 0
local btype=bd.btype		or 1
local on_on_on=bd.on_on_on	or {}
local on_on_off=bd.on_on_off	or {}
local off_on_on=bd.off_on_on	or {}
local off_on_off=bd.off_on_off	or {}
local return_co=bd.return_co	or 0
--#####################################
--#####################################
--initialize button
if buttons[tostring(button_name)]==nil then
	if btype~=4 and st_type==0 then --button is off on start
	buttons[tostring(button_name)]=0
	elseif btype~=4 and st_type==1 then --button is on on start
	buttons[tostring(button_name)]=1
	elseif btype==4 then
	buttons[tostring(button_name)]=1
	end
end
--set mouse point type
if btype==1 or btype==3 or btype==4 then
--on off execute or cycle
localx=localx
localy=localy
elseif btype==2 then
--mouse over
localx=localnowx
localy=localnowy
else
print ("button type not set")
end
--set click area if on or off
if btype~=4 and buttons[tostring(button_name)]==0 then
--button is off
blx=bd.blx_off
bly=bd.bly_off
bw=bd.bw_off
bh=bd.bh_off
elseif btype~=4 and buttons[tostring(button_name)]==1 then
--button is on
blx=bd.blx_on or bd.blx_off
bly=bd.bly_on or bd.bly_off
bw=bd.bw_on or bd.bw_off
bh=bd.bh_on or bd.bh_off
elseif btype==4 then
local blxt=bd.blx_cyc
local blyt=bd.bly_cyc
local bwt=bd.bw_cyc
local bht=bd.bh_cyc
local cynum=bd.cynum
local set=tonumber(buttons[tostring(button_name)])
blx=blxt[set] or blxt[#blxt]
bly=blyt[set] or blyt[#blyt]
bw=bwt[set] or bwt[#bwt]
bh=bht[set] or bht[#bht]
end
--set mechanism based on button type
if btype==1 then --on off ##############################################################
--if click is inside box and button is not on - turn on
if localx>=blx and localx<=blx+bw and localy<=bly and localy>=bly-bh and buttons[tostring(button_name)]~=1 then
buttons[tostring(button_name)]=1
--turn on other buttons as set
	for i=1,#on_on_on do
	buttons[tostring(on_on_on[i])]=1
	end
--turn off other buttons as set
	for i=1,#off_on_on do
	buttons[tostring(off_on_on[i])]=0
	end
--if click is inside box and button is on - turn off
elseif localx>=blx and localx<=blx+bw and localy<=bly and localy>=bly-bh and buttons[tostring(button_name)]==1 then
buttons[tostring(button_name)]=0
--turn off other buttons as set
	for i=1,#off_on_off do
	buttons[tostring(off_on_off[i])]=0
	end
--turn on other buttons as set
	for i=1,#on_on_off do
	buttons[tostring(on_on_off[i])]=1
	end
end
end --if btype==1###################################################################
if btype==2 then --mouse over ##############################################################
--if mouse is inside box
if localx>=blx and localx<=blx+bw and localy<=bly and localy>=bly-bh then
buttons[tostring(button_name)]=1
--turn on other buttons as set
	for i=1,#on_on_on do
	buttons[tostring(on_on_on[i])]=1
	end
--turn off other buttons as set
	for i=1,#off_on_on do
	buttons[tostring(off_on_on[i])]=0
	end
--if click is inside box and button is on - turn off
else --mouse is outside
buttons[tostring(button_name)]=0
--turn off other buttons as set
	for i=1,#off_on_off do
	buttons[tostring(off_on_off[i])]=0
	end
--turn on other buttons as set
	for i=1,#on_on_off do
	buttons[tostring(on_on_off[i])]=1
	end
end --if mouse inside
end --if btype==3###################################################################
if btype==3 then --execte ##############################################################
--if mouse click is inside box
if localx>=blx and localx<=blx+bw and localy<=bly and localy>=bly-bh then
buttons[tostring(button_name)]=1
--turn on other buttons as set
	for i=1,#on_on_on do
	buttons[tostring(on_on_on[i])]=1
	end
--turn off other buttons as set
	for i=1,#off_on_on do
	buttons[tostring(off_on_on[i])]=0
	end
--if click is inside box and button is on - turn off
else --mouse click is outside
buttons[tostring(button_name)]=0
--turn off other buttons as set
	for i=1,#off_on_off do
	buttons[tostring(off_on_off[i])]=0
	end
--turn on other buttons as set
	for i=1,#on_on_off do
	buttons[tostring(on_on_off[i])]=1
	end
end--if click inside
end --if btype==3###################################################################
if btype==4 then --cycle ##############################################################
local cynum=bd.cynum
--if mouse click is inside box
	if localx>=blx and localx<=blx+bw and localy<=bly and localy>=bly-bh then
		if buttons[tostring(button_name)]+1>cynum then
		buttons[tostring(button_name)]=1
		else
		buttons[tostring(button_name)]=buttons[tostring(button_name)]+1
		end
	end--if click inside
end --if btype==4###################################################################
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
--draw #############################################################################
local draw=bd.draw or 0
if draw==1 then--#########################################################################################
--set variables if button on or off
if btype~=4 and buttons[tostring(button_name)]==0 then
dtype=bd.dtype_off  or 1
--fill when off
dfblx=bd.dfxadj_off or 0
dfbly=bd.dfyadj_off or 0
dfw=bd.dfw_off      or bw
dfh=bd.dfh_off      or bh
dfcr=bd.dfcr_off    or 0
dfcol=bd.dfcol_off  or 0xffffff
dfal=bd.dfal_off    or 1
--outline when off
doblx=bd.doxadj_off or 0
dobly=bd.doyadj_off or 0
dow=bd.dow_off      or bw
doh=bd.doh_off      or bh
docr=bd.docr_off    or 0
docol=bd.docol_off  or 0xffffff
doal=bd.doal_off    or 1
dolw=bd.dolw_off    or 1
elseif btype~=4 and buttons[tostring(button_name)]==1 then--draw on and button on
dtype=bd.dtype_on  or bd.dtype_off or 1
--fill when on
dfblx=bd.dfxadj_on or 0
dfbly=bd.dfyadj_on or 0
dfw=bd.dfw_on      or bw
dfh=bd.dfh_on      or bh
dfcr=bd.dfcr_on    or 0
dfcol=bd.dfcol_on  or 0xff0000
dfal=bd.dfal_on    or 1
--outline when on
doblx=bd.doxadj_on or 0
dobly=bd.doyadj_on or 0
dow=bd.dow_on      or bw
doh=bd.doh_on      or bh
docr=bd.docr_on    or 0 
docol=bd.docol_on  or 0xff0000
doal=bd.doal_on    or 1
dolw=bd.dolw_on    or 1
--###########################################
elseif btype==4 then --#######################
--###########################################
local cynum=bd.cynum
local set=tonumber(buttons[tostring(button_name)])
--set draw type
dtypet=bd.dtype_cyc or {1}
dtype=dtypet[set] or dtypet[#dtypet]
--fill cycle
local dfblxt=bd.dfxadj_cyc or {0}
local dfblyt=bd.dfyadj_cyc or {0}
local dfwt=bd.dfw_cyc      or {bw}
local dfht=bd.dfh_cyc      or {bh}
local dfcrt=bd.dfcr_cyc    or {0}
local dfcolt=bd.dfcol_cyc  or {0xffffff}
local dfalt=bd.dfal_cyc    or {1}
dfblx=dfblxt[set] or dfblxt[#dfblxt] or 0
dfbly=dfblyt[set] or dfblyt[#dfblyt] or 0
dfw=dfwt[set]     or dfwt[#dfwt]     or bw
dfh=dfht[set]     or dfht[#dfht]     or bh
dfcr=dfcrt[set]   or dfcrt[#dfcrt]   or 0
dfcol=dfcolt[set] or dfcolt[#dfcolt] or 0xffffff
dfal=dfalt[set]   or dfalt[#dfalt]   or 1
--outline cycle
local doblxt=bd.doxadj_off or {0}
local doblyt=bd.doyadj_off or {0}
local dowt=bd.dow_off      or {bw}
local doht=bd.doh_off      or {bh}
local docrt=bd.docr_off    or {0}
local docolt=bd.docol_off  or {0xffffff}
local doalt=bd.doal_off    or {1}
local dolwt=bd.dolw_off    or {1}    
doblx=doblxt[set] or doblxt[#doblxt] or 0
dobly=doblyt[set] or doblyt[#doblyt] or 0
dow=dowt[set]     or dowt[#dowt]     or bw
doh=doht[set]     or doht[#doht]     or bh
docr=docrt[set]   or docrt[#docrt]   or 0
docol=docolt[set] or docolt[#docolt] or 0xff0000
doal=doalt[set]   or doalt[#doalt]   or 1
dolw=dolwt[set]   or dolwt[#dolwt]   or 1
else
print ("error4")
end--check btype and button on off
--##########################
--draw based on type
if dtype==1 then
--top left mid circle
local xtl=blx+dfblx+dfcr
local ytl=bly+dfbly-(dfh-dfcr)
--top right mid circle
local xtr=xtl+(dfw-(dfcr*2))
local ytr=ytl
--bottom right mid circle
local xbr=xtr
local ybr=bly+dfbly-dfcr
--bottom left mid circle
local xbl=xtl
local ybl=ybr
--the drawing part---------------------------
cairo_move_to (cr,xtl,ytl-dfcr)
cairo_line_to (cr,xtr,ytr-dfcr)
cairo_arc(cr,xtr,ytr,dfcr,((2*math.pi/4)*3),((2*math.pi/4)*4))
cairo_line_to (cr,xbr+dfcr,ybr)
cairo_arc(cr,xbr,ybr,dfcr,((2*math.pi/4)*4),((2*math.pi/4)*1))
cairo_line_to (cr,xbl,ybl+dfcr)
cairo_arc(cr,xbl,ybl,dfcr,((2*math.pi/4)*1),((2*math.pi/4)*2))
cairo_line_to (cr,xtl-dfcr,ytl)
cairo_arc(cr,xtl,ytl,dfcr,((2*math.pi/4)*2),((2*math.pi/4)*3))
cairo_close_path(cr)
cairo_set_source_rgba (cr,rgb_to_r_g_b({dfcol,dfal}))
cairo_fill (cr)
elseif dtype==2 then
--top left mid circle
local xtl=blx+doblx+docr
local ytl=bly+dobly-(doh-docr)
--top right mid circle
local xtr=xtl+(dow-(docr*2))
local ytr=ytl
--bottom right mid circle
local xbr=xtr
local ybr=bly+dobly-docr
--bottom left mid circle
local xbl=xtl
local ybl=ybr
--the drawing part---------------------------
cairo_move_to (cr,xtl,ytl-docr)
cairo_line_to (cr,xtr,ytr-docr)
cairo_arc(cr,xtr,ytr,docr,((2*math.pi/4)*3),((2*math.pi/4)*4))
cairo_line_to (cr,xbr+docr,ybr)
cairo_arc(cr,xbr,ybr,docr,((2*math.pi/4)*4),((2*math.pi/4)*1))
cairo_line_to (cr,xbl,ybl+docr)
cairo_arc(cr,xbl,ybl,docr,((2*math.pi/4)*1),((2*math.pi/4)*2))
cairo_line_to (cr,xtl-docr,ytl)
cairo_arc(cr,xtl,ytl,docr,((2*math.pi/4)*2),((2*math.pi/4)*3))
cairo_close_path(cr)
cairo_set_source_rgba (cr,rgb_to_r_g_b({docol,doal}))
cairo_set_line_width (cr,dolw)
cairo_stroke (cr)
elseif dtype==3 then
--top left mid circle
local xtl=blx+dfblx+dfcr
local ytl=bly+dfbly-(dfh-dfcr)
--top right mid circle
local xtr=xtl+(dfw-(dfcr*2))
local ytr=ytl
--bottom right mid circle
local xbr=xtr
local ybr=bly+dfbly-dfcr
--bottom left mid circle
local xbl=xtl
local ybl=ybr
--the drawing part---------------------------
cairo_move_to (cr,xtl,ytl-dfcr)
cairo_line_to (cr,xtr,ytr-dfcr)
cairo_arc(cr,xtr,ytr,dfcr,((2*math.pi/4)*3),((2*math.pi/4)*4))
cairo_line_to (cr,xbr+dfcr,ybr)
cairo_arc(cr,xbr,ybr,dfcr,((2*math.pi/4)*4),((2*math.pi/4)*1))
cairo_line_to (cr,xbl,ybl+dfcr)
cairo_arc(cr,xbl,ybl,dfcr,((2*math.pi/4)*1),((2*math.pi/4)*2))
cairo_line_to (cr,xtl-dfcr,ytl)
cairo_arc(cr,xtl,ytl,dfcr,((2*math.pi/4)*2),((2*math.pi/4)*3))
cairo_close_path(cr)
cairo_set_source_rgba (cr,rgb_to_r_g_b({dfcol,dfal}))
cairo_fill (cr)
--top left mid circle
local xtl=blx+doblx+docr
local ytl=bly+dobly-(doh-docr)
--top right mid circle
local xtr=xtl+(dow-(docr*2))
local ytr=ytl
--bottom right mid circle
local xbr=xtr
local ybr=bly+dobly-docr
--bottom left mid circle
local xbl=xtl
local ybl=ybr
--the drawing part---------------------------
cairo_move_to (cr,xtl,ytl-docr)
cairo_line_to (cr,xtr,ytr-docr)
cairo_arc(cr,xtr,ytr,docr,((2*math.pi/4)*3),((2*math.pi/4)*4))
cairo_line_to (cr,xbr+docr,ybr)
cairo_arc(cr,xbr,ybr,docr,((2*math.pi/4)*4),((2*math.pi/4)*1))
cairo_line_to (cr,xbl,ybl+docr)
cairo_arc(cr,xbl,ybl,docr,((2*math.pi/4)*1),((2*math.pi/4)*2))
cairo_line_to (cr,xtl-docr,ytl)
cairo_arc(cr,xtl,ytl,docr,((2*math.pi/4)*2),((2*math.pi/4)*3))
cairo_close_path(cr)
cairo_set_source_rgba (cr,rgb_to_r_g_b({docol,doal}))
cairo_set_line_width (cr,dolw)
cairo_stroke (cr)
end
end--if draw=1 #################################################################################
local image=bd.image or 0
if image==1 then--##############################################################################
if btype~=4 and buttons[tostring(button_name)]==0 then
file=tostring(bd.im_file_off)
if file==nil then print("set image file") end
local show = imlib_load_image(file)
if show == nil then return end
imlib_context_set_image(show)
	if tonumber(bw)==0 then 
	width=imlib_image_get_width() 
	end
	if tonumber(bh)==0 then 
	height=imlib_image_get_height() 
	end
imlib_context_set_image(show)
local scaled=imlib_create_cropped_scaled_image(0, 0, imlib_image_get_width(), imlib_image_get_height(), bw, bh)
imlib_free_image()
imlib_context_set_image(scaled)
imlib_render_image_on_drawable(blx, bly-bh)
imlib_free_image()
show=nil
elseif btype~=4 and buttons[tostring(button_name)]==1 then
file=tostring(bd.im_file_on)
if file==nil then print("set image file") end
---------------------------------------------
local show = imlib_load_image(file)
if show == nil then return end
imlib_context_set_image(show)
	if tonumber(bw)==0 then 
	width=imlib_image_get_width() 
	end
	if tonumber(bh)==0 then 
	height=imlib_image_get_height() 
	end
imlib_context_set_image(show)
local scaled=imlib_create_cropped_scaled_image(0, 0, imlib_image_get_width(), imlib_image_get_height(), bw, bh)
imlib_free_image()
imlib_context_set_image(scaled)
imlib_render_image_on_drawable(blx, bly-bh)
imlib_free_image()
show=nil
elseif btype==4 then
local cynum=bd.cynum
local set=tonumber(buttons[tostring(button_name)])
local file=bd.im_file_cyc or {}
file=file[set]
if file==nil then print("set image file") end
---------------------------------------------
local show = imlib_load_image(file)
if show == nil then return end
imlib_context_set_image(show)
	if tonumber(bw)==0 then 
	width=imlib_image_get_width() 
	end
	if tonumber(bh)==0 then 
	height=imlib_image_get_height() 
	end
imlib_context_set_image(show)
local scaled=imlib_create_cropped_scaled_image(0, 0, imlib_image_get_width(), imlib_image_get_height(), bw, bh)
imlib_free_image()
imlib_context_set_image(scaled)
imlib_render_image_on_drawable(blx, bly-bh)
imlib_free_image()
show=nil
end--btype test
end--if image ##################################################################################
local text=bd.text
if text==1 then --##############################################################################
--set variables if button on or off
if btype~=4 and buttons[tostring(button_name)]==0 then
local txt=bd.txt_off   or {"text"}
local font=bd.font_off or {"mono"}
local fs=bd.fs_off     or {12}
local fx=bd.fxadj_off  or {0}
local fy=bd.fyadj_off  or {0}
local fcol=bd.fcol_off or {0x000000}
local fal=bd.fal_off   or {1}
	for i=1,#txt do
	cairo_select_font_face (cr, font[i] or font[#font], CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
	cairo_set_font_size (cr, fs[i] or fs[#fs])
	cairo_set_source_rgba (cr,rgb_to_r_g_b({fcol[i] or fcol[#fcol],fal[i] or fal[#fal]}))
	cairo_move_to (cr,blx+(fx[i] or fx[#fx]),bly+(fy[i] or fy[#fy]))
	cairo_show_text (cr, txt[i] or txt[#txt])
	cairo_stroke (cr)
	end
elseif btype~=4 and buttons[tostring(button_name)]==1 then
local txt=bd.txt_on   or bd.txt_off   or {"text"}
local font=bd.font_on or bd.font_off  or {"mono"}
local fs=bd.fs_on     or bd.fs_off    or {12}
local fx=bd.fxadj_on  or bd.fxadj_off or {0}
local fy=bd.fyadj_on  or bd.fyadj_off or {0}
local fcol=bd.fcol_on or bd.fcol_off  or {0x000000}
local fal=bd.fal_on   or bd.fal_off   or {1}
	for i=1,#txt do
	cairo_select_font_face (cr, font[i] or font[#font], CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
	cairo_set_font_size (cr, fs[i] or fs[#fs])
	cairo_set_source_rgba (cr,rgb_to_r_g_b({fcol[i] or fcol[#fcol],fal[i] or fal[#fal]}))
	cairo_move_to (cr,blx+(fx[i] or fx[#fx]),bly+(fy[i] or fy[#fy]))
	cairo_show_text (cr, txt[i] or txt[#txt])
	cairo_stroke (cr)
	end
elseif btype==4 then
--text for cycle trype button
--into tables round 1
local cynum=bd.cynum
local set=tonumber(buttons[tostring(button_name)])
local txtt=bd.txt_cyc   or {{"text"}}
local fontt=bd.font_cyc or {{"mono"}}
local fst=bd.fs_cyc     or {{12}}
local fxt=bd.fxadj_cyc  or {{0}}
local fyt=bd.fyadj_cyc  or {{0}}
local fcolt=bd.fcol_cyc or {{0x000000}}
local falt=bd.fal_cyc   or {{1}}
--into tables round 2
local txt=txtt[set]    or txtt[#txtt]
local font=fontt[set]  or fontt[#fontt]
local fs=fst[set]      or fst[#fst]
local fx=fxt[set]      or fxt[#fxt]
local fy=fyt[set]      or fyt[#fyt]
local fcol=fcolt[set]  or fcolt[#fcolt]
local fal=falt[set]    or falt[#falt]
	for i=1,#txt do
	cairo_select_font_face (cr, font[i] or font[#font], CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
	cairo_set_font_size (cr, fs[i] or fs[#fs])
	cairo_set_source_rgba (cr,rgb_to_r_g_b({fcol[i] or fcol[#fcol],fal[i] or fal[#fal]}))
	cairo_move_to (cr,blx+(fx[i] or fx[#fx]),bly+(fy[i] or fy[#fy]))
	cairo_show_text (cr, txt[i] or txt[#txt])
	cairo_stroke (cr)
	end
else
print ("error with text")
end--if buttons[]==0
end--if text==1 ################################################################################
--##############################################################################################
if return_co==0 then
return tonumber(buttons[tostring(button_name)])
elseif return_co==1 then
return tonumber(buttons[tostring(button_name)]),localnowx,localnowy
end--return settings
end-- end button calculations function #################################
--######################################################################

function conky_rc_button(bd)--function to setup button in conkyrc
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)
local updates=tonumber(conky_parse('${updates}'))
if updates>5 then
--###################################
send=do_button(bd)
--###################################
end--if updates>3
cairo_destroy(cr)
cairo_surface_destroy(cs)
cr=nil
return send or 0
end-- end main function

Now, on the how to:

conky_data_file is the location of the file that contains the xdotool click logging data

1. How do I find that file?

SETTINGS
here i will list, with a short description all the available options

MINIMUM REQUIRED SETTINGS
btype=1, --type, 1=on/off, 2=mouse over, 3=execute, 4=cycle
bname="test1", --set button name unique for each button
blx_off=200, --xpos when off
bly_off=200, --ypos when off
bw_off=100, --height when off
bh_off=100, --width when off

2. WHERE do those settings go?
3. Sould I add the setting to a given line, or should I replace it, partially or totally?

4. Can I setup more than one button (to activate different conkys) with only one lua, or do I have to have a different lua for each conky.
5. If I can use one lua for more than one conky, how do I do it? Do I have to replicate a section of the lua, to create different buttons? If that's a yes, which section should I replicate?

Thank you all again for your patience. Now, don't get scared, but there may be more questions comin'... wink

Offline

#1098 2014-12-10 03:16:48

Sector11
#!'er to BL'er
From: SR11 Cockpit
Registered: 2010-05-05
Posts: 15,667
Website

Re: interactive conky

EDIT - never mind I see you addressed this.  I must get to bed.

Inodoro Pereyra wrote:

This is the buttons.lua script:

--[[buttons by mrpeachy - thanks to barrybarrykelly for the xdotool method, gmonti for finding the deb files for the xdotool and arclance for xdotool error catching
see here for instructions: http://crunchbanglinux.org/forums/post/245759/#p245759
]]

conky_name="interactiveconkyrc"
click_data_file ="/home/mcdowall/Dropbox/Public/interactive_conky/xdo"

--setup buttons here
function button_settings()

Can't even answer your questions ... but I do see one OOPS! above ... this line:

click_data_file ="/home/mcdowall/Dropbox/Public/interactive_conky/xdo"

bold italics are mine - and that can't be right.

Last edited by Sector11 (2014-12-10 03:32:28)


·  ↓   ↓   ↓   ↓   ↓   ↓  ·
BunsenLabs Forums now Open for Registration
·  ↑   ↑   ↑   ↑   ↑   ↑  · BL ModSquad

Offline

#1099 2014-12-10 03:22:26

Inodoro Pereyra
#! Die Hard
From: Back in Buenos Aires
Registered: 2013-07-01
Posts: 844

Re: interactive conky

Sector11 wrote:

Can't even answer your questions ... but I do see one OOPS! above ... this line:

click_data_file ="/home/mcdowall/Dropbox/Public/interactive_conky/xdo"

bold italics are mine - and that can't be right.

That's the way it comes out of the box (the dropbox... get it wink), haven't done anything on that lua yet.

Offline

Help fund CrunchBang, donate to the project!

#1100 2014-12-10 07:40:36

ohnonot
...again
Registered: 2012-05-22
Posts: 2,205

Re: interactive conky

Sector11 wrote:

@ ohnonot

I quoted you herebig_smile
Have coffee - bring mug.

...and i answered there!

(maybe inodoro pereyra also wants to read that to avoid misunderstandings about my previous advice)

Last edited by ohnonot (2014-12-10 07:41:45)

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.
Server: acrobat

Debian Logo