Unity of Command

Steam-pelikauppa tuli vihdoin Linuxille. Tietenkin sieltä täytyi heti jotain ostaa. Oma Linux-rauta on sen verran vanhaa, ettei aivan uusimmat 3D-räiskinnät oikein toimi. Strategiapeli Unity of Command oli julkaisualennuksessa, vaati vähän koneelta ja vaikutti hyvältä.

Unity of Command Ubuntulla

Tyyliltään Unity of Command on hyvin lähellä perus sotalautapelejä, kuten Tide of Ironia. Vaikeusaste on kohdallaan, sillä skenaarioita joutuu pelaamaan useamman kerran, että pääsee läpi. Tide of Ironiin verrattuna mukana joukkojen huoltoketju, jota täytyy ylläpitää. Jos huoltoketju katkeaa ja yksikkö jää vihollislinjojen taakse, ei se jaksa sotia pitkään. Parin pelin jälkeen täytyy todeta, että Unity of Command on täyden viiden tähden strategiapeli.

Categories: Pelit, Lautapelit, Ubuntu
Date: 2013-02-23 17:40:24

Simple text applet for Ubuntu's Unity panel

Since upgrading Debian left me with broken X, I tried to use Ubuntu for couple of days. I have to confess that Unity is a nice piece of software. On Debian I have nice setup with awesome window manager (framework!) that displays line of text on the panel. I wanted to have the same on functionality with Unity. It was not that hard.

Unity Panel

I wrote a small Python program that executes command every 37 seconds, reads that commands output and puts that on the Unity panel. Simple task. The actual output generated by the command is more complicated, since it displays my next calendar entry, near by weather from the Finnish weather service and couple of mailboxes. I am not going to describe its inner logic in detail here. But basically the Python program is the applet

Here is the Python applet.

#!/usr/bin/env python
import sys
import gtk
import appindicator

import subprocess

PING_FREQUENCY = 37 # seconds

class PetteriApplet:
    def __init__(self):
        self.ind = appindicator.Indicator("petteri",
                                           "petteri",
                                           appindicator.CATEGORY_APPLICATION_STATUS)
        self.ind.set_label("petteri")
        self.ind.set_status(appindicator.STATUS_ACTIVE)
        self.ind.set_attention_icon("new-messages-red")

        self.menu_setup()
        self.ind.set_menu(self.menu)

    def menu_setup(self):
        self.menu = gtk.Menu()
        self.quit_item = gtk.MenuItem("Quit")
        self.quit_item.connect("activate", self.quit)
        self.quit_item.show()
        self.menu.append(self.quit_item)

    def main(self):
        self.check_line()
        gtk.timeout_add(PING_FREQUENCY * 1000, self.check_line)
        gtk.main()

    def quit(self, widget):
        sys.exit(0)

    def check_line(self):
        line = subprocess.check_output(["/home/petteri/bin/combine"])
        self.ind.set_label(line.strip())
        return True

if __name__ == "__main__":
    indicator = PetteriApplet()
    indicator.main()

After the Python program was finished I created ~/.config/autostart/petteri-applet.desktop file with the following content:

[Desktop Entry]
Name=Petteri
Comment=Show string in panel
Icon=Petteri
Exec=/home/petteri/bin/petteri-applet
Terminal=false
Type=Application
NoDisplay=true
NotShowIn=KDE;
X-GNOME-Bugzilla-Bugzilla=GNOME
X-GNOME-Bugzilla-Product=NetworkManager
X-GNOME-Bugzilla-Component=general
X-GNOME-Autostart-enabled=true
X-Ubuntu-Gettext-Domain=petteri-applet

The .desktop dictates that every time I start Unity the Python applet (/home/petteri/bin/petteri-applet) will be also started. Works nicely

Categories: Ubuntu, Avoin, Debian, English
Date: 2012-09-30 18:28:48