You are not logged in.
I was playing arround with conky and wanted to show an animation..
So I took a compdead.gif and used this line to grap all stills from it:
gifsicle --unoptimize --explode /home/pieter/temp/compdead.gif --output /home/pieter/temp/temp.gif
Above line creates images in /temp/ that look like this:
temp.gif.001
temp.gif.002
temp.gif.003
temp.gif.004
temp.gif.005
..
temp.gif.236
temp.gif.237
temp.gif.238
Then I used this conky config to show it:
update_interval 0.1
imlib_cache_size 0
template1 /home/pieter/temp/temp.gif.
template2 -p 10,20 -s 135x135
TEXT
Conky Animation with images
${if_updatenr 01}${image ${template1}005 ${template2}}${endif}
${if_updatenr 02}${image ${template1}010 ${template2}}${endif}
${if_updatenr 03}${image ${template1}015 ${template2}}${endif}
${if_updatenr 04}${image ${template1}020 ${template2}}${endif}
${if_updatenr 05}${image ${template1}025 ${template2}}${endif}
${if_updatenr 06}${image ${template1}030 ${template2}}${endif}
${if_updatenr 07}${image ${template1}035 ${template2}}${endif}
${if_updatenr 08}${image ${template1}040 ${template2}}${endif}
${if_updatenr 09}${image ${template1}045 ${template2}}${endif}
${if_updatenr 10}${image ${template1}050 ${template2}}${endif}
${if_updatenr 11}${image ${template1}055 ${template2}}${endif}
${if_updatenr 12}${image ${template1}060 ${template2}}${endif}
${if_updatenr 13}${image ${template1}065 ${template2}}${endif}
${if_updatenr 14}${image ${template1}070 ${template2}}${endif}
${if_updatenr 15}${image ${template1}075 ${template2}}${endif}
${if_updatenr 16}${image ${template1}080 ${template2}}${endif}
${if_updatenr 17}${image ${template1}085 ${template2}}${endif}
${if_updatenr 18}${image ${template1}090 ${template2}}${endif}
${if_updatenr 19}${image ${template1}095 ${template2}}${endif}
${if_updatenr 20}${image ${template1}100 ${template2}}${endif}
${if_updatenr 21}${image ${template1}105 ${template2}}${endif}
${if_updatenr 22}${image ${template1}110 ${template2}}${endif}
${if_updatenr 23}${image ${template1}115 ${template2}}${endif}
${if_updatenr 24}${image ${template1}120 ${template2}}${endif}
${if_updatenr 25}${image ${template1}125 ${template2}}${endif}
${if_updatenr 26}${image ${template1}130 ${template2}}${endif}
${if_updatenr 27}${image ${template1}135 ${template2}}${endif}
${if_updatenr 28}${image ${template1}140 ${template2}}${endif}
${if_updatenr 29}${image ${template1}145 ${template2}}${endif}
${if_updatenr 30}${image ${template1}150 ${template2}}${endif}
${if_updatenr 31}${image ${template1}155 ${template2}}${endif}
${if_updatenr 32}${image ${template1}160 ${template2}}${endif}
${if_updatenr 33}${image ${template1}165 ${template2}}${endif}
${if_updatenr 34}${image ${template1}170 ${template2}}${endif}
${if_updatenr 35}${image ${template1}175 ${template2}}${endif}
${if_updatenr 36}${image ${template1}180 ${template2}}${endif}
${if_updatenr 37}${image ${template1}185 ${template2}}${endif}
${if_updatenr 38}${image ${template1}190 ${template2}}${endif}
${if_updatenr 39}${image ${template1}195 ${template2}}${endif}
${if_updatenr 40}${image ${template1}200 ${template2}}${endif}
${if_updatenr 41}${image ${template1}205 ${template2}}${endif}
${if_updatenr 42}${image ${template1}210 ${template2}}${endif}
${if_updatenr 43}${image ${template1}215 ${template2}}${endif}
${if_updatenr 44}${image ${template1}220 ${template2}}${endif}
${if_updatenr 45}${image ${template1}225 ${template2}}${endif}
${if_updatenr 46}${image ${template1}230 ${template2}}${endif}
${if_updatenr 47}${image ${template1}235 ${template2}}${endif}
${if_updatenr 48}${image ${template1}239 ${template2}}${endif}
${if_updatenr 49}${image ${template1}239 ${template2}}${endif}
${if_updatenr 50}${image ${template1}239 ${template2}}${endif}
As you see it isnt that optimized at all (although I used templates vars to make it easy for myself).
${template1}005 will show: /home/pieter/temp/temp.gif.005 as image
In this sequence I found it good enough to use every 5th image. 5,10,15 etc etc and for the end I used 3 times the last image.
You can see it at work in this movie: http://pieter.blinkenshell.org/blog/wp- … ky-ani.ogv
(you might want to download it and then play it (its my desktop window at 1600x900 grabbed with recordmydesktop )).
Still need to find an easier way to create a movie from a part of my desktop. Suggestions Anyone?
Now this aint that fancy but it works without lua or other third party script..
type and read you later!
Using CrunchBang 10 “Statler” Alpha 2
Offline
I think: KOOL
thanks for sharing
Offline
Yes I know... now we are in 2014 ... but I only discovered your post today and I want to say that it works perfectly ! ! ! !
Very nice conky !
Thank you very much,
Offline
4 years between posts, impressive ]:D
however, lua is pretty easy to pick up and well integrated with conky, the same thing could be done far more simply and efficiently with a short lua script.
Offline
Hello mrpeachy !
First, excuse me for answering in this thread ... 4 years too late. I know that is not correct and I present my regrets to this forum. Do you want me to create a new thread ? Or may I keep on writing in this current thread ?
In fact, I am a beginner with Linux/conky and lua code is hard to understand for beginners and non-computer scientists like me. I was searching for an easy method to play an animated gif in a conky window. That is why I was very happy to find the Pietre Blinkenshell method (using gifsicle and no lua code). And as the thread was not closed ...
My initial idea was : making an animated launcher on my Xubuntu desktop. To carry out this project, I imagined a method in two steps: first step, place a little animated gif in a conky window (the final size like a classic icon) and, second step, find a method to make it clickable - in my case, the click action is only to open a folder in Nemo or Thunar, or to start a program like VLC or SMplayer in my Xubuntu. Only actions in the OS, no action in the conky.
I think that my first step is now done. This link in the French Ubuntu forum to show you what I have done. I will now try to take care of the next step : making this conky clickable. It may prove to be harder but Didier-T (a very talented, friendly and active contributor in the French Ubuntu forum) has shown me an example of one of its own lua scripts, called clic_info.lua. I will try to modify and adapt it to my specific project this week-end.
Not sure whether I can do it ... but I will try ...
MrPeachy, you told me that lua will be better and easier than the method of Pietre Blinkenshell to make an animated launcher. Could you send me a link to learn this better lua method? A how-to but only if it is a step-by-step method, since I am really a beginner and not a computer scientist.
Thank you very much by advance of your answer !
Offline
i wrote this how to for people who want to start using lua in conky
i have had some feedback from people who found it useful
http://crunchbang.org/forums/viewtopic.php?id=17246
it depends how interested you are in conky whether the effort to learn some lua is worth it
the method described in this first post is fine, it works which is the main thing
to display the gif images you are going to want to use a this kind of thing
updates=tonumber(conky_parse('${updates}'))--this gets the conky update number
number_of_images=100--how manny images you are showing
count=(updates %number_of_images)--counts up to from 0 to number_of_images and repeats
path="/home/username/gif_images/" --path to the folder where the images are
show_image=path..count..".png" --assuming that the images are png's
then you will need a method to get the images displayed
there are several ways to do that
i posted an image display function in the how to under "useful functions"
Last edited by mrpeachy (2014-03-20 22:44:39)
Offline
this works
gif.lua
--gifsicle --unoptimize --explode /home/pieter/temp/compdead.gif --output /home/pieter/temp/temp.gif
require 'cairo'
require 'imlib2'
function conky_gif(nim,path,x,y,w,h)
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)
updates=tonumber(conky_parse('${updates}'))
count=(updates %nim)+1
if string.len(count)==1 then
count=("00"..count)
elseif string.len(count)==2 then
count=("0"..count)
end
show_image=path..count
image({x=x,y=y,w=w,h=h,file=show_image,decache=1})
cairo_destroy(cr)
cairo_surface_destroy(cs)
cr=nil
return ""
end-- end main function
function image(im)--#######################################################################################
local x=(im.x or 0)
local y=(im.y or 0)
local w=(im.w or 50)
local h=(im.h or 50)
local file=tostring(im.file)
local decache=im.decache or 0
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)
if decache==1 then
imlib_free_image_and_decache()
else
imlib_free_image()
end
imlib_context_set_image(scaled)
imlib_render_image_on_drawable(x,y)
imlib_free_image()
end--function image
in conky rc (in addition to other settings)
lua_load ~/Desktop/gif.lua
TEXT
${lua gif 11 /home/mcdowall/gifimages/gif. 30 30 60 60}
#${lua gif number_of_images path_to_image_excluding_trailing_numbers x y width height}
i used this command to get the individual images
gifsicle --unoptimize --explode /home/mcdowall/gifimages/NyanCat.gif --output /home/mcdowall/gifimages/gif
which generated files named gif.001, gif.002 etc
work for gifs up to 999 images
Last edited by mrpeachy (2014-03-20 23:18:06)
Offline
MrPeachy,
Thank you so much for your quick reply ! I am very grateful for your help. I will try this week-end what you have sent me and will keep you informed.
Thank you again, I very appreciate your kindness!
Offline
Hello mrpeachy !
Thank you a lot for the gif.lua! I have not yet managed to make it work entirely, but thanks to Didier-T (French contributor to French Ubuntu Forum) it is well underway to precisely adapt it to my particular case. Didier-T has slightly modified your script.
He asked me to transfer it to you in order to share his work as well as thanking you for this script, in hopes you will like it
Here is the link where Didier-T posted his modified version of your script :
And here is this modified version :
gif.lua
--[[
Script gif.lua
By mrpeachy
Modified on 22/03/2014 by Didier-T
prise en charge du contenu complet d'un répertoire avec choix de format (jpg, gif, etc...)
prise en charge des racourcis ~ et $HOME, ainsi que des espaces dans le chemin du repertoire
Translation :
supports full directory content with choice of format (jpg, gif, etc...)
supports shortcuts ~ and $HOME as well as spaces in the directory pathname
#############################################################################################
# #
# Usage #
# #
#############################################################################################
# #
# lua_load ~/gif.lua #
# TEXT #
# ${lua gif repertoire format pos_x pos_y largeur hauteur} #
# #
#############################################################################################
remplacer les espaces par %20 pour le chemin du repertoire
TL : replace spaces by %20 for the directory pathname
]]--
--gifsicle --unoptimize --explode /home/pieter/temp/compdead.gif --output /home/pieter/temp/temp.gif
require 'cairo'
require 'imlib2'
ini=0
count=0
fichier={}
function conky_gif(rep,ext,x,y,w,h)
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 ini==0 then fichier=init(rep, ext) end
show_image=fichier[count]
if count<table.getn(fichier) then
count=count+1
else
count=0
end
image({x=x,y=y,w=w,h=h,file=show_image,decache=1})
cairo_destroy(cr)
cairo_surface_destroy(cs)
cr=nil
return ""
end-- end main function
function init(rep, ext)
ini=1
local home = os.getenv("HOME")
rep = string.gsub(rep, "~", home)
rep = string.gsub(rep, "$HOME", home)
rep=string.gsub(rep, '%%20', "\\ ")
local file=conky_parse("${exec find "..rep.."/*."..ext.." -type f -print}")
return file:split('\n')
end
-- Fonction de découpage maison
function string:split(pat)
-- Détermination du caractère séparant les champs pour le découpage
-- Par défaut ce sera espace
pat = pat or '%s+'
local tab = {}
local x=0
for i in self:gmatch("([^"..pat.."]+)") do
tab[x]=i
x=x+1
end
return tab
end
function image(im)--#######################################################################################
local x=(im.x or 0)
local y=(im.y or 0)
local w=(im.w or 50)
local h=(im.h or 50)
local file=tostring(im.file)
local decache=im.decache or 0
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)
if decache==1 then
imlib_free_image_and_decache()
else
imlib_free_image()
end
imlib_context_set_image(scaled)
imlib_render_image_on_drawable(x,y)
imlib_free_image()
end--function image
Offline
Thanks for letting me know jlfh0816
i hope you get it up and running
Offline
Hello MrPeachy,
Everything is working fine now. Thank you again, I would have never been able to make it work without your and Didier-T's help
Offline
Hello MrPeachy,
Everything is working fine now. Thank you again, I would have never been able to make it work without your and Didier-T's help
Good to hear
can you post the files you are using here for a reference?
Offline
Hello mrpeachy,
Yes of course, I will gladly share my files.
The aim was to have an animated and clickable conky.
This is my conky (named Cube) :
http://nsa34.casimages.com/img/2014/03/18/140318102335206491.gif
The click only served to open the «Images » folder of my Xubuntu 13.10 (no action in the conky).
The 3 files to use are : .conkyrc, gif.lua and Click_info.lua
And the command line to enter in the terminal to launch the whole thing is :
conky -c /home/jlfh0816/essai/.conkyrc
The frames of the animated gif are stored in /home/jlfh0816/temp and are named gif.000, gif.001, gif002, and so on …
The following is the files content :
1°) .conkyrc
# conky on which you clicked must have his own window and a name
own_window_title Cube
# window type and decorations
own_window_argb_visual yes
own_window yes
own_window_type normal
own_window_transparent yes
own_window_hints undecorate,sticky,skip_taskbar,skip_pager,below
# conky size and position
minimum_size 135 135
alignment ml
gap_x 10
gap_y 10
# cube rotation speed
update_interval 0.15
# memory setting, to avoid flickering
double_buffer yes
# remove the memory buffers from the allocated memory
no_buffers yes
text_buffer_size 1024
lua_load ~/essai/Click_info.lua
lua_load ~/essai/gif.lua
TEXT
#Conky animation with images
${lua click}
${lua gif ~/temp * 0 15 135 135}
2°) gif.lua
--[[
Script gif.lua
By mrpeachy
Modified on 22/03/2014 by Didier-T
supports full directory content with choice of format (jpg, gif, etc...)
supports shortcuts ~ and $HOME as well as spaces in the directory pathname
#############################################################################################
# #
# Use #
# #
#############################################################################################
# #
# lua_load ~/gif.lua #
# TEXT #
# ${lua gif folder format pos_x pos_y width height} #
# #
#############################################################################################
replace spaces in the folder pathname by %20
]]--
--gifsicle --unoptimize --explode /home/jlfh0816/temp/cube.gif --output /home/jlfh0816/temp/temp.gif
require 'cairo'
require 'imlib2'
ini=0
count=0
fichier={}
function conky_gif(rep,ext,x,y,w,h)
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 ini==0 then fichier=init(rep, ext) end
show_image=fichier[count]
if count<table.getn(fichier) then
count=count+1
else
count=0
end
image({x=x,y=y,w=w,h=h,file=show_image,decache=1})
cairo_destroy(cr)
cairo_surface_destroy(cs)
cr=nil
return ""
end-- end main function
function init(rep, ext)
ini=1
local home = os.getenv("HOME")
rep = string.gsub(rep, "~", home)
rep = string.gsub(rep, "$HOME", home)
rep=string.gsub(rep, '%%20', "\\ ")
local file=conky_parse("${exec find "..rep.."/*."..ext.." -type f -print}")
return file:split('\n')
end
-- Self-made splitting function (by Didier-T)
function string:split(pat)
-- Determining the separator
-- default : space
pat = pat or '%s+'
local tab = {}
local x=0
for i in self:gmatch("([^"..pat.."]+)") do
tab[x]=i
x=x+1
end
return tab
end
function image(im)--#######################################################################################
local x=(im.x or 0)
local y=(im.y or 0)
local w=(im.w or 50)
local h=(im.h or 50)
local file=tostring(im.file)
local decache=im.decache or 0
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)
if decache==1 then
imlib_free_image_and_decache()
else
imlib_free_image()
end
imlib_context_set_image(scaled)
imlib_render_image_on_drawable(x,y)
imlib_free_image()
end--function image
3°) Click_info.lua (by Didier-T)
--[[
!!! Nécessite l’installation de xdotool !!!
Le conky appelant doit avoir sa propre fenêtre et un nom, par exemple
own_window_title Cube
own_window yes
Dans le conky il faut ajouter :
Avant TEXT
lua_load "Votre chemin"/Clic_info.lua
Après TEXT
${lua click}
Pour obtenir la position de la souris dans le script lié au clic utiliser
posx et posy
Pour ajouter des données récupérées via conky dans la commande à exécuter indiquer dans la ligne de commande arg(x), arg1 sera remplacé par le résultat de arg1, vous disposez de 5 arguments
Les commandes peuvent être exécutées par conky ou directement par le système
Le nom de la fenêtre conky doit être renseigné ci-dessous
]]--
local Fenetre="Cube"
local Bouton={
{
Posx=0,
Posy=15,
Lageur=135,
Hauteur=135,
Commande_Os="nemo /home/jlfh0816/Images",
Commande_Conky="",
arg1="",
arg2="",
arg3="",
arg4="",
arg5="",
},
}
local start=1
local abstlx, abstly
function conky_click()
local mousex, mousey, localx, localy, arg1, arg2, arg3, arg4, arg5
if conky_window == nil then return end
local updates=tonumber(conky_parse('${updates}'))
if updates>2 then
localx,localy=clickfunction()
for i in pairs(Bouton) do
if localx>=Bouton[i].Posx and localx<=Bouton[i].Posx+Bouton[i].Lageur and localy>=Bouton[i].Posy and localy<=Bouton[i].Posy+Bouton[i].Hauteur then
mousex=Bouton[i].Posx+abstlx
mousey=Bouton[i].Posy+Bouton[i].Hauteur+abstly
if Bouton[i].arg1 ~= "" then arg1=conky_parse( "${"..Bouton[i].arg1.."}" ) else arg1=" " end
if Bouton[i].arg2 ~= "" then arg2=conky_parse( "${"..Bouton[i].arg2.."}" ) else arg2=" " end
if Bouton[i].arg3 ~= "" then arg3=conky_parse( "${"..Bouton[i].arg3.."}" ) else arg3=" " end
if Bouton[i].arg4 ~= "" then arg4=conky_parse( "${"..Bouton[i].arg4.."}" ) else arg4=" " end
if Bouton[i].arg5 ~= "" then arg5=conky_parse( "${"..Bouton[i].arg5.."}" ) else arg5=" " end
if Bouton[i].Commande_Os ~= "" then
Bouton[i].Commande_Os=Bouton[i].Commande_Os:gsub("posx", mousex):gsub("posy", mousey):gsub("arg1", arg1):gsub("arg2", arg2):gsub("arg3", arg3):gsub("arg4", arg4):gsub("arg5", arg5)
print(Bouton[i].Commande_Os)
os.execute(Bouton[i].Commande_Os)
end
if Bouton[i].Commande_Conky ~= "" then
Bouton[i].Commande_Conky=Bouton[i].Commande_Conky:gsub("posx", mousex):gsub("posy", mousey):gsub("arg1", arg1):gsub("arg2", arg2):gsub("arg3", arg3):gsub("arg4", arg4):gsub("arg5", arg5)
conky_parse( "${"..Bouton[i].Commande_Os.."}")
end
end
end
collectgarbage()
end
return ""
end
function clickfunction()
local xdot, geometry ,s ,f , click, mousex, mousey, localx, localy
--start click logging and calculations ##########################################
if start==1 then
xdot=os.execute("exec ps ax | awk '/ xdotool search --name "..Fenetre.." behave %@ mouse-click getmouselocation / {print $1}'")
if tonumber(xdot)==1 then
os.execute("kill "..xdot)
end
os.execute("xdotool search --name "..Fenetre.." behave %@ mouse-click getmouselocation >> /tmp/xdo &")
start=nil
local f = io.popen("xwininfo -name '"..Fenetre.."' | grep 'Absolute'")
geometry = f:read("*a")
f:close()
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*)")
end--if 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
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)
localx=mousex-abstlx
localy=mousey-abstly
--END CLICK CALCULATIONS #################################
return localx,localy,mousex,mousey
end--function
I hope to have been helpful ….
Last edited by jlfh0816 (2014-04-17 21:09:06)
Offline
The LUA scripts are cool but... Apparently you can't put the gif above another image.
I mean, if you put ${image 1}${image 2} the image 2 will be displayed above the image 1, but with ${image 1}${lua gif} or ${lua gif}${image 1} the gif will be always under the image 1. O_o
I definitely need to learn Lua. 8.(
Offline
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