Articles

wmbadapple

Notice: This page is currently a work in progress and I will rewrite/reformat parts of it in the near future.

Also Merry Christmas, lainon!

For some time now I've wanted to make my own dockapp, so that I could customize Window Maker to my liking better. One other thing I've also wanted to do is to 'port' Bad Apple to something, but it never occurred to me that I could do both of these at the same time... that is until now. So I present to you: Bad Apple running as a dockapp on my desktop (it doesn't have any audio).

Yes... I know that it's been done to death at this point and that this application is utterly useless, you don't have to tell me. I wrote it just for fun and most of it was done in a single afternoon. If you wish to run it for yourself, you can download the code and binaries here: wmbadapple. Before running it however, I do want to preface that I am not a programmer by any stretch of the imagination. This app is a modified example program ("Morning on earth" by Jonas Aaberg) which was included in the library I used. The library is called GAI, short for General Applet Interface. I packaged it together with wmbadapple, but it can also be found here. You will need to have it installed if you wish to run this app.

The reason I chose this library (aside from being lazy) was that it was relatively simple to work with, contained the most amount of documentation compared to all the other (three) libraries listed on the dockapps website, and had an example program included with everything I needed to write this app.

How it works

I must warn you beforehand that this was, as mentioned before, written in a single afternoon without any regards to optimization. I basically just wanted to get it to a functional state, as quick as possible, so that it doesn't end up in a pile with all the other scrapped projects and ideas of mine. I am kind of embarrassed to share it because of how stupid it is, but at the same there isn't really a point in creating it if I don't. Besides, this way someone more skilled than I am might rewrite it/make their own version (if that doesn't already exist, I wasn't able to find it). I am aware that actual video player dockapps exist which could accomplish this and much more with less resources (this uses an absurd amount of memory for some reason and I can't figure out why), but I still wanted to make my own.

With that out of the way, this is a pretty simple program. It just loads a really large image that contains each individual frame, in essence just an image sequence, and then iterates over each frame and updates the applet at what should be 30 times a second, although I think it does run a bit slower. Left click pauses it, and middle click restarts the animation.

Click here to view the code
/* 

   Bad Apple for your dock.

   - Rewritten from Jonas Aaberg's <cja@gmx.net> GAI example "Morning on earth".
     The example is included in gai-0.5.x
     (which can be obtained here: https://gai.sourceforge.net/)

   Requires GAI version 0.5.3 or later.

   Released under GNU GPL.
   
*/

#include "config.h"
#include <gai/gai.h>

#define HEIGHT 64
#define WIDTH 64
#define FRAMES 6572

static int frame_counter = 0;
static GdkPixbuf *img;
int n = 0;

void update()
{
	//stupid
	if(n == 0){
		if(frame_counter == FRAMES-1)
			frame_counter = 0;
		else 
			frame_counter++;
		gai_draw_bg(img, 0, frame_counter*HEIGHT, 
		WIDTH, HEIGHT, 0,0);
		gai_draw_update_bg();

	}
}

void ispaused()
{	
	if(n == 1)
		n = 0;
	else
		n = 1;
} 

void reset()
{
	frame_counter = 0;
	n = 0;
}

int main(int argc, char **argv)
{
    GaiFlagsType gf = GAI_FLAGS_NEVER_ROTATE;
    gai_init2(&applet_defines, &argc, &argv);
    img = gai_load_image("./images/wmbadapple.png");
    gai_background_set(WIDTH, HEIGHT, GAI_BACKGROUND_MAX_SIZE_NONE, TRUE);
    gai_flags_set(gf);
    gai_signal_on_update((GaiCallback0 *)update, 33.33, NULL);
    gai_signal_on_mouse_button_click((GaiCallback2 *)ispaused, GAI_MOUSE_BUTTON_1, NULL);
    gai_signal_on_mouse_button_click((GaiCallback2 *)reset, GAI_MOUSE_BUTTON_2, NULL);
    gai_start();
    return 0;
}

Before running

You will need to have GAI installed for this to work. It can be a pain getting it to compile, for this reason I've included binary files for GAI and wmbadapple, which I've compiled myself, and an install script for said files packaged together with the source code. Please read the install script before running, I've only tested the script on a single Debian 13 installation and everything is hardcoded without any checks. I might clean this up in the future.

The size of the frames is 64x64 and it doesn't adjust/recenter when the "Icon Size" of your dock is set to anything other than that in Window Maker. I wasn't able to figure out how to fix this, and looking at other programs written with GAI it seems like they also have this issue, although I haven't checked all of them. This is also the reason the image is 1:1 and not 4:3. A simple solution would be to render the image sequence according to your "Icon Size" setting (e.g. 70x70, 80x80 etc.), I might do this and have multiple downloads available in the future.

Another note before running is that it also doesn't have any audio. I might also try adding that in the future.

Installing/running

More detailed instructions are included in the README and INSTALL files inside the archive.

Firstly you will need to have GAI installed, you can compile it yourself (the source code is in source/gai-0.5.10/) or you could try installing the included binaries (compiled/lib/), but please read the README if you decide to use the binaries

After that you should be able to compile wmbadapple without issue and run it with wmbadapple, however a binary is also included (compiled/wmbadapple). Again more detailed instructions are in the archive.

Date written: 25. Dec 2025

25. Dec 2025 - Last page update.