Last active
September 5, 2020 20:04
-
-
Save cschramm/c6cc7cea909d7a40e6f5a976dbaf484f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from gi.repository import Gio, GLib | |
bus = Gio.bus_get_sync(Gio.BusType.SESSION) | |
info = Gio.DBusNodeInfo.new_for_xml(""" | |
<node name='/'> | |
<interface name='org.kde.StatusNotifierItem'> | |
<property name="Category" type="s" access="read"/> | |
<property name="Id" type="s" access="read"/> | |
<property name="Title" type="s" access="read"/> | |
<property name="Status" type="s" access="read"/> | |
<property name="WindowId" type="i" access="read"/> | |
<property name="IconName" type="s" access="read"/> | |
<property name="IconPixmap" type="(iiay)" access="read"> | |
</property> | |
<property name="OverlayIconName" type="s" access="read"/> | |
<property name="OverlayIconPixmap" type="(iiay)" access="read"> | |
</property> | |
<property name="AttentionIconName" type="s" access="read"/> | |
<property name="AttentionIconPixmap" type="(iiay)" access="read"> | |
</property> | |
<property name="AttentionMovieName" type="s" access="read"/> | |
<property name="ToolTip" type="(sa(iiay)ss)" access="read"> | |
</property> | |
<method name="ContextMenu"> | |
<arg name="x" type="i" direction="in"/> | |
<arg name="y" type="i" direction="in"/> | |
</method> | |
<method name="Activate"> | |
<arg name="x" type="i" direction="in"/> | |
<arg name="y" type="i" direction="in"/> | |
</method> | |
<method name="SecondaryActivate"> | |
<arg name="x" type="i" direction="in"/> | |
<arg name="y" type="i" direction="in"/> | |
</method> | |
<method name="Scroll"> | |
<arg name="delta" type="i" direction="in"/> | |
<arg name="orientation" type="s" direction="in"/> | |
</method> | |
<signal name="NewTitle"> | |
</signal> | |
<signal name="NewIcon"> | |
</signal> | |
<signal name="NewAttentionIcon"> | |
</signal> | |
<signal name="NewOverlayIcon"> | |
</signal> | |
<signal name="NewToolTip"> | |
</signal> | |
<signal name="NewStatus"> | |
<arg name="status" type="s"/> | |
</signal> | |
</interface> | |
</node> | |
""") | |
def get_property(connection, sender, object_path, interface_name, property_name): | |
if property_name in {"Category", "Id", "Status", "IconName"}: | |
return GLib.Variant("s", { | |
"Category": "Hardware", | |
"Id": "blueman", | |
"Status": "Active", | |
"IconName": "blueman", | |
"Title": "A simple title", | |
}.get(property_name)) | |
if property_name == "ToolTip": | |
return GLib.Variant("(sa(iiay)ss)", ("", [], "Tooltip title", "<b>Bold tooltip decription</b>")) | |
bus.register_object("/org/blueman/sni", info.interfaces[0], lambda *args: print(args), get_property, lambda *args: print(args)) | |
bus.call("org.kde.StatusNotifierWatcher", "/StatusNotifierWatcher", "org.kde.StatusNotifierWatcher", "RegisterStatusNotifierItem", GLib.Variant("(s)", ("/org/blueman/sni",)), GLib.VariantType("(s)"), Gio.DBusCallFlags.NONE, -1, None) | |
GLib.MainLoop().run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment