Monday, May 9, 2011

Hello, Vala!

A while ago I've been playing with Vala. The cool thing about Vala is that it's a cutting edge language which is able to produce programs with similar performance to those written directly in C. Obviously, it may prove to be a perfect language for fast audio-processing tasks, and there already are bindings for JACK, liboil (now removed from PySoy), an ongoing effort to create bindings for libsndfile and probably other libraries, which I overlooked.

For the exercise, I tried to create Vala bindings for liblo, the lightweight OSC protocol library. They're still unpolished, but already usable in a straightforward, almost C-like way:
static void main(string[] args)
{
    Lo.Address t = new Lo.Address(null, "8080");
    Lo.send(t, "/box/grid/led/all", "i", 1);
}
Right now, I'm working on Vala bindings for LV2 and the accompanying Lilv library. For this purpose and for further experiments with LV2 plugins I've created uSynth capsula - a project, which currently provides little more than a functional port of lv2jack host from Lilv source distribution. It does not have any support for plugin GUIs yet, but it's a planned feature. Loading GUIs with SLV2 (a Lilv predecessor) worked to some extent:


Capsula is still in the earliest planning stages and doesn't have a roadmap yet. For now, I'm thinking about a full featured LV2 plugin host, completely controllable by OSC. I don't have any further ideas, but perhaps you have? Then, by all means, feel free to join the fun!

Saturday, April 30, 2011

Natty Release Party: success!

The release party in Gorno-Altaisk turned out to be the best release party we ever had, a really joyful evening. I have no idea how many people came, but the place was certainly full of people, who continued to arrive.

We had the usual bulk of DVDs to give out, a talk about free software and Ubuntu, a talk about the local media environment, and lots of interaction and conversations about Ubuntu and open source. For the entertainment part, there was a Mafia game with a geek theme and some live music, performed under Linux with the monome (actually an arduinome) controller and rove.

Several pictures from the event are below, and the full set is available here (courtesy of the Shum webzine).

Во время лекции о свободном софте Игра в "гик-мафию" Вечеринка Гости интересуются мономом

Thursday, February 24, 2011

Writing PolicyKit applications in Python without D-Bus

I'm always happy when more libraries get Python bindings, and today I've been especially excited by the fact that GObject introspection support for PolicyKit has finally appeared in Natty repositories. Basically it means, that PolicyKit is now accessible from Python through a native API without direct D-Bus communication. I've tried to port the querying example from PolicyKit manual and it did work!

The Python example below is an almost line-by-line port of the original, but it should give you a basic idea on how to use the API for your own scripts.

#! /usr/bin/env python

import sys, os
from gi.repository import GObject, Gio, Polkit

def on_tensec_timeout(loop):
  print("Ten seconds have passed. Now exiting.")
  loop.quit()
  return False

def check_authorization_cb(authority, res, loop):
    try:
        result = authority.check_authorization_finish(res)
        if result.get_is_authorized():
            print("Authorized")
        elif result.get_is_challenge():
            print("Challenge")
        else:
            print("Not authorized")
    except GObject.GError as error:
         print("Error checking authorization: %s" % error.message)
        
    print("Authorization check has been cancelled "
          "and the dialog should now be hidden.\n"
          "This process will exit in ten seconds.")
    GObject.timeout_add(10000, on_tensec_timeout, loop)

def do_cancel(cancellable):
    print("Timer has expired; cancelling authorization check")
    cancellable.cancel()
    return False

if __name__ == "__main__":
    if len(sys.argv) != 2:
        print("usage: %s <action_id>" % sys.argv[0])
        sys.exit(1)
    action_id = sys.argv[1]

    mainloop = GObject.MainLoop()
    authority = Polkit.Authority.get()
    subject = Polkit.UnixProcess.new(os.getppid())

    cancellable = Gio.Cancellable()
    GObject.timeout_add(10 * 1000, do_cancel, cancellable)

    authority.check_authorization(subject,
        action_id, #"org.freedesktop.policykit.exec",
        None,
        Polkit.CheckAuthorizationFlags.ALLOW_USER_INTERACTION,
        cancellable,
        check_authorization_cb,
        mainloop)

    mainloop.run()

In order to run this example, make sure you have the gir1.2-polkit-1.0 package installed and provide an action in the command line, for example:

./polkit-test org.freedesktop.policykit.exec

I suppose, the API is still a little rough on the edges, but it's already usable and I'm going to try it for an upcoming D-Bus service in indicator-cpufreq. Looks like it's perfect time to start moving things to GObject introspection already.

Friday, February 18, 2011

Hello Planet Ubuntu!

Greetings to all the Planet readers! I've become an Ubuntu member today (or was it yesterday in Americas?), and this is my first post on Planet Ubuntu.

My name's Artem Popov and I am an active member of the Russian Ubuntu Translators team. Sometimes, I also help with packaging / bugs and I intend to become a MOTU in the future.

Ubuntu is my favourite distribution for a long time now, because I believe it has many things done right from the very start. Contributing to Ubuntu is a great opportunity to gain new experience and it's always a pleasure to work with such a rocking community.

For now, I am going to continue my work on translations and packages with the MOTU team, but maybe I shall try some other ways of helping out. Fortunately, there are plenty of them!