Initial import
This commit is contained in:
commit
7367fcd3b5
26
README.md
Normal file
26
README.md
Normal file
@ -0,0 +1,26 @@
|
||||
### krha
|
||||
|
||||
This plugin provides a simple template for a KRunner plugin using dbus.
|
||||
|
||||
The install script copies the Krunner config file and a dbus activation service file
|
||||
to their appropriate locations.
|
||||
This way the python script gets executed when KRunner
|
||||
requests matches and it does not need to be autostarted.
|
||||
|
||||
If you want to run the plugin manually to debug it you can do the following:
|
||||
```bash
|
||||
mkdir -p ~/.local/share/krunner/dbusplugins/
|
||||
cp plasma-runner-krha.desktop ~/.local/share/krunner/dbusplugins/
|
||||
kquitapp5 krunner
|
||||
python3 krha.py
|
||||
```
|
||||
|
||||
After that you should see your runner when typing `hello` in KRunner.
|
||||
|
||||
More information can be found here:
|
||||
https://invent.kde.org/frameworks/krunner/-/blob/master/src/data/org.kde.krunner1.xml
|
||||
https://techbase.kde.org/Development/Tutorials/D-Bus/Introduction
|
||||
|
||||
|
||||
If you feel confident about your runner you can upload it to the KDE Store
|
||||
https://store.kde.org/browse/cat/628/order/latest/.
|
20
install.sh
Executable file
20
install.sh
Executable file
@ -0,0 +1,20 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Exit if something fails
|
||||
set -e
|
||||
|
||||
|
||||
if [[ -z "$XDG_DATA_HOME" ]]; then
|
||||
prefix=~/.local/share
|
||||
else
|
||||
prefix="$XDG_DATA_HOME"
|
||||
fi
|
||||
|
||||
mkdir -p $prefix/krunner/dbusplugins/
|
||||
mkdir -p $prefix/dbus-1/services/
|
||||
|
||||
cp plasma-runner-krha.desktop $prefix/krunner/dbusplugins/
|
||||
sed "s|/home/qbit/projects/krha/krha.py|${PWD}/krha.py|" "org.kde.krha.service" > $prefix/dbus-1/services/org.kde.krha.service
|
||||
|
||||
kquitapp5 krunner
|
||||
|
38
krha.py
Executable file
38
krha.py
Executable file
@ -0,0 +1,38 @@
|
||||
#!/usr/bin/python3
|
||||
|
||||
import dbus.service
|
||||
from dbus.mainloop.glib import DBusGMainLoop
|
||||
from gi.repository import GLib
|
||||
|
||||
DBusGMainLoop(set_as_default=True)
|
||||
|
||||
objpath = "/krha"
|
||||
|
||||
iface = "org.kde.krunner1"
|
||||
|
||||
|
||||
class Runner(dbus.service.Object):
|
||||
def __init__(self):
|
||||
dbus.service.Object.__init__(self, dbus.service.BusName("org.kde.krha", dbus.SessionBus()), objpath)
|
||||
|
||||
@dbus.service.method(iface, in_signature='s', out_signature='a(sssida{sv})')
|
||||
def Match(self, query: str):
|
||||
"""This method is used to get the matches and it returns a list of tupels"""
|
||||
if query == "hello":
|
||||
# data, text, icon, type (Plasma::QueryType), relevance (0-1), properties (subtext, category, multiline(bool) and urls)
|
||||
return [("Hello", "Hello from krha!", "document-edit", 100, 1.0, {'subtext': 'Demo Subtext'})]
|
||||
return []
|
||||
|
||||
@dbus.service.method(iface, out_signature='a(sss)')
|
||||
def Actions(self):
|
||||
# id, text, icon
|
||||
return [("id", "Tooltip", "planetkde")]
|
||||
|
||||
@dbus.service.method(iface, in_signature='ss')
|
||||
def Run(self, data: str, action_id: str):
|
||||
print(data, action_id)
|
||||
|
||||
|
||||
runner = Runner()
|
||||
loop = GLib.MainLoop()
|
||||
loop.run()
|
3
org.kde.krha.service
Normal file
3
org.kde.krha.service
Normal file
@ -0,0 +1,3 @@
|
||||
[D-BUS Service]
|
||||
Name=org.kde.krha
|
||||
Exec=/usr/bin/python3 "/home/qbit/projects/krha/krha.py"
|
15
plasma-runner-krha.desktop
Normal file
15
plasma-runner-krha.desktop
Normal file
@ -0,0 +1,15 @@
|
||||
[Desktop Entry]
|
||||
Name=krha
|
||||
Comment=krha Runner written in Python
|
||||
X-KDE-ServiceTypes=Plasma/Runner
|
||||
Type=Service
|
||||
Icon=planetkde
|
||||
X-KDE-PluginInfo-Author=%{AUTHOR}
|
||||
X-KDE-PluginInfo-Email=%{EMAIL}
|
||||
X-KDE-PluginInfo-Name=krha
|
||||
X-KDE-PluginInfo-Version=1.0
|
||||
X-KDE-PluginInfo-License=LGPL
|
||||
X-KDE-PluginInfo-EnabledByDefault=true
|
||||
X-Plasma-API=DBus
|
||||
X-Plasma-DBusRunner-Service=org.kde.krha
|
||||
X-Plasma-DBusRunner-Path=/krha
|
15
uninstall.sh
Executable file
15
uninstall.sh
Executable file
@ -0,0 +1,15 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Exit if something fails
|
||||
set -e
|
||||
|
||||
if [[ -z "$XDG_DATA_HOME" ]]; then
|
||||
prefix=~/.local/share
|
||||
else
|
||||
prefix="$XDG_DATA_HOME"
|
||||
fi
|
||||
|
||||
rm $prefix/krunner/dbusplugins/plasma-runner-krha.desktop
|
||||
rm $prefix/dbus-1/services/org.kde.krha.service
|
||||
kquitapp5 krunner
|
||||
|
Loading…
x
Reference in New Issue
Block a user