KRunner Bridge

Write krunner python plugins the quick way.

the thing runs eval() on everything you type into krunner and returns the result with a nice icon.

it does not get simpler than that, given that the bridge actually compiles, which may or may not happen for you.

Plasma 5 stopped exposing KDE Framework API to script languages (except QML) for the purpose of so-called stability (but it is not at all stable, crashing from time to time). But this brings some horrible consequence that writing krunner plugins becomes time-consuming. You have to write long C++ code, configure your C++ building toolchain, and compile them each time you modify something.

No more pains with ONE plugin for all.

UPDATE: A KDE maintainer has described a way that was newly introduced in KDE 5.11, to make use of DBus to achieve this. See this post:



Clone this repository to local filesystem and cd into it.

mkdir build
cd build

cmake ..
make install

Quick Start

We will try to write a basic calculator using python’s eval function.

Follow the installation instructions and then edit ~/.local/share/kservices5/

#!/usr/bin/env python

import krunner_bridge
from math import *

def match(query):
        res = eval(query)
        if isinstance(res, (int, float)):
            return krunner_bridge.datasource(
                category="Python Calculator")

if __name__ == "__main__":

Append one line to ~/.local/share/kservices5/krunner_bridge.desktop, which tells krunner bridge where to find your script.

echo >> $HOME/.local/share/kservices5/krunner_bridge.desktop

Kill and restart krunner. (NOTE: It would be more debuggable to run it in terminal than using kstart5. All stderr output from your python script will be forwarded and displayed.) That’s what it will be like when all’s done:

For more practical examples, check out and view the effects by running ./ It searches in my useful little scripts and applications, with far better fuzzy match algorithm and selection mechanism. As what shows below, when you type one more key 5 to form a query kse5, the 5th choice KColorSchemeEditor will automatically be selected.