Short D-Bus tips

KDE 2 Comments

Dcop was a handy tool for instance to communicate with KDE applications from the shell. D-Bus allows for the same, and while searching for dbus equivalents for some old dcop commands I used I came up with some nice scripts that shall be backed up here now:

To get started, something simple: Lock the screen.

qdbus org.kde.krunner /ScreenSaver Lock

Use qdbusviewer to find more commands like that:

The SimulateUserActivity method highlighted in the screenshot above can be used for a nice wrapper script: Imagine you want to watch a movie or display a presentation and the application does not support disabling the screensaver itself. Use this little wrapper script to start the application:

#!/bin/bash
$* &
while jobs | grep -q Running
do
qdbus org.kde.krunner /ScreenSaver SimulateUserActivity
sleep 30
done

Save it as, let’s say, /usr/local/bin/noscreensaver and use it to open mplayer, for example: noscreensaver mplayer (I am aware that mplayer has a -stop-xscreensaver parameter). As long as the application is running, every thirty seconds user input is simulated with a dbus call to prevent the screen saver from starting. Once the application is closed, the script itself closes as well and the screen saver is enabled again (if it was before).

The next script is a bit more complicated: Whenever a tinyurl gets copied to the clipboard, let’s replace it with the link target. For instance, when copying http://tinyurl.com/5bz8v5 to the clipboard, I want it being replaced with http://planetkde.org instead. Here we go:

#/bin/bash
while true
do
if qdbus org.kde.klipper /klipper getClipboardContents | egrep -q ‘^(http://)?tinyurl.com/’
then
in=”$(qdbus org.kde.klipper /klipper getClipboardContents)”
target=”$(wget ${in} -O /dev/null 2>&1 | grep Location | sed ’s/^Location: \([^ ]*\) .*$/\1/’)”
qdbus org.kde.klipper /klipper setClipboardContents “${target}”
fi
sleep 1
done

The script however is not really suitable for every-day usage as it relies on polling for clipboard changes. If signals are available however, we can do fancy things like opening instant messages from a specific person directly:

#/bin/bash
dbus-monitor “type=’signal’,sender=’org.kde.kopete’,interface=’org.kde.Kopete’,path=’/Kopete’,member=’contactChanged’” | awk ‘/string “/ {print $2; fflush() }’ | sed -u ’s/”//g’ | while read contact
do
if [[  "$contact" == "${*}" ]]
then
if qdbus org.kde.kopete /Kopete contactProperties “$contact” | grep pending_messages: | grep -q ‘<p’
then
qdbus org.kde.kopete /Kopete openChat “$contact”
fi
fi
done

Save it as kopete-open-directly.bash, make it executable and call it like ./kopete-open-directly.bash <id-of-a-contact>

<id-of-a-contact> has to be a Kopete contact ID. To get a list of valid ones, run

qdbus org.kde.kopete /Kopete contacts | while read contact
do
qdbus org.kde.kopete /Kopete contactProperties “$contact” | grep display_name | sed “s/display_name:/${contact} <=> /”
done

If John has the Kopete ID MSNProtocol:me@someprovider.org:john@example.com for instance, executing kopete-open-directly.bash MSNProtocol:me@someprovider.org:john@example.com would open messages from John directly as long as the script is running.

Please notice that you might have to install some additional packages to get qdbusviewer, dbus-monitor, wget or other programs used in the scripts above. The D-Bus interfaces match todays SVN trunk, some of them might not be available in KDE 4.1 (the Kopete ones for example).

Marble Integration

KDE 6 Comments

Things are coming along nicely for the contacts plasmoid. While a short vacation slowed things down a bit, I worked on contact source abstraction in the last days which resulted in a kaddressbook integration. In the long run decibel/akonadi will take care of that as well, but for now you can choose among contacts from Kopete and the standard address book.

To work on something more visually pleasing, I gave marble a try this evening. The idea is to display all contacts with a known location (here provided by kaddressbook) in a common map. Thanks to the nice marble API, a first version is already done:

Next things to do are making the marble contacts widget configurable and look less ugly (better zooming level, rounded corners, maybe remove the small map if possible).

Five minute guide to setup Eclipse for KDE development

KDE 4 Comments

Someone asked how to setup Eclipse for KDE development in my last copy/paste bug rant. Here’s how I did, in short.

  1. Setup a working KDE development system according to Techbase, with cmakekde and all the good stuff.
  2. Download Eclipse 3.4 Ganymede, preferably the C++ one from eclipse.org, but any set containing CDT will do.
  3. Create /home/kde-devel/cmakekdeeclipse similarly to cmakekde (see the end for the content), make it executable (chmod +x)
  4. In Eclipse, File => New => Other => SVN => Checkout Projects from SVN. Checkout the KDE module you want to have in Eclipse. Use the C++ wizard when creating the project, set it to a Makefile project. You’ll adjust that later (or use the Advanced Settings button directly).
  5. After the checkout, open the projects properties and choose the C++ Builder tab. Change the builder from make to /home/kde-devel/cmakekdeeclipse ${workspace_loc:/playground_plasma} and choose an existing, empty directory for the build directory.
    Change playground_plasma to the name of your project.
  6. Press Ok. If all went well, you can just hit the “Build” button now and it will just work ™.
  7. Realize it took more than five minutes ;-)

