PDA

View Full Version : HOWTO: Animated .gif as a background


memorygap
September 22nd, 2008, 01:39 AM
So you went to put that funny animated gif as your desktop background but only the first frame appeared, static and alone? Cheer up, we can make it move.
This is a guide to getting an animated gif centered on your desktop background. I've only tested it in gnome on Hardy Heron. It works with or without compiz. The only caveat is that if you happen to have icons on your desktop the gif may cover these up if it's big enough.

Alright let's open a terminal window and get down to business.
We're going to grab Shantz modified (i.e. fixed) version of xwinwrap (https://launchpad.net/xwinwrap).
Ok we need the source from launchpad, but first we need to install bazaar to get the code, gcc to compile it, and gifsicle to actually display the gifs:
sudo apt-get install bzr build-essential gifsicle
Now let's grab the code:
bzr branch lp:xwinwrap
Let's change into that newly created directory and compile it and then install it.
cd xwinwrap
make
sudo make install

I've created a little script to make centering a gif easy for myself so open up your favorite text editor and copy and paste the following:
#!/bin/sh
# Uses xwinwrap to display given animated .gif in the center of the screen

if [ $# -ne 1 ]; then
echo 1>&2 Usage: $0 image.gif
exit 1
fi

#get screen resolution
SCRH=`xrandr | awk '/current/ { print $8 }'`
SCRW=`xrandr | awk '/current/ { print $10 }'`
SCRW=${SCRW%\,}

#get gif resolution
IMGHW=`gifsicle --info $1 | awk '/logical/ { print $3 }'`
IMGH=${IMGHW%x*}
IMGW=${IMGHW#*x}

#calculate position
POSH=$((($SCRH/2)-($IMGH/2)))
POSW=$((($SCRW/2)-($IMGW/2)))

xwinwrap -g ${IMGHW}+${POSH}+${POSW} -ov -ni -s -nf -- gifview -w WID $1 -a

exit 0

Save this file as gifbg.sh and let's not forget to make it executable:
chmod +x gifbg.sh
Now when we can make our background move:
./gifbg.sh /path/to/animated.gif

You'll probably want to start this script when you login so hit the gnome menu -> system -> preferences -> sessions hit Add and make up a name and copy the command into the appropriate box. Notes: You have to put the complete path to the script in here because gnome doesn't respect the $PATH variable. Also, for some reason the image will appear always on top when it's loaded from boot, one solution is to add a "sleep 5" on top of the script to make sure it loads after the rest of your desktop.

There you go, an animated background using a few megs of ram and an imperceptible amount of cpu time.

To stop the magic happening either Ctrl-C the command if you ran it from the terminal or hit Alt-F2 and type:
killall xwinwrap
To uninstall:
sudo rm /usr/bin/xwinwrap

thestig_992
September 25th, 2008, 04:59 AM
Does anyone have any good gifs to share? preferable some that would work as a background?

binbash
September 25th, 2008, 06:17 AM
awesome guide, it will be cool if someone can share good gifs .

memorygap
September 25th, 2008, 05:10 PM
the gif that made me figure this out is on this page http://squareamerica.com/gif4.htm

toucher5
September 26th, 2008, 04:30 AM
This is a little different than the animated gif but I think it is interesting.

http://gnome-look.org/content/show.php/All+Day+Long+(Animated+Wallpaper)?content=83443

Basically you make an xml file as the background that refers to the pictures of choice. It changes over time. The artist set it up to look like the sun moving in the sky.

I have one in the works and will upload it to gnome-look when its done. So keep a look out.

whitethorn
November 4th, 2008, 09:32 PM
I wasn't able to get this to work in Ibex. Just getting the branch downloaded from launchpad was pretty complicated (had to create a gpg and ssh key). After downloading the folder I wasn't able to make it.

:xwinwrap|$make
gcc -Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -lX11 -lXext -lXrender xwinwrap.c -o xwinwrap
mkdir x86_64
mv ./xwinwrap ./x86_64
gcc -m32 -Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -lX11 -lXext -lXrender xwinwrap.c -o xwinwrap
mkdir i386
mv ./xwinwrap ./i386
:xwinwrap|$sudo make install
make: *** No rule to make target `install'. Stop.


It's really too bad, I was about to use the hypnotoad gif.

http://www.stumbleupon.com/toolbar/#topic=Humor&url=http%253A%252F%252Fgallery2.jpmullan.com%252Fv %252Fscans%252Fblog%252Fhypnotoad.gif.html%253Fg2_ imageViewsIndex%253D1

kranny
February 4th, 2009, 04:47 AM
This is what i get when i try to compile


gcc -Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -lX11 -lXext -lXrender xwinwrap.c -o xwinwrap
xwinwrap.c:39:22: error: X11/Xlib.h: No such file or directory
xwinwrap.c:40:23: error: X11/Xutil.h: No such file or directory
xwinwrap.c:41:23: error: X11/Xatom.h: No such file or directory
xwinwrap.c:42:24: error: X11/Xproto.h: No such file or directory
xwinwrap.c:44:34: error: X11/extensions/shape.h: No such file or directory
xwinwrap.c:45:36: error: X11/extensions/Xrender.h: No such file or directory
xwinwrap.c:97: error: expected ‘)’ before ‘*’ token
xwinwrap.c:110: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
xwinwrap.c:177: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘find_desktop_window’
xwinwrap.c: In function ‘main’:
xwinwrap.c:219: error: ‘Display’ undeclared (first use in this function)
xwinwrap.c:219: error: (Each undeclared identifier is reported only once
xwinwrap.c:219: error: for each function it appears in.)
xwinwrap.c:219: error: ‘dpy’ undeclared (first use in this function)
xwinwrap.c:220: error: ‘Window’ undeclared (first use in this function)
xwinwrap.c:220: error: expected ‘;’ before ‘win’
xwinwrap.c:221: error: expected ‘;’ before ‘root’
xwinwrap.c:222: error: expected ‘;’ before ‘p_desktop’
xwinwrap.c:224: error: ‘XSizeHints’ undeclared (first use in this function)
xwinwrap.c:224: error: expected ‘;’ before ‘xsh’
xwinwrap.c:225: error: ‘XWMHints’ undeclared (first use in this function)
xwinwrap.c:225: error: expected ‘;’ before ‘xwmh’
xwinwrap.c:240: error: ‘Atom’ undeclared (first use in this function)
xwinwrap.c:240: error: expected ‘;’ before ‘state’
xwinwrap.c:244: error: ‘Pixmap’ undeclared (first use in this function)
xwinwrap.c:244: error: expected ‘;’ before ‘mask’
xwinwrap.c:245: error: ‘GC’ undeclared (first use in this function)
xwinwrap.c:245: error: expected ‘;’ before ‘mask_gc’
xwinwrap.c:246: error: ‘XGCValues’ undeclared (first use in this function)
xwinwrap.c:246: error: expected ‘;’ before ‘xgcv’
xwinwrap.c:248: warning: implicit declaration of function ‘XOpenDisplay’
xwinwrap.c:255: warning: implicit declaration of function ‘DefaultScreen’
xwinwrap.c:256: error: ‘root’ undeclared (first use in this function)
xwinwrap.c:256: warning: implicit declaration of function ‘RootWindow’
xwinwrap.c:263: warning: implicit declaration of function ‘XParseGeometry’
xwinwrap.c:275: error: ‘state’ undeclared (first use in this function)
xwinwrap.c:275: warning: implicit declaration of function ‘XInternAtom’
xwinwrap.c:357: error: ‘xsh’ undeclared (first use in this function)
xwinwrap.c:357: error: ‘PSize’ undeclared (first use in this function)
xwinwrap.c:357: error: ‘PPosition’ undeclared (first use in this function)
xwinwrap.c:358: warning: implicit declaration of function ‘DisplayWidth’
xwinwrap.c:359: warning: implicit declaration of function ‘DisplayHeight’
xwinwrap.c:368: error: ‘xwmh’ undeclared (first use in this function)
xwinwrap.c:368: error: ‘InputHint’ undeclared (first use in this function)
xwinwrap.c:373: error: ‘XSetWindowAttributes’ undeclared (first use in this function)
xwinwrap.c:373: error: expected ‘;’ before ‘attr’
xwinwrap.c:374: error: ‘Visual’ undeclared (first use in this function)
xwinwrap.c:374: error: ‘visual’ undeclared (first use in this function)
xwinwrap.c:376: warning: implicit declaration of function ‘findArgbVisual’
xwinwrap.c:383: error: ‘attr’ undeclared (first use in this function)
xwinwrap.c:385: warning: implicit declaration of function ‘XCreateColormap’
xwinwrap.c:385: error: ‘AllocNone’ undeclared (first use in this function)
xwinwrap.c:387: error: ‘win’ undeclared (first use in this function)
xwinwrap.c:387: warning: implicit declaration of function ‘XCreateWindow’
xwinwrap.c:388: error: ‘InputOutput’ undeclared (first use in this function)
xwinwrap.c:389: error: ‘CWBackPixel’ undeclared (first use in this function)
xwinwrap.c:389: error: ‘CWBorderPixel’ undeclared (first use in this function)
xwinwrap.c:389: error: ‘CWColormap’ undeclared (first use in this function)
xwinwrap.c:393: error: expected ‘;’ before ‘attr’
xwinwrap.c:396: warning: implicit declaration of function ‘find_desktop_window’
xwinwrap.c:396: error: ‘p_desktop’ undeclared (first use in this function)
xwinwrap.c:399: error: ‘CopyFromParent’ undeclared (first use in this function)
xwinwrap.c:400: error: ‘CWOverrideRedirect’ undeclared (first use in this function)
xwinwrap.c:410: warning: implicit declaration of function ‘XSetWMProperties’
xwinwrap.c:413: warning: implicit declaration of function ‘setWindowOpacity’
xwinwrap.c:417: error: ‘Region’ undeclared (first use in this function)
xwinwrap.c:417: error: expected ‘;’ before ‘region’
xwinwrap.c:419: error: ‘region’ undeclared (first use in this function)
xwinwrap.c:419: warning: implicit declaration of function ‘XCreateRegion’
xwinwrap.c:422: warning: implicit declaration of function ‘XShapeCombineRegion’
xwinwrap.c:422: error: ‘ShapeInput’ undeclared (first use in this function)
xwinwrap.c:422: error: ‘ShapeSet’ undeclared (first use in this function)
xwinwrap.c:423: warning: implicit declaration of function ‘XDestroyRegion’
xwinwrap.c:428: warning: implicit declaration of function ‘XChangeProperty’
xwinwrap.c:429: error: ‘XA_ATOM’ undeclared (first use in this function)
xwinwrap.c:429: error: ‘PropModeReplace’ undeclared (first use in this function)
xwinwrap.c:434: error: ‘mask’ undeclared (first use in this function)
xwinwrap.c:434: warning: implicit declaration of function ‘XCreatePixmap’
xwinwrap.c:435: error: ‘mask_gc’ undeclared (first use in this function)
xwinwrap.c:435: warning: implicit declaration of function ‘XCreateGC’
xwinwrap.c:435: error: ‘xgcv’ undeclared (first use in this function)
xwinwrap.c:442: warning: implicit declaration of function ‘XSetForeground’
xwinwrap.c:443: warning: implicit declaration of function ‘XFillRectangle’
xwinwrap.c:446: warning: implicit declaration of function ‘XFillArc’
xwinwrap.c:451: error: ‘XPoint’ undeclared (first use in this function)
xwinwrap.c:451: error: expected ‘;’ before ‘points’
xwinwrap.c:459: warning: implicit declaration of function ‘XFillPolygon’
xwinwrap.c:459: error: ‘points’ undeclared (first use in this function)
xwinwrap.c:459: error: ‘Complex’ undeclared (first use in this function)
xwinwrap.c:459: error: ‘CoordModeOrigin’ undeclared (first use in this function)
xwinwrap.c:469: warning: implicit declaration of function ‘XShapeCombineMask’
xwinwrap.c:469: error: ‘ShapeBounding’ undeclared (first use in this function)
xwinwrap.c:472: warning: implicit declaration of function ‘XMapWindow’
xwinwrap.c:476: warning: implicit declaration of function ‘XLowerWindow’
xwinwrap.c:479: warning: implicit declaration of function ‘XSync’
xwinwrap.c:513: warning: implicit declaration of function ‘XDestroyWindow’
xwinwrap.c:514: warning: implicit declaration of function ‘XCloseDisplay’
make: *** [all64] Error 1

Bachstelze
March 23rd, 2009, 01:18 PM
@kranny

sudo apt-get install xorg-dev

[.root/fail]
April 3rd, 2009, 01:00 AM
This is after getting the stuff from the post before me and running the rest of the first post I could:



fail@dotroot:~/xwinwrap$ cd xwinwrap
bash: cd: xwinwrap: No such file or directory
fail@dotroot:~/xwinwrap$ make
gcc -Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -lX11 -lXext -lXrender xwinwrap.c -o xwinwrap
mkdir x86_64
mv ./xwinwrap ./x86_64
gcc -m32 -Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -lX11 -lXext -lXrender xwinwrap.c -o xwinwrap
In file included from /usr/include/features.h:354,
from /usr/include/sys/types.h:27,
from /usr/include/X11/Xlib.h:52,
from xwinwrap.c:45:
/usr/include/gnu/stubs.h:7:27: error: gnu/stubs-32.h: No such file or directory
make: *** [all32] Error 1
fail@dotroot:~/xwinwrap$ sudo make install
[sudo] password for kyo:
make: *** No rule to make target `install'. Stop.
fail@dotroot:~/xwinwrap$

Earl_Maroon
May 5th, 2009, 12:02 PM
I wasn't able to get this to work in Ibex. Just getting the branch downloaded from launchpad was pretty complicated (had to create a gpg and ssh key). After downloading the folder I wasn't able to make it.



It's really too bad, I was about to use the hypnotoad gif.

http://www.stumbleupon.com/toolbar/#topic=Humor&url=http%253A%252F%252Fgallery2.jpmullan.com%252Fv %252Fscans%252Fblog%252Fhypnotoad.gif.html%253Fg2_ imageViewsIndex%253D1
@ Whitethorn:

This happened to me too. All that has happened is that the winwrap ececutable file hasn't been moved to /usr/bin, which isn't too much of a problem. You could move it or alter the script to direct to the file. Depending on your architecture the file to direct to is in i386 or x86_64 in the winwrap directory.

asm_Coty
May 5th, 2009, 12:38 PM
Fascinating tutorial, I will be sure to pass this one on :D

angels21usa
January 12th, 2010, 08:13 PM
Hey,

I just want to say thank you for the HOWTO. I got the xwinwrapper working with my gif images. When I start it the gifs initially show up in the background, but when I click on the image it covers up all of my other programs including the panels. I was wondering if anyone might know a way to keep the gif image on the desktop even when it is clicked.

Thanks for any help in advance

Chiapo
January 17th, 2010, 07:46 PM
Awesome!

I especially like post #5) http://ubuntuforums.org/showpost.php?p=5858279&postcount=5

What a wonderful concept using xml to change the image!

For myself, I prefer to create my own animations using gimp, or a free online service like http://imator.com/

Thanks for sharing!

d3v1150m471c
March 15th, 2010, 07:28 PM
mplayer -gif89a yourvideo.avi

You can use mplayer like so to create gif animations from video.

TheProphetJonah
June 4th, 2011, 01:21 PM
I couldn't get the .c file to "make" so make install just gave me the old familiar "no rule to make install -stop" message.
So I left out of that and went looking for a .deb file and found it on mediafire xwinwrap_1386.deb dl'ed it and dpkg'ed it.
I'm assuming it's going to work.

From my limited reading on the possible uses, it seems that I can use the gif as a background in any xwindow, yes/no?

Hopefully. But I've got this really cool word-by-word or chunk-by-chunk text reader called "dictator", got Orca and this really simple hipno-spiral that will stretch across the desktop or any window.

Bam, instant hypnosis session where I can insert any text I want.

Hopefully it will work, one other thing though, no worries or hurries, but does either the gif tool or xwinwrap make it a transparent layer?
Da Gimp has a tool that supposedly works for that but I've not advanced that far.

el_itur
October 26th, 2011, 10:57 AM
This gif would make a great wallpaper

http://i.imgur.com/l3LL3.gif (http://i.imgur.com/l3LL3.gif)

I would love to see some native solution :D

Angelus-Michael
October 26th, 2011, 12:31 PM
Awesome. Respect man

DrDunkMcNally
May 17th, 2012, 03:03 PM
;7004013']This is after getting the stuff from the post before me and running the rest of the first post I could:



fail@dotroot:~/xwinwrap$ cd xwinwrap
bash: cd: xwinwrap: No such file or directory
fail@dotroot:~/xwinwrap$ make
gcc -Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -lX11 -lXext -lXrender xwinwrap.c -o xwinwrap
mkdir x86_64
mv ./xwinwrap ./x86_64
gcc -m32 -Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -lX11 -lXext -lXrender xwinwrap.c -o xwinwrap
In file included from /usr/include/features.h:354,
from /usr/include/sys/types.h:27,
from /usr/include/X11/Xlib.h:52,
from xwinwrap.c:45:
/usr/include/gnu/stubs.h:7:27: error: gnu/stubs-32.h: No such file or directory
make: *** [all32] Error 1
fail@dotroot:~/xwinwrap$ sudo make install
[sudo] password for kyo:
make: *** No rule to make target `install'. Stop.
fail@dotroot:~/xwinwrap$

It seems like this is because you must choose which install you are going to run with from the "Makefile" if you wrote "sudo make install32" it would work for you, 64-bit would use "sudo make install64"

I followed all of the op's instructions but i'm facing an issue of my own, I got my exploding heads gif on my background (had to add sleep 5 to the script) but as soon as there are no windows open, xwinwrap jumps to the front again and I've got exploding zombie heads right in the middle of everything. any ideas how to prevent this?

here's the gif (it's small, but it's still great!)

edit: So upon further investigation, the gif will stay in the background unless I happen to click on it at which point it sits in the middle of the screen on top of everything. i haven't changed the gifbg.sh options.