July 18, 2011

Qt/Caca Lighthouse Plugin

lighthouse_ascii

At the Qt Contributors Summit, Johannes‘ showed me his Qt/Caca Lighthouse plugin. Caca is a graphics library to output text instead of pixels. So this plugin lets you run Qt programs on the console :-)

His code needed some love, so I forked it and cleaned it up. Caca does not provide a event fd and so we have to keep polling caca for events. Since this wasn’t ideal, I moved the event handling to a separate thread and blocked for events. Unfortunately, I found that the caca library is not thread-safe and rendering and processing events in separate threads makes caca crash at randomly. So, I ended up moving the rendering to the event processing thread and having to resurrect the 20ms event timer again :-( The cool thing though is that now Qt renders to QImage in the main ui thread and hands it off to caca. Caca opens a X connection (or similar), converts the image into text, displays a window and handles events in another thread. With some refactoring and thanks to QMetaObject::invokeMethod, the threaded and non-threaded rendering are pretty much the same and can be switched using an environment variable (THREADED_CACA=1).

Animated tiles:

If you want to hack further, code is on gitorious. (Caca doesn’t seem to deliver gpm events with ncurses, so that would be a nice fix to have)

Update: Welcome slashdot readers

21 Responses to “Qt/Caca Lighthouse Plugin”

  1. bq says:

    This. Is. 1337!

  2. Paul Gideon Dann says:

    That is pure awesomeness! It might even be useful, but I’m not sure what for. Have there been any ideas?

  3. Rich Moore says:

    Is it a coincidence this is this is published just after we hear about accelerated text rendering in QML? Perhaps this is the compatibility layer we’ve been promised… :-)

  4. vicky says:

    caca means poop in spanish :p

  5. Girish says:

    @Paul: It’s a great demo for publicizing Lighthouse :-) Hopefully, it inspires others to port Qt to other platforms.

  6. Donald says:

    @Paul:

    The purpose it served for the original developer was to get Qt running on a X-less server hovering near the coffee machine.

  7. Mario C├ęsar says:

    I confirm, that is not the best name for a software, so, can we rename it as “Ca Ca”, or “Cac A”. Sorry for beeing childish… but “poop”?

  8. Spanish person says:

    caca is NOT a good name, take my word

  9. Girish says:

    @Mario, @Spanish person: I didn’t give libcaca it’s name. libcaca is an existing project by Caca Labs (http://caca.zoy.org/wiki/libcaca).

  10. Raven says:

    Libpoop, another great name… Bad, bad.

  11. exn says:

    what about the linux’s framebufer ? it would be looking much better
    than ascii characters.

  12. anonim says:

    Caca means crap/shit in Romanian. Just sayin…

  13. anon says:

    I think they are well aware of the meaning of the word, you’d realize that if you visited the project page.

  14. Johannes says:

    caca even in german means shit :-)

    My main usecase actually is to have my ssh login message animated.

    I also have the qtcompositor running with caca backend, to have multiple applications composited within the same console.

    There are plenty of use cases ;-)

  15. Vincenzo Romano says:

    The Library name is actually unfortunately ridiculous for all those speaking a latin-based language.
    Please, please, change its name! For the sake of the world.

  16. Dom says:

    The name is intentional. The caca project page explains the name by a quote french quote which approximately translates by:
    “There’s nothing really beautiful that has no use; what is useful is ugly, because it is the expression of some need, and those of man are ignoble and disgusting, as his poor and crippled nature. The most useful place in a house is its toilets.”

  17. Menestrel says:

    Let’s add that the authors of the projects seem to be proud of their project being unuseful. Another quote on the same page translates like this :

    “What did you say ? It’s unuseful ? I do know it.
    But you do not fight in hope of victory.
    No, no it’s far more beutiful when it is not useful !”
    from Cyrano de Bergerac, by Edmond Rostand.

  18. M says:

    Animated Login-message? That’s cool! Can you show an example you are using?

    Thank you

  19. Benjamin Meyer says:

    How well does the demo browser run? Could this be used without X11? (i.e. a console browser)

  20. Cattle Barriers says:

    Nice blog right here! Also your web site a lot up fast! What host are you using? Can I get your affiliate hyperlink on your host? I wish my site loaded up as fast as yours lol

  21. lolo says:

    Caca = shit in spanish.. nice name ! xD

Leave a comment

(email will not be published)