-
Notifications
You must be signed in to change notification settings - Fork 25
/
i3-appmenu-service.py
executable file
·36 lines (29 loc) · 1.13 KB
/
i3-appmenu-service.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/env python3
from gi.repository import Gtk
import dbus
import dbus.service
from dbus.mainloop.glib import DBusGMainLoop
class i3AppmenuService(dbus.service.Object):
def __init__(self):
bus_name = dbus.service.BusName('com.canonical.AppMenu.Registrar', bus = dbus.SessionBus())
dbus.service.Object.__init__(self, bus_name, '/com/canonical/AppMenu/Registrar')
self.window_dict = dict()
@dbus.service.method('com.canonical.AppMenu.Registrar',
in_signature='uo',
sender_keyword='sender')
def RegisterWindow(self, windowId, menuObjectPath, sender):
self.window_dict[windowId] = (sender, menuObjectPath)
@dbus.service.method('com.canonical.AppMenu.Registrar',
in_signature='u',
out_signature='so')
def GetMenuForWindow(self, windowId):
if windowId in self.window_dict:
sender, menuObjectPath = self.window_dict[windowId]
return [dbus.String(sender), dbus.ObjectPath(menuObjectPath)]
@dbus.service.method('com.canonical.AppMenu.Registrar')
def Q(self):
Gtk.main_quit()
DBusGMainLoop(set_as_default=True)
myservice = i3AppmenuService()
Gtk.main()
# GTK apps : get dbus service (xprop)