Things to enjoy: Error and warning parser that will annotate faulty lines, a great indexer and content assistant, spell checking (that’s actually useful), gdb integration, doxygen assistant, Bugzilla integration (sadly not working with KDE Bugzilla), IRC integration (needs communication framework), Subversion support (needs subclipse/subversive), code formatting and a whole lot more.

Last not least some random tweaks:

  • Set the environment option LC_ALL to C in the preferences if the error/warning parser shows warnings as errors
  • Disable klippers setting “Prevent empty clipboard” if copy/paste in Eclipse behaves weird
  • Activate doxygen support in Window => Preferences => C/C++ => Editor
  • Disable automatic builds
  • Activate the (gnu) elf parser for gdb integration in Project Settings => C/C++ Build => Settings => Binary Parsers

And finally the cmakekdeeclipse script I use to invoke building:

#!/bin/bash
set -e

srcFolder=”${1}”
test -d “${srcFolder}”
source ~/.bashrc
cmake $srcFolder -DCMAKE_INSTALL_PREFIX=$KDEDIR -DCMAKE_BUILD_TYPE=debugfull
nice make -j3 VERBOSE=1
make install

No pic, no care?

Fixing copy/paste in Eclipse

KDE 4 Comments

Eclipse has grown up for C++ development and is what I’m using most of the time, even for KDE. One thing that was driving me crazy in the last days however was copying things to the clipboard: Often it didn’t work on the first key press, but a second one was needed. Countless times later I was annoyed enough to ask Google for it and found this workaround. Now someone please enlighten me who to blame, Eclipse or Klipper. I guess this won’t be a problem with the upcoming KDevelop 4.0, looking forward to it :-)

People running KDE SVN with plasma/playground can enjoy an early version of the contacts plasmoid, I checked in the code earlier.

Leaving the mockup phase

KDE 6 Comments

Found some time this weekend to continue working on the contacts plasmoid and some basic functionality is now there. Kudos to the plasma team for the great API. The data engine now supports querying kopete, but is designed to support other contact backends in the future. Rumors say there’s going to be a nepomuk backend, and sooner or later a decibel backend should take care of the rest (including kopete).

Besides writing the kopete backend (and extending the kopete dbus api a bit for that), I focused on building the plasmoid itself in a generic way. Think of it as a table where each row represents a contact and each column some kind of information or a way to interact with a contact. Rows are each their own object (to ease a later integration of extenders), and cells (information or actions) are created by a factory. This makes integration of new content and customization of the look very easy. See this screenshot:

Both plasmoids shown are instances of the contacts plasmoid and just differ in the configuration settings, which allow you to alter the contacts “table” to your liking:

This works nice so far (it’s already possible to send messages from the input line shown in the first screenshot) and I plan to work on eye-candy (e.g. animations for changes) and more custom cells (like a clock showing a contact’s local time, plasma is all about clocks after all ;-) ) next.

More interesting things will likely happen around akademy, stay tuned :-)

Disclaimer: The code is not yet available in KDE SVN.

On a totally unrelated sidenote, dynamic playlists in amarok 2 rock!

Today is Kopete Bugday!

KDE No Comments

