notification-hub

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

commit
21f75f7b3388d2da09537518df53d1d7b45f8f33
parent
0fe08c21ebe8c2893336046725fa6bebc51e6ae0
Author
Tobias Bengfort <tobias.bengfort@posteo.de>
Date
2020-08-09 17:55
add indicator

Diffstat

M notification_hub.py 15 +++++++++++++++

1 files changed, 15 insertions, 0 deletions


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

@@ -1,11 +1,17 @@
    1     1 # https://github.com/dunst-project/dunst/blob/master/src/dbus.c
    2     2 # https://lazka.github.io/pgi-docs/GLib-2.0/classes/VariantType.html
    3     3 # https://stackoverflow.com/questions/28949009/glib-gio-critical-error-while-invoking-a-method-on-dbus-interface
   -1     4 # https://lazka.github.io/pgi-docs/AyatanaAppIndicator3-0.1/classes/Indicator.html
    4     5 
    5     6 import sys
    6     7 
   -1     8 import gi
   -1     9 
   -1    10 gi.require_version('AyatanaAppIndicator3', '0.1')
   -1    11 
    7    12 from gi.repository import Gio
    8    13 from gi.repository import GLib
   -1    14 from gi.repository import AyatanaAppIndicator3 as AppIndicator3
    9    15 
   10    16 VERSION = '0.0.0'
   11    17 
@@ -50,6 +56,7 @@ INTROSPECTION_XML = """<?xml version="1.0" encoding="UTF-8"?>
   50    56 </node>"""
   51    57 
   52    58 next_id = 1
   -1    59 indicator = None
   53    60 
   54    61 
   55    62 def on_call(conn, sender, path, interface, method, parameters, invocation, user_data=None):
@@ -59,6 +66,7 @@ def on_call(conn, sender, path, interface, method, parameters, invocation, user_
   59    66         reply = GLib.Variant('(as)', [['actions', 'body', 'body-hyperlinks']])
   60    67     elif method == 'Notify':
   61    68         print(sender, parameters)
   -1    69         indicator.set_status(AppIndicator3.IndicatorStatus.ATTENTION)
   62    70         reply = GLib.Variant('(u)', [next_id])
   63    71         next_id += 1
   64    72     elif method == 'CloseNotification':
@@ -96,6 +104,13 @@ if __name__ == '__main__':
   96   104         on_name_lost,
   97   105     )
   98   106 
   -1   107     indicator = AppIndicator3.Indicator.new(
   -1   108         'notify',
   -1   109         'user-available',
   -1   110         AppIndicator3.IndicatorCategory.APPLICATION_STATUS,
   -1   111     )
   -1   112     indicator.set_status(AppIndicator3.IndicatorStatus.PASSIVE)
   -1   113 
   99   114     try:
  100   115         loop = GLib.MainLoop()
  101   116         loop.run()