28 lines
1.4 KiB
Python
28 lines
1.4 KiB
Python
# Fake StatusNotifierWatcher on the session bus, so that Medlar finds a tray host.
|
|
import gi
|
|
gi.require_version("Gio", "2.0")
|
|
from gi.repository import Gio, GLib
|
|
XML = """<node><interface name="org.kde.StatusNotifierWatcher">
|
|
<method name="RegisterStatusNotifierItem"><arg type="s" direction="in"/></method>
|
|
<method name="RegisterStatusNotifierHost"><arg type="s" direction="in"/></method>
|
|
<property name="IsStatusNotifierHostRegistered" type="b" access="read"/>
|
|
<property name="ProtocolVersion" type="i" access="read"/>
|
|
<property name="RegisteredStatusNotifierItems" type="as" access="read"/>
|
|
</interface></node>"""
|
|
items = []
|
|
def call(conn, sender, path, iface, method, params, inv):
|
|
if method == "RegisterStatusNotifierItem":
|
|
s = params.unpack()[0]
|
|
items.append(s if s.startswith("/") is False else sender)
|
|
open(OUT, "w").write(sender + "\n")
|
|
inv.return_value(None)
|
|
def prop(conn, sender, path, iface, name):
|
|
return {"IsStatusNotifierHostRegistered": GLib.Variant("b", True), "ProtocolVersion": GLib.Variant("i", 0),
|
|
"RegisteredStatusNotifierItems": GLib.Variant("as", items)}[name]
|
|
import sys
|
|
OUT = sys.argv[1]
|
|
info = Gio.DBusNodeInfo.new_for_xml(XML).interfaces[0]
|
|
def acquired(conn, name):
|
|
conn.register_object("/StatusNotifierWatcher", info, call, prop, None)
|
|
Gio.bus_own_name(Gio.BusType.SESSION, "org.kde.StatusNotifierWatcher", 0, acquired, None, None)
|
|
GLib.MainLoop().run()
|