notification-hub

distraction-free notification daemon for simple linux desktops.
git clone https://git.ce9e.org/notification-hub.git

commit
1e458587b4cac2242530ac5cd6a280684feee510
parent
412c5139d113769b481ae2d05b866efac0b2e842
Author
Tobias Bengfort <tobias.bengfort@posteo.de>
Date
2022-02-12 18:01
small improvements

-	use __version__ as per convention
-	rm unused/unsupported entries from INTROSPECTION_XML
-	rm on_name_acquired (only the error case is interesting)
-	use parameter instead of global variable in on_name_lost
-	change id and title to "notifications"

Diffstat

M README.md 4 ++--
M notification_hub.py 30 +++++++-----------------------

2 files changed, 9 insertions, 25 deletions


diff --git a/README.md b/README.md

@@ -12,9 +12,9 @@ Distraction-free notification daemon for linux inspired by github.
   12    12 ## Dependencies
   13    13 
   14    14 -	python3-gi
   15    -1 -	gir1.2-glib-2.0
   -1    15 -	[gir1.2-glib-2.0](https://docs.gtk.org/gio/)
   16    16 -	gir1.2-gtk-3.0
   17    -1 -	gir1.2-ayatanaappindicator3-0.1
   -1    17 -	[gir1.2-ayatanaappindicator3-0.1](https://lazka.github.io/pgi-docs/AyatanaAppIndicator3-0.1/classes/Indicator.html)
   18    18 
   19    19 ## Known Limitations
   20    20 

diff --git a/notification_hub.py b/notification_hub.py

@@ -1,8 +1,3 @@
    1    -1 # https://github.com/dunst-project/dunst/blob/master/src/dbus.c
    2    -1 # https://lazka.github.io/pgi-docs/GLib-2.0/classes/VariantType.html
    3    -1 # https://stackoverflow.com/questions/28949009/glib-gio-critical-error-while-invoking-a-method-on-dbus-interface
    4    -1 # https://lazka.github.io/pgi-docs/AyatanaAppIndicator3-0.1/classes/Indicator.html
    5    -1 
    6     1 import sys
    7     2 
    8     3 import gi
@@ -15,7 +10,7 @@ from gi.repository import GLib  # noqa
   15    10 from gi.repository import Gtk  # noqa
   16    11 from gi.repository import AyatanaAppIndicator3 as AppIndicator3  # noqa
   17    12 
   18    -1 VERSION = '0.0.0'
   -1    13 __version__ = '0.0.0'
   19    14 
   20    15 IGNORE = []
   21    16 
@@ -48,14 +43,6 @@ INTROSPECTION_XML = """<?xml version="1.0" encoding="UTF-8"?>
   48    43             <arg direction="out" name="version"         type="s"/>
   49    44             <arg direction="out" name="spec_version"    type="s"/>
   50    45         </method>
   51    -1         <signal name="NotificationClosed">
   52    -1             <arg name="id"         type="u"/>
   53    -1             <arg name="reason"     type="u"/>
   54    -1         </signal>
   55    -1         <signal name="ActionInvoked">
   56    -1             <arg name="id"         type="u"/>
   57    -1             <arg name="action_key" type="s"/>
   58    -1         </signal>
   59    46    </interface>
   60    47 </node>"""
   61    48 
@@ -153,7 +140,7 @@ def on_call(
  153   140         on_close_notification(*params)
  154   141         reply = None
  155   142     elif method == 'GetServerInformation':
  156    -1         info = ['notification-hub', 'xi', VERSION, '1.2']
   -1   143         info = ['notification-hub', 'xi', __version__, '1.2']
  157   144         reply = GLib.Variant('(ssss)', info)
  158   145     else:
  159   146         print(f'Unknown method: {method}')
@@ -167,14 +154,10 @@ def on_bus_acquired(conn, name, user_data=None):
  167   154     conn.register_object(FDN_PATH, node_info.interfaces[0], on_call)
  168   155 
  169   156 
  170    -1 def on_name_acquired(conn, name, user_data=None):
  171    -1     print(f'Aquired name {name}')
  172    -1 
  173    -1 
  174   157 def on_name_lost(conn, name, user_data=None):
  175   158     sys.exit(
  176    -1         f'Could not aquire name {FDN_IFAC}. '
  177    -1         f'Is some other notification daemon running?'
   -1   159         f'Could not aquire name {name}. '
   -1   160         f'Is some other service blocking it?'
  178   161     )
  179   162 
  180   163 
@@ -184,16 +167,17 @@ if __name__ == '__main__':
  184   167         FDN_IFAC,
  185   168         Gio.BusNameOwnerFlags.NONE,
  186   169         on_bus_acquired,
  187    -1         on_name_acquired,
   -1   170         None,
  188   171         on_name_lost,
  189   172     )
  190   173 
  191   174     indicator = AppIndicator3.Indicator.new(
  192    -1         'notify',
   -1   175         'notifications',
  193   176         'user-available',
  194   177         AppIndicator3.IndicatorCategory.APPLICATION_STATUS,
  195   178     )
  196   179     indicator.set_status(AppIndicator3.IndicatorStatus.PASSIVE)
   -1   180     indicator.set_title('Notifications')
  197   181     menu = Gtk.Menu()
  198   182     indicator.set_menu(menu)
  199   183