28 Mar 2009
Python Suspend Applet
Yesterday Sebas blogged about his desire for a small plasmoid that would allow him to suspend his computer when the screen is locked.
Since I already wanted an excuse to play around with a Python plasmoid, I decided this would be a cool little applet to code. Turns out that there is a (pending) freedesktop.org interface to power management and PowerDevil implements the important parts of this.
I started out with the great Python+Plasma tutorial and the second one on using the Plasma::Widgets that we know and love from C++. Couple that with the python bindings for dbus, and you’ve got yourself a little applet that suspends your computer at the press of a button.
You can find the applet on kde-look, and it should be present in GHNS as well. (working on this point… for some reason it’s not showing up for me).
Edit: Ok, now it’s showing up. I guess it just took some time.

Yay! Looks pretty much exactly how I want it, and as a bonus, it has DPMS support
Now I’ve got an excuse to compile the python plasma bindings, I guess
sebas
March 28th, 2009 at 10:28 ampermalink
Cool stuff, thanks
Just as a suggestion for the next version, center the icons vertically in the buttons, this looks even cooler than aligning at the top
Michael
March 28th, 2009 at 12:59 pmpermalink
@sebas
Glad to help =). KDE technologies can be quite easy to work with.
@Michael
I think that’s a byproduct of my theme. I didn’t touch anything with icon alignment (And I don’t think Plasma::PushButton has that capability anyways)
hmm… it actually seems to go away if I resize the applet a bit. I wonder if some layout thing is getting in the way. Wouldn’t be the first time.
astromme
March 28th, 2009 at 1:11 pmpermalink
nice
one little nitpick: why is “turn display off” in hte middle? I would’ve expected it to be at the top, since it has the smallest effect, with hibernate (the “biggest” change) at the bottom.
Chani
March 28th, 2009 at 1:46 pmpermalink
No particular reason at all, just the way it was coded. They’re flipped now, you’re right it makes more sense.
astromme
March 28th, 2009 at 2:43 pmpermalink
It gives me a warm and fuzzy feeling to hear that people are enjoying and producing useful things with the Python support in Plasma. (especially after the turd-sandwich of an email some frustrated user sent me this morning.
)
A small request: Perhaps you could make a small tutorial on techbase explaining the code you use to talk to DBus. That would be handy and I think quite a few people would be interested in it. thanks.
Simon Edwards
March 29th, 2009 at 2:30 ampermalink
I’ve started a PyKDE4 DBus tutorial here:
http://techbase.kde.org/index.php?title=Development/Languages/Python/PyKDE_DBus_Tutorial
It’s a work in progress for now
astromme
April 1st, 2009 at 12:09 pmpermalink