Articles tagged with "KDE"

The pyKonsole distraction

I use KDE 4. One of my workspaces is configured with a "dashboard" activity, displaying all the usual monitoring widgets (CPU, RAM, network, temperatures). When my notebook starts acting slow, I hop over to the dashboard to check out my CPU load. If it's high I whip out Konsole and launch htop to find the culprit. It has occurred to me that it would really be nice if I could see the CPU hog right away.

I realized there must be a process-monitor plasmoid out there but a Konsole widget seemed so much more flexible. Plasmacon seemed to fit the bill and I had it on the desktop in next to no time. It turned out, however, that it has no facility to launch a command at start-up. I figured it should be easy to extend the widget as it's written in Python. Checking the documentation for Konsole's KPart turned up two promising methods: sendInput() and startProgram(). Neither of them worked.

I inserted some trace code into Plasmacon's init method and it turned out that the object Plasmacon creates is just a plain KParts::ReadOnlyPart. Browsing PyKDE documentation brought the answer: PyKDE doesn't include a binding for kdebase-apps. The upshot is that you can create a Konsole::Part instance from Python but you can't access its full API.

Things didn't look so trivial anymore but I decided to have a go at creating the necessary bindings. PyKDE uses a generator called SIP (apt-get install python-sip in Debian) to create Python modules from C++ headers and deceptively simple spec files. I tried to write a SIP spec for Konsole starting from Konsole::Part's header file and various .sip files I dug up. I have to say SIP provides rather modest feedback. I ended up stuck with a terse "syntax error" message providing no detail at all.

I noticed a little comment in one of the .sip files, saying "Generated by twine". Googling for twine proved to be quite a challenge; this is really obscure code used primarily by PyKDE creators and few others. There is no website nor documentation. Another comment in a .sip file provided the decisive clue: a mention of "twine2". It brought me to where the tool currently seems to live. And yes, it's a generator of input for a generator. Go figure...

Writing a twine2 script seemed quite daunting but I came up with an entirely different approach: what if I could talk to the Konsole via DBus? I quickly discovered qdbusviewer and clicked around to see what I could do. Unfortunately, while the org.kde.plasma-desktop service does expose a /Konsole object, it doesn't provide its Sessions. Some could be found under org.kde.konsole but they included strictly sessions in proper Konsole windows; the one in the Plasma widget didn't show up in the list. I had to go back to twine2.

Except I didn't. The ability to delve into the guts of open source software is one of its most useful aspects but there is a limit to how far down the rabbit hole one can reasonably afford to go. I've reached that limit and had to accept that, for the foreseeable future, I will simply not have a process monitor on my dashboard. Worse things have happened.

« Page 1 / 1 »
Proudly powered by Pelican, which takes great advantage of Python.