You are not logged in.
oops, thats just me being a bonehead 
local f = io.popen("mocp -Q %album")
mocalbum= f:read("*a")
f:close()
mocalbum=string.gsub(mocalbum,"[\n]","")just getting my string names mixed up
its been a long day!
Offline
oops, thats just me being a bonehead
....
its been a long day!
I understand, sometimes my mind gets ahead of my fingers. Crainial flatulation! 
Offline
I feel I have to share my volume conky here which is based on mrpeachy's gauge conky:

Download link: http://dl.dropbox.com/u/40050690/Yam_Conky_Volume.zip
Requires: Candara font (included)
I want to thank mrpeachy for his awesome conky's, many of my ideas are based on your work.
Last edited by eXpander (2012-01-24 14:23:52)
I don't know.
Offline
This one shows battery,free space and mem usage:

Download link: http://dl.dropbox.com/u/40050690/Yam_Vertical_Text.zip
Requries: Candara and Pushkin font (both included)
Requries: acpitool (have to install it yourself)
Last edited by eXpander (2012-01-24 14:24:24)
I don't know.
Offline
Hi guys, I've been playing with conky for the last few days and found a quick and handy way to add interactive (on click) buttons to conky just using bash and a tool called xdotool
It starts with using xdotool to capture and record mouse clicks on conky windows. I've implemented it this way but you'll get the idea very quickly and see it's a really handy way to add functionality to conky, this is just how to get audacious to play / pause when the user clicks on the album art in the conky as an example.
First I log the mouse clicks using this script I've called conkyMouse.sh
#!/bin/bash
#use the name / title you've assigned to your conky in the rc, "own_window_title main_conky"
xdotool search --name [main_conky] behave %@ mouse-click getmouselocationthen I invoke the script by running
~/Desktop/conkyMouse.sh > ~/Desktop/mouseTrap2.logso mouseTrap2.log is where all our output is going when that script is running. Next up we want to parse that information to see if it matches up with any buttons / icons we've placed. I've done this in a script called mouseCatcher.sh
#!/bin/bash
# First check if logfile is still empty, if it is then exit
FILE=~/Desktop/mouseTrap2.log
if [[ ! -s $FILE ]] ; then
exit 0
fi
#we're only interested in the very last line in the log file, this is where we parse that string
# into easy to work with X and Y coordinates
vars=`tail -n 1 $FILE`
X=`echo $vars | awk '{print $1}'`
Y=`echo $vars | awk '{print $2}'`
x=${X:2}
y=${Y:2}
#now we have our coordinates stored go ahead and empty the logfile for next time.
cat /dev/null > $FILE
# Now it's just a case of evaluating if our coordinates match up with our icons, if they do
# we just execute a terminal command or any other functionality we want to include
# and if they dont we just ignore them.
if (($x>885&&$x<971)) ;then
#echo "Last recorded X is between 885 and 971 with a value of :"$x
if (($y>410&&$y<485)) ;then
#echo "Last recorded Y is between 410 and 485 with a value of :"$y
status=`audtool2 playback-status`
if [ $status == "playing" ] ; then
#echo "ready to pause"
`audtool playback-playpause`
else
# echo "ready to play"
`audtool playback-playpause`
fi
fi
fi
exit 0This one is the one that does all the hard work but it's very easy to modify just by changing the pixel ranges it checks against or adding as many more as you'd like. It's also pretty snappy too so you can just call this script in the conkyrc and give it a nice low refresh time.
${offset 110}${if_running audacious2}${voffset 10}${font Sans:style=Bold:size=10}${color}Audacious is ${execi 3 audtool playback-status} ${stippled_hr}${font}${color grey}
${execpi 20 ~/.conky/audacious}${voffset 10}${offset 110}${color lightgrey} Title : $color${execi 3 audtool current-song-tuple-data title}
${offset 110}${color lightgrey} Artist : $color${execi 3 audtool current-song-tuple-data artist}
${offset 110}${color lightgrey} Album : $color${execi 3 audtool current-song-tuple-data album}${execi 1 ~/Desktop/mouseCatcher.sh}
${offset 110}${color lightgrey} Length: $color${execi 3 audtool current-song-output-length}/${execi 3 audtool current-song-length}
${offset 110}${color lightgrey} Track $color${execi 3 audtool playlist-position} ${color lightgrey}of $color${execi 10 audtool playlist-length}${endif}That's just where I've stuck it in but you get the idea.
And well that's just what it looks like at the minute for the sake of it. For that example clicking on the cdart plays and pauses audacious but I'll be knocking up some real controls now I know it works lol.
Oh yeah and before I forget the "conkyMouse.sh" script that does the logging needs to start AFTER conky (or as part of conky starting up seems to work fine too). I've no idea why, if anything I'd have thought it'd be the other way round.
But yeah easy interactive conkies using "xdotool" (available though apt-get etc if you don't already have it) without going anywhere near Lua, Cairo or python 
Last edited by barrybarrykelly (2012-01-26 01:08:46)
Offline
^the version of xdotool in repo (mint 11) is
xdotool version 2.20100701.2961
and when i try the command you posted it just says:
xdotool: Unknown command: behave
Run 'xdotool help' if you want a command list
what version do you have?
Offline
My output with just "xdotool behave" is:
barry@office-lubu:~$ xdotool behave
Invalid number of arguments (minimum is 3)
Usage: behave window event action [args...]
The event is a window event, such as mouse-enter, resize, etc.
The action is any valid xdotool command (chains OK here)
Events:
mouse-enter - When the mouse moves into the window
mouse-leave - When the mouse leaves a window
mouse-click - Fired when the mouse button is released
focus - When the window gets focus
blur - When the window loses focusBut my version number: is 1:2.20110530.1-3ubuntu1
I'm having a poke through the man pages and things now to see why the two are so different, though behave should be there in some form or another.
Offline
from http://www.semicomplete.com/projects/xdotool/
Debian and Ubuntu users can install xdotool with: apt-get install xdotool
(Note: you will get a pretty ancient version of xdotool, if you want newer ones check here)
then when i do the click here i see only 64 bit versions (which i cant run on my eeepc)
Offline
thats harsh
Quick update on the method though I found out you can use the logfile itself to trigger the check on the mouse coords so there's no need to wait on a refresh or the conky scripts to run again, it's instant.
If you manage to get it installed (I'm using Lubuntu 11.10 btw if that helps, package came straight from repos) you only need to make one file with :
#!/bin/bash
xdotool search --name [main_conky] behave %@ mouse-click getmouselocation > mouseTrap3.log exec ~/Desktop/mouseCatcher3.shThen the mouseCatcher3.sh just has the same sort of stuff in it again:
#!/bin/bash
# First check if logfile is still empty, if it is then exit
FILE=~/Desktop/mouseTrap3.log
if [[ ! -s $FILE ]] ; then
exit 0
fi
#we're only interested in the very last line in the log file, this is where we parse that string
# into easy to work with X and Y coordinates
vars=`tail -n 1 $FILE`
X=`echo $vars | awk '{print $1}'`
Y=`echo $vars | awk '{print $2}'`
x=${X:2}
y=${Y:2}
#now we have our coordinates stored go ahead and empty the logfile for next time.
cat /dev/null > $FILE
# Now it's just a case of evaluating if our coordinates match up with our icons, if they do
# we just execute a terminal command or any other functionality we want to include
# and if they dont we just ignore them.
if (($x>885&&$x<971)) ;then
#echo "Last recorded X is between 885 and 971 with a value of :"$x
if (($y>410&&$y<485)) ;then
#echo "Last recorded Y is between 410 and 485 with a value of :"$y
`audtool playback-playpause`
fi
fi
exit 0If I get time tomorrow I'll make up a standard one with the XY range checks stuck in a function so to add more you just need to call it with the max and min for them and the terminal line.
Offline
^the version of xdotool in repo (mint 11) is
xdotool version 2.20100701.2961and when i try the command you posted it just says:
xdotool: Unknown command: behave
Run 'xdotool help' if you want a command listwhat version do you have?
WoW! Debian Wheezy: 1:2.20100701.2961-3
OUCH!!!!!
Offline
^the version of xdotool in repo (mint 11) is
xdotool version 2.20100701.2961and when i try the command you posted it just says:
xdotool: Unknown command: behave
Run 'xdotool help' if you want a command listwhat version do you have?
WoW! Debian Wheezy: 1:2.20100701.2961-3
OUCH!!!!!
Offline
You can download the last xdotool and dependency from:
http://ftp.us.debian.org/debian/pool/ma … 3_i386.deb
http://ftp.us.debian.org/debian/pool/ma … 3_i386.deb
and then install with dpkg -i path_where_you_saved/libxdo2_2.20110530.1-3_i386.deb path_where_you_saved/xdotool_2.20110530.1-3_i386.deb
Edit: Mrpeachy you can use these two in your eeepc without problem
Almost forgot the gui: http://sourceforge.net/projects/xdotool-gui/
Last edited by gmonti (2012-01-26 16:17:47)
Giuliano Monti Avellino
Debian/Squeeze
Gnome
Offline
thanks gmonti!
i have xdotool up and running
Offline
a question about gap_x and gap_y
on my puter i need
gap_x 5
gap_y 5
to get the conky window just on the edge of my visible display (using top right positioning)
6 i see a pixel of background between the edge of conky and the edge of my visible screen
is this setting of 5 universal?
or do others need other numbers?
Offline
0 gives the sides of the screen for me with 5 just giving a bit of a gap.
Not really sure why that changes for yours unless you're using sticky window positioning things that might be snapping any value within 5 pixels to the side
Offline
thanks barrybarrykelly, i wonder what it is thats causing that
anyway, ive been using the xdotool method in a lua script and currently have this amazing square that changes color when you click on it
but as a proof of concept its certainly working well
ive had to factor in my 5 pixel offset to calculate x and y relative to the edges of the conky window
also to get the change i need a relatively slow double click (as conky is set on 1 second updates)
--clicky lua by mrpeachy - thanks to barrybarrykelly for the xdotool method and gmonti for finding the deb files for the xdotool
require 'cairo'
function conky_main()
if conky_window == nil then return end
local cs = cairo_xlib_surface_create(conky_window.display, conky_window.drawable, conky_window.visual, conky_window.width, conky_window.height)
cr = cairo_create(cs)
local updates=tonumber(conky_parse('${updates}'))
if updates>5 then
--#########################################################################################################
--xdotool search --name [main_conky] behave %@ mouse-click getmouselocation
if updates==6 then
local f = io.popen("xdotool search --name 'clicky' behave %@ mouse-click getmouselocation > /tmp/xdo")
end
local f=io.open("/tmp/xdo")
local click=f:read()
f:close()
if click~=nil then
local f = io.open("/tmp/xdo","w")
f:write("")
f:close()
end
--###############################
--enter conky and screen settings
conkyposition="tr"
conkygapx=40
conkygapy=40
screenw=1024
screenh=600
--set clickbox ##################
topleftx=100
toplefty=100
boxwidth=100
boxheight=100
--###############################
clicked(click,conkygapx,conkygapy,conkyposition,screenw,screenh,topleftx,toplefty,boxwidth,boxheight)
--#########################################################################################################
end-- if updates>5
cairo_destroy(cr)
cairo_surface_destroy(cs)
cr=nil
end-- end main function
function clicked(click,conkygapx,conkygapy,conkyposition,screenw,screenh,topleftx,toplefty,boxwidth,boxheight)
if click==nil then click="x:0 y:0 " end
s,f,mousex=string.find(click,"x%p(%d*)%s")
s,f,mousey=string.find(click,"y%p(%d*)%s")
mousex=tonumber(mousex)
mousey=tonumber(mousey)
conkyw=tonumber(conky_window.width)-10
conkyh=tonumber(conky_window.height)-10
if conkyposition=="tr" then
localx=mousex-screenw+conkyw+conkygapx+5
localy=mousey-conkygapy+5
elseif conkyposition=="br" then
localx=mousex-screenw+conkyw+conkygapx+5
localy=mousey-screenh+conkyh+conkygapy+5
elseif conkyposition=="tl" then
localx=mousex+conkygapx-5
localy=mousey+conkygapy-5
elseif conkyposition=="bl" then
localx=mousex+(conkygapx-5)
localy=mousey-screenh+conkyh+conkygapy+5
elseif conkyposition=="tm" then
localx=(mousex)-(screenw/2)+(conkyw/2)+conkygapx+5
localy=mousey-conkygapy+5
elseif conkyposition=="bm" then
localx=(mousex)-(screenw/2)+(conkyw/2)+conkygapx+5
localy=mousey-screenh+conkyh+conkygapy+5
end
--test if the click was inside
if localx>=topleftx and localx<=topleftx+boxwidth and localy>=toplefty and localy<=toplefty+boxheight and onoff~=1 then
onoff=1
localx=0
localy=0
end
if localx>=topleftx and localx<=topleftx+boxwidth and localy>=toplefty and localy<=toplefty+boxheight and onoff==1 then
onoff=0
end
--do action
if onoff==1 then
cairo_set_source_rgba (cr,1,1,1,1)
else
cairo_set_source_rgba (cr,1,0,1,1)
end
cairo_set_line_width (cr,1)
cairo_rectangle (cr,topleftx,toplefty,boxwidth,boxheight)
cairo_fill (cr)
end--clicked functionLast edited by mrpeachy (2012-01-27 00:44:44)
Offline
@Mrpeachy, one of my mate here at the office, gave me link for you: http://pratyeka.org/fake-x-input/ it is about xdotool
Giuliano Monti Avellino
Debian/Squeeze
Gnome
Offline
@Mrpeachy, one of my mate here at the office, gave me link for you: http://pratyeka.org/fake-x-input/ it is about xdotool
thanks again,
xwininfo looks to be the best way to calculate click coordinates within the conky window
Offline
xwininfo makes the calculating much easier
ive come up with a couple of ways to use this method
to turn things on or off like the top left square
or to execute on click like the bottom right square
lots of interesting possibilities
Offline
OH MY!!!!!!!!!!!!!
Inter active conkys ... what a rush!
I gotta get workin' on that too!
Lets see, I have a million conkys (well, a lot):
I boot-up with different conkys on different desktops
- I need another desktops for a new conky
I have some great LUA conkys thank's to wlourf and mrpeachy, and
NOW interactive conkys! I want one I want one
... but what can they do?
Offline
how to use interactive conky.... hmm
you could have a conky displaying info from perhaps last fm, along with album art, a song comes up that you really like so you click on the cover art and your taken to the a website to get the lyrics
and put your controls for moc or mpd in conky for that matter
or you have a news feed, see a story, click on it and it takes you to a site for more info
or you click on your gmail indicator when you see that you have new mail and it opens a browser at your inbox
i made the interactive conkybar a little while ago but this method is much easier than the one i used foor that
click on a button shows you a system monitor, another one shows you weather, etc
things along those lines
Last edited by mrpeachy (2012-01-27 04:26:42)
Offline

That's what I'm using atm for Audacious, the seek bar works using:
if (($x>1035&&$x<1185)) ;then
if (($y>520&&$y<527)) ;then
if [[ `audtool playback-status` = playing || `audtool playback-status` = paused ]];then
barDrawPos=1035
pixelsIntoBar=$( expr $x - $barDrawPos )
songLength=`audtool current-song-length-seconds`
percentSong=$( expr $pixelsIntoBar \* 10 / 15 )
seekSecond=$(expr $songLength \* $percentSong / 100 )
`audtool playback-seek $seekSecond`
fi
fi
fiAnd the playback/playlist buttons are working too but I still need to add play file/open playlist, close audacious and volume controls. The nested ifs mean it's not doing extra processing unless it's required and it allows me to use the same coordinates for different commands depending on what's happening and what conky is displaying at the time.
Offline
Made a quick video showing my mouse driven conky in action.
Mouse controlled audacious2 conky
I couldn't get the sound to work properly on xvidcap so it kind of back fired, I've left the audacious2 window on the screen to show that even though conky has to wait until it's next refresh to display any changes, the changes are immediate for other programs. So I can skip multiple songs in-between refresh cycles by using multiple clicks on the skip track button.
It'd make more sense if I had recorded sound lol
Last edited by barrybarrykelly (2012-01-28 00:04:29)
Offline
Ok, I finally did it. Kinda. I wrote a lua script that displays music info and coverart. I know Vastone put some stuff together but it depends on python/shell scripts. Even the lua script uses python/shell scripts. I wrote a lua script that doesn't depend on python/shell scripts. The lua script just uses moc, it can probably do others easily. I have some bugs I'd like to work out first. One in particular is the coverart part, sometimes it doesn't get the correct image. Here is an image of what I have.
.conkyrc-music
# -- Conky settings -- #
background no
update_interval 1
cpu_avg_samples 2
net_avg_samples 2
override_utf8_locale yes
double_buffer yes
no_buffers yes
text_buffer_size 1024
imlib_cache_size 0
# -- Window specifications -- #
draw_borders no
own_window_argb_visual yes
own_window_type normal
own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager
own_window yes
own_window_transparent yes
own_window_class conky-semi
border_inner_margin 0
border_outer_margin 0
minimum_size 200 180
alignment ml
gap_x 5
gap_y 60
# -- Graphics settings -- #
draw_shades no
draw_outline no
draw_borders no
draw_graph_borders no
# -- Text settings -- #
use_xft yes
xftfont Santana:size=8
xftalpha 0.8
uppercase no
default_color FFFFFF
# -- Lua load -- #
lua_load ~/.conky/draw_bg.lua
lua_load ~/.conky/lua-test/image-display.lua
lua_draw_hook_pre main
#at least one line (empty or not) after TEXT
#
TEXT
${lua conky_draw_bg 20 0 0 0 0 0x000000 0.5}image-display.lua
require 'cairo'
require 'imlib2'
--Set parameters for x,y,h,w
-- y = vertical position
-- x = horizontal position
-- h,w = picture size
-- image_file = name & location of file to be displayed
x=40
y=40
h=100
w=100
image_file='/tmp/covers.jpg'
homedir=os.getenv("HOME").."/"
-- start of main() function
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=conky_parse('${updates}')
update_num=tonumber(updates)
if update_num > 5 then
if conky_window==nil then return end
--Display text
font="santana-black"
font_size=12
test_txt="hello world"
xpos,ypos=5,15
red,green,blue,alpha=1,1,1,1
font_slant=CAIRO_FONT_SLANT_NORMAL
font_face=CAIRO_FONT_WEIGHT_NORMAL
--song info
mocrunning=conky_parse("${if_running mocp}1${else}0${endif}")
if tonumber(mocrunning)==1 then
local f = io.popen("mocp -Q %album")
mocalbum= f:read("*a")
f:close()
mocalbum=string.gsub(mocalbum,"[\n]","")
local f = io.popen("mocp -Q %artist")
mocartist= f:read("*a")
f:close()
mocartist=string.gsub(mocartist,"[\n]","")
local f = io.popen("mocp -Q %song")
mocsong= f:read("*a")
f:close()
mocsong=string.gsub(mocsong,"[\n]","")
local f = io.popen("mocp -Q %ct")
currenttime= f:read("*a")
f:close()
currenttime=string.gsub(currenttime,"[\n]","")
local f = io.popen("mocp -Q %tt")
totaltime= f:read("*a")
f:close()
totaltime=string.gsub(totaltime,"[\n]","")
----------------------------------
--check directory exists
--------------------------
dir_exists()
-------------
cairo_select_font_face (cr, font, font_slant, font_face);
cairo_set_font_size (cr, font_size)
cairo_set_source_rgba (cr,red,green,blue,alpha)
cairo_move_to (cr,xpos,ypos)
cairo_show_text (cr,'Album: '..(mocalbum))
cairo_move_to (cr,xpos,ypos+10)
cairo_show_text (cr, 'Artist: ' .. (mocartist))
cairo_move_to (cr,xpos,ypos+20)
cairo_show_text (cr, 'Song: ' .. (mocsong))
cairo_move_to (cr,xpos,ypos+140)
cairo_show_text (cr, "Current Time")
cairo_move_to (cr,xpos+15,ypos+150)
cairo_show_text (cr, (currenttime))
cairo_move_to (cr,xpos+125,ypos+140)
cairo_show_text (cr, "Total Time")
cairo_move_to (cr,xpos+140,ypos+150)
cairo_show_text (cr, (totaltime))
cairo_stroke (cr)
-- start of image display
local show = imlib_load_image(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
end
-----------------
function dir_exists()
local f=io.open(homedir..'covers',"r")
if f~=nil then io.close(f)
get_coverart()
return
---Do nothing else
else
print ("Directory not here...creating")
os.execute ('mkdir ~/covers')
return
end
end
function get_coverart()
coversdir=homedir..'covers'
local f=io.open(""..coversdir.."/"..mocartist.."-"..mocalbum..".jpg","r")
if f~=nil then io.close(f)
--link cover from coverdir to /tmp/covers.jpg to be displayed
local f= io.popen("rm /tmp/covers.jpg")
f:close()
local f= io.popen("ln -s '"..coversdir.."/"..mocartist.."-"..mocalbum..".jpg' /tmp/covers.jpg")
f:close()
return
else
--Get cover
local f= io.popen("curl -s 'http://api.discogs.com/search?q='"..mocartist.."'+'"..mocalbum.."'&btn=&type=all' | python -mjson.tool | grep -o 'http://api.discogs.com/image/[^\"]*.jpeg' |sed -n 1p")
searchresults= f:read("*a")
f:close()
local f= io.popen('wget -O \"'..coversdir..'/'..mocartist..'-'..mocalbum..'.jpg\" '..searchresults..'')
coverart= f:read("*a")
f:close()
return
end
end
endI didn't use conkyparse() because I found it was not dependable with mocp conky variables. It's not pretty, but it works(kinda).
i
Offline
Lookin good there ack-ack.
One thing I am going to suggest:
image_file='/tmp/covers.jpg'Dump that /tmp/ folder - even conkyForecast had problems with that, make a directory:
example
/.MCA --for MusicCoverArtand use that.
See if that helps.
Mind ya, I'm grabbing at straws ... but straws that worked with cForecast.
Last edited by Sector11 (2012-01-28 22:45:15)
Offline
Copyright © 2012 CrunchBang Linux.
Proudly powered by Debian. Hosted by Linode.
Debian is a registered trademark of Software in the Public Interest, Inc.