Everything Optimus
http://everythingoptimus.com/

Running it on Linux
http://everythingoptimus.com/viewtopic.php?f=19&t=78
Page 1 of 1

Author:  MrTweek [ Tue Apr 22, 2008 5:27 am ]
Post subject:  Running it on Linux

As I only run Linux on my computer, I had to do some manual work to get it running.

At first I wrote a little tool, to convert tiff images to the art.lebedev format of these sys-files. Here's the source. You'll need libtiff and libtiff-dev to compile and run it. argv[1] is the input file (must be tiff, 48x48), argv[2] is the resulting sys-file.
Code:
#include <tiffio.h>

int main(int argc, char* argv[]) {
        TIFF* bild;

        uint32 raster[48*48];
        uint16 res[48*48];

        bild = TIFFOpen(argv[1], "r");
        TIFFReadRGBAImage(bild, 48, 48, raster, 0);

        for (int y = 0; y < 48; y++) {
                for (int x = 0; x < 48; x++) {
                        res[x+48*y] = ((TIFFGetR(raster[x+48*y]) & 0xF8) | (TIFFGetG(raster[x+48*y]) >> 5)) | (((TIFFGetB(raster[x+48*y]) >> 3) | ((TIFFGetG(raster[x+48*y]) >> 2) & 0x07)) << 8);
                }
        }

        FILE* f;
        f = fopen(argv[2], "w");
        for (int y = 47; y >= 0; y--) {
                for (int x = 0; x < 48; x++) {
                        fwrite(&(res[x+48*y]), sizeof(uint16), 1, f);
                }
        }
        fclose(f);
        return 0;
}

I didn't do much testing or error handling, but it basically works for me. Will probably update it soon.

Now you can create your key-images with your favourite image manipulation application.
To activate them, I just wrote some little shell scripts, that look like this:
Code:
#!/bin/bash

./tiff2sys/tiff2sys keys/normal_q.tiff /media/VirtualDisk/vOptimus/normal/086.sys
./tiff2sys/tiff2sys keys/normal_w.tiff /media/VirtualDisk/vOptimus/normal/075.sys
./tiff2sys/tiff2sys keys/normal_e.tiff /media/VirtualDisk/vOptimus/normal/069.sys
./tiff2sys/tiff2sys keys/normal_r.tiff /media/VirtualDisk/vOptimus/normal/070.sys
./tiff2sys/tiff2sys keys/normal_t.tiff /media/VirtualDisk/vOptimus/normal/059.sys
./tiff2sys/tiff2sys keys/normal_y.tiff /media/VirtualDisk/vOptimus/normal/060.sys
./tiff2sys/tiff2sys keys/normal_u.tiff /media/VirtualDisk/vOptimus/normal/054.sys
./tiff2sys/tiff2sys keys/normal_I.tiff /media/VirtualDisk/vOptimus/normal/053.sys
./tiff2sys/tiff2sys keys/normal_o.tiff /media/VirtualDisk/vOptimus/normal/043.sys
./tiff2sys/tiff2sys keys/normal_p.tiff /media/VirtualDisk/vOptimus/normal/044.sys
./tiff2sys/tiff2sys keys/normal_a.tiff /media/VirtualDisk/vOptimus/normal/083.sys
./tiff2sys/tiff2sys keys/normal_s.tiff /media/VirtualDisk/vOptimus/normal/076.sys
./tiff2sys/tiff2sys keys/normal_d.tiff /media/VirtualDisk/vOptimus/normal/068.sys
./tiff2sys/tiff2sys keys/normal_f.tiff /media/VirtualDisk/vOptimus/normal/067.sys
./tiff2sys/tiff2sys keys/normal_g.tiff /media/VirtualDisk/vOptimus/normal/062.sys
./tiff2sys/tiff2sys keys/normal_h.tiff /media/VirtualDisk/vOptimus/normal/061.sys
./tiff2sys/tiff2sys keys/normal_j.tiff /media/VirtualDisk/vOptimus/normal/051.sys
./tiff2sys/tiff2sys keys/normal_k.tiff /media/VirtualDisk/vOptimus/normal/052.sys
./tiff2sys/tiff2sys keys/normal_I.tiff /media/VirtualDisk/vOptimus/normal/046.sys
./tiff2sys/tiff2sys keys/normal_z.tiff /media/VirtualDisk/vOptimus/normal/077.sys
./tiff2sys/tiff2sys keys/normal_x.tiff /media/VirtualDisk/vOptimus/normal/066.sys
./tiff2sys/tiff2sys keys/normal_c.tiff /media/VirtualDisk/vOptimus/normal/065.sys
./tiff2sys/tiff2sys keys/normal_v.tiff /media/VirtualDisk/vOptimus/normal/063.sys
./tiff2sys/tiff2sys keys/normal_b.tiff /media/VirtualDisk/vOptimus/normal/064.sys
./tiff2sys/tiff2sys keys/normal_n.tiff /media/VirtualDisk/vOptimus/normal/050.sys
./tiff2sys/tiff2sys keys/normal_m.tiff /media/VirtualDisk/vOptimus/normal/049.sys

sync

The sync at the end is important to commit the changes. Otherwise they will be kept in the fs-cache and it will take a while until the changes take effect.

To generate text on the fly, you can use imagemagick:
Code:
convert -size 48x48 xc:black -font Verdana-Bold -pointsize 16 -fill white -draw "text -1,32 'wtf?'" /tmp/esc.tiff
This will generate a little tiff file containing the text 'wtf?'. Now copy it into your keyboard:
Code:
./tiff2sys/tiff2sys /tmp/esc.tiff /media/VirtualDisk/vOptimus/normal/099.sys
Check the docs of imagemagick for adding more cool effects.

Some cool dynamic stuff:
Code:
#!/bin/bash
convert -size 48x48 xc:black -font Verdana-Bold -pointsize 16 -fill white -draw "text -1,32 '`date +%H:%M`'" time.tiff
./tiff2sys/tiff2sys ~/time.tiff /media/keyboard/vOptimus/normal/078.sys
sync

This will put the current time into your spacebar. I'm using cron, to update it every minute.

Any more Linux users out there? Let me know, how you handle your Optimus.
Questions or problems with my scripts? Feel free to ask.

Author:  Atomic [ Tue Apr 22, 2008 9:41 am ]
Post subject:  Re: Running it on Linux

Excellent work MrTweek!

Page 1 of 1 All times are UTC + 10 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/