

Plasma 4 Extensions
Good thinking there :D
I've looked at what Awesome (the WM) widget's do. They use Lua's io.popen which allows to monitor the stdout of a program asynchronously.
From what I can tell there is no direct equivalent in Plasma's JavaScript API. Instead you're supposed to use the "executable" date engine. It starts a process, waits for it to finish and sends you the stdout,stderr etc. to the slot it was connected it to. You can't monitor a long running process with it, since it won't call the slot until the program has finished execution.
In case of "mpd" this isn't an issue though. It's a daemon that can be queried by short running programs, foremost "mpc". In other cases there is always the workaround to provide a shell script that starts, reads some data and exits.
Since I can't edit comments to fix errors, I'll add the paste link to some code in the description above. I think of a better method to share such snippets later. Maybe a thread on forum.kde.org is a good idea.
- Feb 24 2012
I've looked at what Awesome (the WM) widget's do. They use Lua's io.popen which allows to monitor the stdout of a program asynchronously.
From what I can tell there is no direct equivalent in Plasma's JavaScript API. Instead you're supposed to use the "executable" date engine. It starts a process, waits for it to finish and sends you the stdout,stderr etc. to the slot it was connected it to. You can't monitor a long running process with it, since it won't call the slot until the program has finished execution.
In case of "mpd" this isn't an issue though. It's a daemon that can be queried by short running programs, foremost "mpc". In other cases there is always the workaround to provide a shell script that starts, reads some data and exits.
Since I can't edit comments to fix errors, I'll add the paste link to some code in the description above. I think of a better method to share such snippets later. Maybe a thread on forum.kde.org is a good idea.
- Feb 24 2012
The code of version 0.1 worked well, but looked horrible. That became very clear when I wrote the documentation on how to change/tweak it. Changes all over the place were needed and then this giant "if else if" chain.. *shiver*.
As of version 1.0 I'm really happy with the code and feel confident enough to say: Thank you :D
The real work however was and will be the documentation. If you have any questions or suggestions, feel free to ask them here. - Feb 19 2012
As of version 1.0 I'm really happy with the code and feel confident enough to say: Thank you :D
The real work however was and will be the documentation. If you have any questions or suggestions, feel free to ask them here. - Feb 19 2012