It’s sunday, it’s bugday, it is your favorite instant messaging application waiting for you! Please visit the second Kopete Bugday page on techbase for an introduction and instructions on how to help out. If you’re looking for a quick way to contribute, please skim over the sections where a particular hardware/protocol/plugin combination is needed to verify a bug and see if one of them comes close to your setup: Bugday 1, Bugday 2.

Contacts Plasmoid Mockup revisited

KDE 13 Comments

Asking for feedback for the first contacts plasmoid mockup was a good idea: Going through all comments (thanks!) and talking to George Goldberg brought up some nice ideas to shape it up further. George works on decibel integration in his SoC project, which will result in a great foundation for a contacts plasmoid independent of a certain application and its representation of contacts.

This means that I’ll try to design it in a more generic fashion, which also addresses the concerns of many commenters. Other suggestions I tried to address in the new mockup:

  • Contact selection with a hover list might be slow and clutter the interface. Let’s move it to the configuration dialog.
  • The line edit should look better and might not be used at all. With integration of other applications (e.g. mail) this doesn’t make too much sense anymore. I still like it for IM, maybe it can be moved into a popup as suggested.
  • Searching for contacts could be integrated into krunner. George Goldberg will work on that in his SoC project.
  • There should be a configuration interface. Things I plan to have in there is the selection of static contacts (favourite contacts always displayed) and dynamic ones (e.g. contacts recently talked to / mailed).

The revisited desktop version looks like this now (powered by gimp again):

The line edit to start a chat is gone atm, although I kind of like the idea of /chat Bob Hi actions.

Disclaimer: This is only a mockup.

Contacts Plasmoid mockup

KDE 30 Comments

One of the things I want to do for KDE 4.2 is a “Contacts” plasmoid: A Kopete-centered plasmoid that displays your contacts status and allows for a quick chat initiation. So far I have two mockups which I’d like feedback on — please comment!

Before pasting those two mockups now, let me outline my plans for it:

I want it to

  • facilitate starting a chat / sending that one-line message quickly
  • let me quickly see the status [changes] of interesting contacts
  • be useful both on the desktop and in a panel, with the usual plasma eye-candy

I do not want it to

  • integrate other communication mechanisms than IM/Kopete
  • display messages. This is what Kopete / KNotify / the Notify plasmoid do.

Now for the mockups, I did one showing it in the panel:

Kopete Contact Plasmoid in the panel

Another one shows it on the desktop:

Kopete Contact Plasmoid on the desktop

Feedback from users, artists, usability people is greatly appreciated :-)

Disclaimer: This is only a mockup, no (not much) code written yet.

Moin Planet!

KDE 3 Comments

Getting added to planet was only a matter of minutes thanks to Riddell. In consequence you can enjoy — or have to live with :-p — occasional posts from southern Germany now. KDE related I’m currently spending most time on Kopete, so look forward to some status updates here. One of them is already there, a visual changelog for Kopete in KDE 4.1.

Many questions frequently popping up in #kopete target the notification system and its configuration, so let’s repeat two of them here:

Can I configure/disable those popups?
Sure, they’re configured in “Settings” => “Configure Notifications”. Some fine-tuning can also be done in “Settings” => “Configure” (like disabling animations or having chat windows open automatically).

I don’t like the popup position! Can I have the yellow bubble back?
Nope, it’s gone for good. For KDE 4.0, some bugs crept in that made it behave rather intrusive at times, but they’re fixed now. Additionally, a promising Notify plasmoid is in the works that can fully replace the popup announcements. Besides stacking up notifications at the place where you want them to pop up, it’ll add the usual plasma eye-candy and therefore quickly outreach that old yellow bubble.

Last not least:

Kopete in KDE 4.1: A Visual Changelog

KDE 17 Comments

With Beta 1 out of the door KDE 4.1 is nearly feature-complete: Time for a quick view at some changes and new features in Kopete. Ignoring bug fixes and changes “under the hood” for now, here’s a quick visual overview of new features:

Status Manager message configuration (left) and status configuration (right)

The new Status Manager greatly simplifies status changes for the various protocols supported by Kopete. It allows for a quick status (message) change, both available from icons at the bottom of the Kopete main window.

Read the rest…

« Previous Entries