Tuesday, 20 January 2009

MakeStatus: A new plasmoid for developers!

I always wanted to develop a plasmoid ever since kde4.0 but I wasn't getting any ideas which had enough driving force in them. Finally, about 2 days back, I got an idea which was the result of "scratch your own itch"!

Let me introduce the functionality of this plasmoid, which served as learning means to me.

Usually we developers keep building from sources quite often. Many a times we do multiple builds in the background. Its quite annoying to monitor the progress staring at the screen. Others start some other work only to realize that the build has completed long time back.
Some smart people invoke echo -e '\a' immediately after make invocation to alert them.

However, wouldn't it be cool to have sneak-peak of the progress somewhere in the panel or as applet on the desktop ?

Especially, cmake has a wonderful method of saying the progress in percentile. So the visualization could really be made simple.

I used this as a use-case and developed a simple data-engine based plasmoid which is made up of following three components.
  • The data-engine, which has a dbus-interface to add, remove make source and also set the progress for an already added make-source.
  • The plasmoid, which at the moment is just a simple visualization, which displays the total progress of all builds.
  • The makeinvoker, which is a simple stand-alone qt-core based program that wraps around make and parses the output of make for progress information. As soon as it finds the progress information, it relays this information to the data-engine using a dbus-call. Also the makeinvoker prints out both the stdout and stderr of the make process to its stdout and stderr.

Here is snapshot of the applet in work


Armed with Techbase, I could grasp the basics quite fast. I really love the architecture of plasma - its flexible, intuitive yet powerful :)
However the codebase of MakeStatus isn't as clean since I am newbie to plasmoids, data-engines and D-Bus. It will take some time to shape up the code.

Some more ideas that can be implemented are:
  1. Notification mechanism to indicate completion of make job (probably with error/warning clue as well if any)
  2. Ability to pause/resume make
  3. Display all make jobs with their progress in an extender when clicked.
As of now there is an issue bugging me and I am afraid there isn't an easy solution for it. The issue is, the "coloring of the output text" by cmake based Makefiles don't work. I don't know how I can read stdout from a QProcess and also forward the same to parent process with coloring. Any help is appreciated :)

Also I somehow could not get data-engine d-bus connection to exist standalone as I wanted. I tried
QDBusConnection::connectToBus(QDBusConnection::SessionBus, "org.MakeStatusEngine")
but somehow that created the connection at ":1.125". I really don't know much dbus - so will resolve this later (or may be I'll get help soon ).
The dbus interface path currently lies in the connection "org.kde.plasma"


BTW, for non cmake based Makefiles there is currently no way to display the progress information. For these build systems, the progress is either 0% or 100% (yeah, its binary in nature ;) )

Thats all I had to say. Any feedback is appreciated. Infact I'd love to listen to many more ideas that can be incorporated into this plasmoid.

10 comments:

gja said...

Dude, this is awesome

gja said...

Errr, where can I get the plasmoid from?

Anonymous said...

Imo it would be even cooler if it could hook into the KDE job-progress framework instead of using an own plasmoid!

Bruno said...

I agree with Anonymous, with the KDE job-progress framework it would look nice.

Good idea, can't wait to use it.

Kraplax said...

Well, that'd be nice to have a popup stderr frame if make errored, and then to have a button for quick post to pastebin.com. Of course, there's a bit more than just stderr, but also a bit of stdout and there should be something like "decide from where plasmoid should begin copy-pasting", but it's solvable, i guess. Wish you luck with this plasmoid and hope it could be ported to Windows too :D

Gopala Krishna said...

Thank you all for the feedback

@gja: Will upload it before this weekend, it requires lots of polishing.

@Anonymous:
@Bruno: The problem of integrating this with job-progress is, people might find the frequent popups to be annoying and distracting.

Is it possible to add a job with ability ,not to show up in the notification of systray ? If so, integrating with jobs will be awesome :)


@Kraplax: Nice idea! Will look into it :)

Diederik said...

> The problem of integrating this with job-progress is, people might find the frequent popups to be annoying and distracting.

Isn't that something different which needs to be resolved? (instead of avoiding the job area) For example, some applications need to become more silent so all job notifications become relevant.

MoRpHeUz said...

Good idea! =)
Cheers!

randomguy3 said...

I suspect your problem with coloured output is that CMake is detecting that its output is not linked directly to a terminal, and is turning off coloured output. This is common behaviour, because the control characters that change the colour can confuse applications and make log files illegible.

I don't know how to force coloured output in CMake, though.

Gopala Krishna said...

@Diederik: Agree. But I didn't use KJob for an other reason as well. There is no easy way out there to just display the total progress of all make jobs using KJob. The total progress is an important aspect to consider IMHO.

Also, this is my first plasmoid - so probably will migrate to KJob after some time :)

@randomguy3: Yeah that could be the reason. Actually I tried setting the environment of process to that of QProcess::systemEnvironment() which also set the TERM to xterm and so on. Yet, it didn't emit colors.

Infact I tested the program with ls command as well, which also didn't emit colors.