Skip to content

Instantly share code, notes, and snippets.

@owais
Created March 13, 2018 01:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save owais/f18577a9a6e94b84a7449e8c28e1208e to your computer and use it in GitHub Desktop.
Save owais/f18577a9a6e94b84a7449e8c28e1208e to your computer and use it in GitHub Desktop.
Slack Badge Notifications
import dbus
import dbus.service
import dbus.mainloop.glib
from gi.repository import GObject
class Service(dbus.service.Object):
def __init__(self, message):
self._message = message
def run(self):
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
bus_name = dbus.service.BusName("com.example.service", dbus.SessionBus())
dbus.service.Object.__init__(self, bus_name, "/com/example/service")
self._loop = GObject.MainLoop()
# snap version ships with slack_slack.desktop instead of slack.desktop. If you are using DEB, rename to slack.desktop
GObject.idle_add(lambda: self.Update("application://slack_slack.desktop", {"count-visible": True, "count": dbus.Int64(10), "urgent": True}))
self._loop.run()
@dbus.service.signal(dbus_interface="com.canonical.Unity.LauncherEntry", signature='sa{sv}')
def Update(self, app_uri, properties):
print(app_uri, properties)
if __name__ == "__main__":
Service("This is the service").run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment