You are not logged in.
carbon
x11-utils and xdotools are installed.
My question is whether it is possible to simulate a left mouse click in the terminal.
Which command would accomplish/record this task?
The background to my question is @loutch's concern that the click behavior in conky no longer functions.
Test:
xdotool getmouselocation
x:1382 y:291 screen:0 window:4209106
xwininfo -name '"..conky_name.."' | grep 'Absolute'
xwininfo: error: No window with name ""..conky_name.."" exists!
Last edited by unklar (2025-08-18 09:35:19)
Offline
Here is a short script for left-clicking on a YAD window:
https://forums.bunsenlabs.org/viewtopic … 03#p144703
See also:
https://forums.bunsenlabs.org/viewtopic … 23#p144723
If people would know how little brain is ruling the world, they would die of fear.
Offline
Thank you very much, @marens.
That works here in principle.
I achieved this result with xwininfo on a test Conky using the click function. So everything is fine on the x11-utils and xdotools side. The conky window ‘clicky’ gets an id.
xwininfo
xwininfo: Please select the window about which you
would like information by clicking the
mouse in that window.
xwininfo: Window id: 0x4a00002 "clicky"
Absolute upper-left X: 1305
Absolute upper-left Y: 670
Relative upper-left X: 0
Relative upper-left Y: 0
Width: 610
Height: 410
Depth: 32
Visual: 0x6e
Visual Class: TrueColor
Border width: 0
Class: InputOutput
Colormap: 0x4a00001 (not installed)
Bit Gravity State: ForgetGravity
Window Gravity State: NorthWestGravity
Backing Store State: Always
Save Under State: no
Map State: IsViewable
Override Redirect State: no
Corners: +1305+670 -5+670 -5-0 +1305-0
-geometry 610x410-5-0
Offline
I'm not really any further along because I don't know if I'm still missing something.
The above image comes from the test files from @mrpeachy and @easysid with Syntax1.10:
conky-start10
conky.config = {
--max_specials = '10000',
max_user_text = 1500000,
background = false,
use_xft = true,
--xftfont Sans:size=16
--xftalpha 1
font = 'Sans:size=9',
total_run_times = 0,
own_window = true,
own_window_argb_visual = true,
own_window_transparent = true,
own_window_type = 'normal',
own_window_title = 'clicky',
own_window_hints = 'undecorated,below,skip_taskbar,skip_pager',--sticky,
double_buffer = true,
minimum_width = 600, minimum_height = 400,
maximum_width = 600,
draw_shades = false,
draw_outline = false,
draw_borders = false,
draw_graph_borders = true,
default_color = 'white',
default_shade_color = 'black',
default_outline_color = 'white',
alignment = 'bottom_right',
gap_x = 10,
gap_y = 5,
no_buffers = true,
uppercase = false,
cpu_avg_samples = 2,
override_utf8_locale = true,
color1 = '#86acad',--darker blue
color2 = '#b1c9c9',--lighter blue
text_buffer_size = 100000,
top_name_width = 5,
update_interval = 1,
--LUA--
lua_load = '$HOME/.conky/click_conky/easyclick.lua',
lua_draw_hook_pre = 'buttonmain',--so that click location is only generated once per cycle rather than one per button per cycle
template1 = [[${lua button {btype=1,bname="test1",blx_off=5,bly_off=100,bw_off=70,bh_off=30,draw=1,dfcol_off=0x0000ff,dfcol_on=0x00ffff,text=1,txt_off="click me"}}]],
};
conky.text = [[
${cpu cpu0}
${if_match ${template1} == 1} button is on ${else} button is off ${endif}
]];
easyclick.lua
--[[click tutorial 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 ~/path/filename.lua
lua_draw_hook_pre buttonmain
TEXT
]]
require 'cairo'
require 'cairo_xlib'
conky_name="clicky"
click_data_file = "/tmp/xdo.txt"
click_start=1-- this starts the clickfunction
buttons={}--this table ini9tially holds the values from the buttons
function conky_buttonmain()
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
--###################################
clickfunction()--start click logging
--###################################
test,x,y=button({
btype=1, --type, 1=on/off, 2=mouse over, 3=execute
bname="test1", --set button name unique for each
st_type=0, --sets button to start 1=on or 0=off
--when off click area setup
blx_off=200, --ypos when off
bly_off=200, --y pos when off
bw_off=100, --height when off
bh_off=100, --width when off
--when on click area setup
blx_on=200, --xpos when on -- default is same as blx_off
bly_on=200, --ypos when on -- default is same as bly_off
bw_on=200, --height when on -- default is same as bw_off
bh_on=100, --height when on -- default is same as bh_off
--draw
draw=1, --1 for draw, 0 for no draw -- default is 0
dtype_off=3, --draw type when off,1=fill, 2=outline,3=outline and fill -- default is 1
dtype_on=3, --draw type when on,1=fill, 2=outline,3=outline and fill --default is 1
--fill off
dfxadj_off=0, --draw x position adjust for fill when off, rel to blx -- default = 0
dfyadj_off=0, --draw y position adjust for fill when off, rel to bly -- default = 0
dfw_off=100, --draw width fill if off -- default is same as bw
dfh_off=100, --draw height fill if off -- default is same as bh
dfcr_off=20, --draw fill corner radius when off -- default is 0
dfcol_off=0xffffff, --draw fill color when off --default is 0xffffff white
dfal_off=1, --draw fill alpha when off -- default is 1, full opaque
--fill on
dfxadj_on=0, --draw x position adjust for fill when on, rel to blx -- default = 0
dfyadj_on=0, --draw y positionadjust for fill when on, rel to bly -- default = 0
dfw_on=200, --draw width fill if on -- default is same as bw
dfh_on=100, --draw height fill if on -- default is same as bh
dfcr_on=30, --draw fill corner radius when on -- default is 0
dfcol_on=0xff0000, --draw fill color when on --default is 0xffffff white
dfal_on=1, --draw fill alpha when on -- default is 1, full opaque
--outline off
doxadj_off=-1, --draw x position adjust for outline when off, rel to blx -- default = 0
doyadj_off=1, --draw y position adjust for outline when off, rel to bly -- default = 0
dow_off=101, --draw width outline if off -- default is same as bw
doh_off=101, --draw height outline if off -- default is same as bh
docr_off=0, --draw outline corner radius when off -- default is 0
docol_off=0x000000, --draw outline color when off --default is 0xffffff white
doal_off=1, --draw outline alpha when off -- default is 1, full opaque
dolw_off=2, --draw outline line width off -- default is 1
--outline on
doxadj_on=0, --draw x position for outline adjust when on
doyadj_on=0, --draw y position for outline adjust when on
dow_on=200, --draw width outline if on -- default is same as bw
doh_on=100, --draw height outline if on -- default is same as bh
docr_on=30, --draw outline corner radius when on -- default is 0
docol_on=0x0000ff, --draw outline color when on --default is 0xffffff white
doal_on=1, --draw outline alpha when on -- default is 1, full opaque
dolw_on=2, --draw outline line width on -- default is 1
--text
text=1, -- 1 if want print text, 0 if no text -- default is 0
--text setup if on, set up to 2 lines
txt1_off="button off", --text when button off -- default is "text"
font1_off="Mono", -- font when off -- default is "mono"
fs1_off="12", -- font size when off -- default is 12
fxadj1_off=15, -- font x position adjust when off -- default is 0
fyadj1_off=-15, -- font y position adjust when off -- default is 0
fcol1_off=0x000000, -- font color off -- default is 0xffffff
fal1_off=1, --font alpha off -- default is 1
--text setup when on
txt_on="button on", --text when button on -- default is same as txt_off
font_on="Sans", -- font when on -- default is "mono"
fs_on="18", -- font size when on -- default is 12
fxadj_on=15, -- font x position adjust when on -- default is 0
fyadj_on=-15, -- font y position adjust when on -- default is 0
fcol_on=0x000000, -- font color on -- default is 0xffffff
fal_off=1, --font alpha on -- default is 1
--other buttons on or off
on_on_on={}, --list other buttons that this button should turn on
on_on_off={},
off_on_on={},
off_on_off={},
--want to return now coords to main function?
return_co=1, -- 1 for return coordiantes, 0 for not
})
--#########################################################################################################
end--if updates>5
cairo_destroy(cr)
cairo_surface_destroy(cs)
cr=nil
end-- end main function
--clickfunction, this runs xdotool and xwininfo and reads the coordinates of clicks
function clickfunction()
--start click logging and calculations ##########################################
click_table={}
if click_start==1 then
local f = io.popen("xwininfo -name '"..conky_name.."' | grep 'Absolute'")
geometry = f:read("*a")
f:close()
local geometry=string.gsub(geometry,"[\n]","")
s,f,abstlx=string.find(geometry,"X%p%s*(%p*%d*)")
s,f,abstly=string.find(geometry,"Y%p%s*(%p*%d*)")
click_start=nil
end--if click_start=1 ######################################
--click calculations #################################
local f=io.open(click_data_file)
click=f:read()
f:close()
if click~=nil then
local f = io.open(click_data_file,"w")
f:write("")
f:close()
end--if click=nil
if click==nil then click="x:0 y:0 " end
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
local f = io.popen("xdotool getmouselocation")
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 #################################
click_table[1]=localx
click_table[2]=localy
click_table[3]=localnowx
click_table[4]=localnowy
end--function
function button(bd)
local localx=click_table[1]
local localy=click_table[2]
local localnowx=click_table[3]
local localnowy=click_table[4]
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
local on_on_off=bd.on_on_off
local off_on_on=bd.off_on_on
local off_on_off=bd.off_on_off
--initialize button
if buttons[tostring(button_name)]==nil then
if st_type==0 then --button is off on start
buttons[tostring(button_name)]=0
elseif st_type==1 then --button is on on start
buttons[tostring(button_name)]=1
else
print ("error1")
end
end
--set mouse point type
if btype==1 or btype==3 then
--on off or execute
localx=localx
localy=localy
elseif btype==2 then
--mouse over
localx=localnowx
localy=localnowy
else
print ("error2")
end
--set click area if on or off
if 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 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
else
print ("error3")
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==2###################################################################
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==2###################################################################
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 buttons[tostring(button_name)]==0 then
dtype=bd.dtype_off or 1
--fill when off
dfblx=blx+(bd.dfxadj_off or 0)
dfbly=bly+(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=blx+(bd.doxadj_off or 0)
dobly=bly+(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 buttons[tostring(button_name)]==1 then--draw on and button on
dtype=bd.dtype_on or 1
--fill when on
dfblx=blx+(bd.dfxadj_on or 0)
dfbly=bly+(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 0xffffff
dfal=bd.dfal_on or 1
--outline when on
doblx=blx+(bd.doxadj_on or 0)
dobly=blx+(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 0xffffff
doal=bd.doal_on or 1
dolw=bd.dolw_on or 1
else
print ("error4")
end--if button on or off
--##########################
--draw base on type
if dtype==1 then
--top left mid circle
local xtl=dfblx+dfcr
local ytl=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=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=doblx+docr
local ytl=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=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=dfblx+dfcr
local ytl=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=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=doblx+docr
local ytl=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=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 text=bd.text
if text==1 then --##############################################################################
--set variables if button on or off
if buttons[tostring(button_name)]==0 then
txt=bd.txt_off or "text"
font=bd.font_off or "mono"
fs=bd.fs_off or 12
fx=blx+(bd.fxadj_off or 0)
fy=bly+(bd.fyadj_off or 0)
fcol=bd.fcol_off or 0xffffff
fal=bd.fal_off or 1
elseif buttons[tostring(button_name)]==1 then
txt=bd.txt_on or bd.txt_off or "text"
font=bd.font_on or "mono"
fs=bd.fs_on or 12
fx=blx+(bd.fxadj_on or 0)
fy=bly+(bd.fyadj_on or 0)
fcol=bd.fcol_on or 0xffffff
fal=bd.fal_on or 1
end
cairo_select_font_face (cr, font, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cr, fs)
cairo_set_source_rgba (cr,rgb_to_r_g_b({fcol,fal}))
cairo_move_to (cr,fx,fy)
cairo_show_text (cr, txt)
cairo_stroke (cr)
end--if text==1 ################################################################################
local return_co=bd.return_co
print (return_co,localx,localy)
if return_co==0 then
return buttons[tostring(button_name)]
elseif return_co==1 then
return buttons[tostring(button_name)],localnowx,localnowy
end
--##########################################################################
end--function###############################################################
--##########################################################################
function conky_conkyclick()
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)
--start click logging and calculations ##########################################
click_table={}
if click_start==1 then
local f = io.popen("xwininfo -name '"..conky_name.."' | grep 'Absolute'")
geometry = f:read("*a")
f:close()
local geometry=string.gsub(geometry,"[\n]","")
s,f,abstlx=string.find(geometry,"X%p%s*(%p*%d*)")
s,f,abstly=string.find(geometry,"Y%p%s*(%p*%d*)")
click_start=nil
end--if click_start=1 ######################################
--click calculations #################################
local f=io.open(click_data_file)
click=f:read()
f:close()
if click~=nil then
local f = io.open(click_data_file,"w")
f:write("")
f:close()
end--if click=nil
if click==nil then click="x:0 y:0 " end
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
local f = io.popen("xdotool getmouselocation")
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 #################################
click_table[1]=localx
click_table[2]=localy
click_table[3]=localnowx
click_table[4]=localnowy
cairo_destroy(cr)
cairo_surface_destroy(cs)
cr=nil
end-- end main function
--this function is to set up button in conkyrc code
function conky_button(bd)
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
local bd=loadstring("return" .. bd)()
local localx=click_table[1]
local localy=click_table[2]
local localnowx=click_table[3]
local localnowy=click_table[4]
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 {}
--initialize button
if buttons[tostring(button_name)]==nil then
if st_type==0 then --button is off on start
buttons[tostring(button_name)]=0
elseif st_type==1 then --button is on on start
buttons[tostring(button_name)]=1
else
print ("error1")
end
end
--set mouse point type
if btype==1 or btype==3 then
--on off or execute
localx=localx
localy=localy
elseif btype==2 then
--mouse over
localx=localnowx
localy=localnowy
else
print ("error2")
end
--set click area if on or off
if 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 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
else
print ("error3")
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==2###################################################################
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==2###################################################################
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 buttons[tostring(button_name)]==0 then
dtype=bd.dtype_off or 1
--fill when off
dfblx=blx+(bd.dfxadj_off or 0)
dfbly=bly+(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=blx+(bd.doxadj_off or 0)
dobly=bly+(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 buttons[tostring(button_name)]==1 then--draw on and button on
dtype=bd.dtype_on or 1
--fill when on
dfblx=blx+(bd.dfxadj_on or 0)
dfbly=bly+(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 0xffffff
dfal=bd.dfal_on or 1
--outline when on
doblx=blx+(bd.doxadj_on or 0)
dobly=blx+(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 0xffffff
doal=bd.doal_on or 1
dolw=bd.dolw_on or 1
else
print ("error4")
end--if button on or off
--##########################
--draw base on type
if dtype==1 then
--top left mid circle
local xtl=dfblx+dfcr
local ytl=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=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=doblx+docr
local ytl=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=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=dfblx+dfcr
local ytl=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=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=doblx+docr
local ytl=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=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 text=bd.text
if text==1 then --##############################################################################
--set variables if button on or off
if buttons[tostring(button_name)]==0 then
txt=bd.txt_off or "text"
font=bd.font_off or "mono"
fs=bd.fs_off or 12
fx=blx+(bd.fxadj_off or 0)
fy=bly+(bd.fyadj_off or 0)
fcol=bd.fcol_off or 0xffffff
fal=bd.fal_off or 1
elseif buttons[tostring(button_name)]==1 then
txt=bd.txt_on or bd.txt_off or "text"
font=bd.font_on or "mono"
fs=bd.fs_on or 12
fx=blx+(bd.fxadj_on or 0)
fy=bly+(bd.fyadj_on or 0)
fcol=bd.fcol_on or 0xffffff
fal=bd.fal_on or 1
end
cairo_select_font_face (cr, font, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cr, fs)
cairo_set_source_rgba (cr,rgb_to_r_g_b({fcol,fal}))
cairo_move_to (cr,fx,fy)
cairo_show_text (cr, txt)
cairo_stroke (cr)
end--if text==1 ################################################################################
local return_co=bd.return_co or 0
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
--#########################################################################################################
end--if updates>5
cairo_destroy(cr)
cairo_surface_destroy(cs)
cr=nil
end-- end main function
The -DD error message from conky:
DEBUG(1) [./src/conky.cc:640]: jumping
DEBUG(1) [./src/lua/fonts.cc:84]: loading fonts
DEBUG(1) [./src/core.cc:2109]: no templates to replace
DEBUG(1) [./src/lua/fonts.cc:84]: loading fonts
DEBUG(1) [./src/conky.cc:684]: evaluated '${updates}' to '4'
DEBUG(1) [./src/lua/fonts.cc:64]: setting up fonts
DEBUG(1) [./src/output/display-x11.cc:816]: Processing 1 X11 events...
DEBUG(1) [./src/output/display-x11.cc:837]: Done processing 1 events.
DEBUG(1) [./src/core.cc:2109]: no templates to replace
DEBUG(1) [./src/lua/fonts.cc:84]: loading fonts
DEBUG(1) [./src/conky.cc:684]: evaluated '${updates}' to '4'
conky: llua_getstring: function conky_button didn't return a string, result discarded
DEBUG(1) [./src/lua/fonts.cc:84]: loading fonts
DEBUG(0) [./src/content/algebra.cc:249]: parsed arg into ' == 1'
conky: Bad arguments: ' ' and ' 1'
....
conky: Bad arguments: ' ' and ' 1'
conky: compare failed for expression ' == 1'
DEBUG(1) [./src/conky.cc:640]: jumping
DEBUG(1) [./src/lua/fonts.cc:84]: loading fonts
DEBUG(1) [./src/core.cc:2109]: no templates to replace
DEBUG(1) [./src/lua/fonts.cc:84]: loading fonts
DEBUG(1) [./src/conky.cc:684]: evaluated '${updates}' to '16'
1 -1305,0 -670,0
DEBUG(1) [./src/lua/fonts.cc:64]: setting up fonts
DEBUG(1) [./src/output/display-x11.cc:816]: Processing 1 X11 events...
DEBUG(1) [./src/output/display-x11.cc:837]: Done processing 1 events.
DEBUG(1) [./src/core.cc:2109]: no templates to replace
DEBUG(1) [./src/lua/fonts.cc:84]: loading fonts
DEBUG(1) [./src/conky.cc:684]: evaluated '${updates}' to '16'
conky: llua_do_call: function conky_button execution failed: /home/unklar/.conky/click_conky/easyclick.lua:538: attempt to call a nil value (global 'loadstring')
DEBUG(1) [./src/lua/fonts.cc:84]: loading fonts
DEBUG(0) [./src/content/algebra.cc:249]: parsed arg into ' == 1'
conky: Bad arguments: ' ' and ' 1'
conky: compare failed for expression ' == 1'
The original files (Syntax1.9) are here: https://workupload.com/file/uzhB3UyWCwL
If can help, it is important to create an empty
/tmp/xdo.txt file in /tmp before starting the test.
Offline