notification-hub

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

commit
9f0d053376570381fb97a26794797737ef58067a
parent
e55cc45cd967cc21425a7bad3163daf09456669c
Author
Tobias Bengfort <tobias.bengfort@posteo.de>
Date
2022-02-11 14:16
convert params to dict

Diffstat

M notification_hub.py 38 +++++++++++++++++++-------------------

1 files changed, 19 insertions, 19 deletions


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

@@ -71,34 +71,25 @@ def clear_thread(item, key):
   71    71 
   72    72 
   73    73 def format_label(params):
   74    -1     app_name = params[0]
   75    -1     summary = params[3]
   76    -1     body = params[4]
   77    -1     hints = params[6]
   78    -1     desktop_entry = hints.get('desktop-entry')
   79    -1 
   80    -1     _app_name = app_name or desktop_entry
   -1    74     desktop_entry = params['hints'].get('desktop-entry')
   -1    75     _app_name = params['app_name'] or desktop_entry
   81    76     if _app_name:
   82    -1         if summary != _app_name:
   83    -1             return '%s: %s' % (_app_name, summary)
   -1    77         if params['summary'] != _app_name:
   -1    78             return '%s: %s' % (_app_name, params['summary'])
   84    79         else:
   85    -1             return '%s: %s' % (_app_name, body[:40])
   -1    80             return '%s: %s' % (_app_name, params['body'][:40])
   86    81     else:
   87    -1         return summary
   -1    82         return params['summary']
   88    83 
   89    84 
   90    85 def on_add_notification(params, id):
   91    -1     app_name = params[0]
   92    -1     replaces_id = params[1]
   93    -1     hints = params[6]
   94    -1 
   95    86     label = format_label(params)
   96    -1     key = hints.get('desktop-entry', app_name)
   -1    87     key = params['hints'].get('desktop-entry', params['app_name'])
   97    88     thread = threads.get(key)
   98    89 
   99    90     if thread:
  100    -1         if replaces_id in thread['ids']:
  101    -1             thread['ids'].remove(replaces_id)
   -1    91         if params['replaces_id'] in thread['ids']:
   -1    92             thread['ids'].remove(params['replaces_id'])
  102    93         thread['ids'].add(id)
  103    94         thread['menuitem'].set_label(label)
  104    95     else:
@@ -130,7 +121,16 @@ def on_call(
  130   121         # announce fake capabilities to avoid firefox fallback
  131   122         reply = GLib.Variant('(as)', [['actions', 'body', 'body-hyperlinks']])
  132   123     elif method == 'Notify':
  133    -1         on_add_notification(params, next_id)
   -1   124         on_add_notification({
   -1   125             'app_name': params[0],
   -1   126             'replaces_id': params[1],
   -1   127             'app_icon': params[2],
   -1   128             'summary': params[3],
   -1   129             'body': params[4],
   -1   130             'actions': params[5],
   -1   131             'hints': params[6],
   -1   132             'expire_timeout': params[7],
   -1   133         }, next_id)
  134   134         reply = GLib.Variant('(u)', [next_id])
  135   135         next_id += 1
  136   136     elif method == 'CloseNotification':