Mercurial > libervia-backend
diff sat_frontends/primitivus/notify.py @ 2624:56f94936df1e
code style reformatting using black
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 27 Jun 2018 20:14:46 +0200 |
parents | 26edcf3a30eb |
children | 003b8b4b56a7 |
line wrap: on
line diff
--- a/sat_frontends/primitivus/notify.py Wed Jun 27 07:51:29 2018 +0200 +++ b/sat_frontends/primitivus/notify.py Wed Jun 27 20:14:46 2018 +0200 @@ -19,27 +19,35 @@ import dbus + class Notify(object): """Used to send notification and detect if we have focus""" def __init__(self): - #X11 stuff + # X11 stuff self.display = None self.X11_id = -1 try: from Xlib import display as X_display + self.display = X_display.Display() self.X11_id = self.getFocus() except: pass - #Now we try to connect to Freedesktop D-Bus API + # Now we try to connect to Freedesktop D-Bus API try: bus = dbus.SessionBus() - db_object = bus.get_object('org.freedesktop.Notifications', '/org/freedesktop/Notifications', follow_name_owner_changes=True) - self.freedesktop_int = dbus.Interface(db_object, dbus_interface='org.freedesktop.Notifications') + db_object = bus.get_object( + "org.freedesktop.Notifications", + "/org/freedesktop/Notifications", + follow_name_owner_changes=True, + ) + self.freedesktop_int = dbus.Interface( + db_object, dbus_interface="org.freedesktop.Notifications" + ) except: self.freedesktop_int = None @@ -56,7 +64,7 @@ def sendNotification(self, summ_mess, body_mess=""): """Send notification to the user if possible""" - #TODO: check options before sending notifications + # TODO: check options before sending notifications if self.freedesktop_int: self.sendFDNotification(summ_mess, body_mess) @@ -68,10 +76,17 @@ app_icon = "" summary = summ_mess body = body_mess - actions = dbus.Array(signature='s') - hints = dbus.Dictionary(signature='sv') + actions = dbus.Array(signature="s") + hints = dbus.Dictionary(signature="sv") expire_timeout = -1 - self.freedesktop_int.Notify(app_name, replaces_id, app_icon, - summary, body, actions, - hints, expire_timeout) + self.freedesktop_int.Notify( + app_name, + replaces_id, + app_icon, + summary, + body, + actions, + hints, + expire_timeout, + )