Extending Plasma Krunner to search for GitLab projectsNew Blog Post

Extending Plasma Krunner to search for GitLab projectsNew Blog Post

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]
Name=GitLab
Comment=GitLab KRunner
X-KDE-ServiceTypes=Plasma/Runner
Type=Service
Icon=internet-web-browser
X-KDE-PluginInfo-Author=Stephan Hochdörfer
X-KDE-PluginInfo-Email=S.Hochdoerfer@bitExpert.de
X-KDE-PluginInfo-Name=krunner-gitlab
X-KDE-PluginInfo-Version=1.0
X-KDE-PluginInfo-License=Apache-2.0
X-KDE-PluginInfo-EnabledByDefault=true
X-Plasma-API=DBus
X-Plasma-DBusRunner-Service=de.hochdoerfer.gitlab
X-Plasma-DBusRunner-Path=/krunner


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


Eintrag von Stephan Hochdörfer am 10.01.2019

Diese Webseite verwendet Cookies, um die Bedienfreundlichkeit zu erhöhen. Mit der Nutzung unserer Webseite wird das Einverständnis erklärt, dass wir Cookies verwenden. Weitere Informationen.