Skip to main content

Extending Plasma Krunner to search for GitLab projects

This blog post might be outdated!
This blog post was published more than one year ago and might be outdated!
· 2 min read
Stephan Hochdörfer
Head of IT Business Operations

Last year I realized that Krunner, the launcher built into the KDE Plasma desktop is extendable by implementing a D-Bus service. I remembered that Derick Rethans once built a dbus extension for PHP5. Unfortunately there does not exist a "final" port of the extension to PHP7, but several people tried to fix most of the problems. I gave both the PHP7 & PHP5 version a try but got segfaults when sending data over D-Bus.

During my christmas holidays, I picked up on the project again and looked for alternatives. Why not give Go a try and try to implement the project in Go? Even without prior experience in Go, I had a prototype up and running quickly. My main goal was to add search capabilities for our company's GitLab instance. I wanted to search for project names and get a list of links back that I could open in a browser. The result can be seen in my personal GitHub project.

The implementation itself is rather simple. All you need is an object (service) that exposes 3 methods: Actions(), Match() and Run(). The Actions() method can be ignored for our use-case. The Match() method gets called whenever the user enters data in KRunner, the Run() method is called when an item got selected in KRunner(), in this case we launch a browser with the url of the selected project.

To make KRunner aware of a new endpoint to query, you simply need to create a file called krunner-gitlab.desktop in $HOME/.local/share/kservices5. This will instruct KRunner to call the de.hochdoerfer.gitlab service. If the service is running and the required methods are exposed, KRunner will call them and get the data back.

[Desktop Entry]
Comment=GitLab KRunner
X-KDE-PluginInfo-Author=Stephan Hochdörfer

Feel free to give it a try and let me know what you think.