diff --git a/not2osd b/not2osd index d77d71cbd39afc438a4555a7d753a93d8320b2eb..7c875784902e454410f636494b4f48bd4fec6dd2 100755 --- a/not2osd +++ b/not2osd @@ -1,4 +1,4 @@ -#!/usr/bin/env python2 +#!/usr/bin/env python3 # # not2osd - Bridge from DBus notifications to osd @@ -23,14 +23,12 @@ import dbus import dbus.service import dbus.mainloop.glib -import gobject import os import subprocess import sys -import thread import time -from htmlentitydefs import name2codepoint as n2cp import re +from gi.repository import GObject as gobject @@ -68,15 +66,15 @@ class NotificationFetcher(dbus.service.Object): out_signature='u') def Notify(self, app_name, notification_id, app_icon, summary, body, actions, hints, expire_timeout): - print "app_name", app_name - print "notification_id", notification_id - print "app_icon", app_icon - print "summary", summary - print "body", body - print "actions", actions - print "expire_timeout", expire_timeout - su = strip_tags(unicode(summary)).split("\n") - bo = strip_tags(unicode(body)).split("\n") + #print("app_name", app_name) + #print("notification_id", notification_id) + #print("app_icon", app_icon) + #print("summary", summary) + #print("body", body) + #print("actions", actions) + #print("expire_timeout", expire_timeout) + su = strip_tags((summary)).split("\n") + bo = strip_tags((body)).split("\n") for i in range(len(su)): if su[i]!="" and su[i][0]=='-': su[i] = ' '+su[i]; @@ -119,59 +117,6 @@ class NotificationFetcher(dbus.service.Object): return ("statnot", "http://code.k2h.se", "0.0.2", "1") if __name__ == '__main__': - for curarg in sys.argv[1:]: - if curarg in ('-v', '--version'): - #print "%s CURVERSION" % sys.argv[0] - sys.exit(1) - elif curarg in ('-h', '--help'): - #print " Usage: %s [-h] [--help] [-v] [--version] [configuration file]" % sys.argv[0] - #print " -h, --help: Print this help and exit" - #print " -v, --version: Print version and exit" - #print "" - #print " Configuration:" - #print " A file can be read to set the configuration." - #print " This configuration file must be written in valid python," - #print " which will be read if the filename is given on the command line." - #print " You do only need to set the variables you want to change, and can" - #print " leave the rest out." - #print "" - ##print " Below is an example of a configuration which sets the defaults." - #print "" - #print " # Default time a notification is show, unless specified in notification" - #print " DEFAULT_NOTIFY_TIMEOUT = 3000 # milliseconds" - #print " " - #print " # Maximum time a notification is allowed to show" - ###print " MAX_NOTIFY_TIMEOUT = 5000 # milliseconds" - #print " " - #print " # Maximum number of characters in a notification. " - #print " NOTIFICATION_MAX_LENGTH = 100 # number of characters" - #print " " - #print " # Time between regular status updates" - #print " STATUS_UPDATE_INTERVAL = 2.0 # seconds" - #print " " - ##print " # Command to fetch status text from. We read from stdout." - #print " # Each argument must be an element in the array" - ##print " # os must be imported to use os.getenv" - ##print " import os" - #print " STATUS_COMMAND = ['/bin/sh', '%s/.statusline.sh' % os.getenv('HOME')] " - ##print "" - #print " # Always show text from STATUS_COMMAND? If false, only show notifications" - #print " USE_STATUSTEXT=True" - #print " " - #print " # Put incoming notifications in a queue, so each one is shown." - #print " # If false, the most recent notification is shown directly." - #print " QUEUE_NOTIFICATIONS=True" - #print " " - #print " # update_text(text) is called when the status text should be updated" - #print " # If there is a pending notification to be formatted, it is appended as" - #print " # the final argument to the STATUS_COMMAND, e.g. as $1 in default shellscript" - ##print "" - #print " # dwm statusbar update" - #print " import subprocess" - #print " def update_text(text):" - #print " subprocess.call(['xsetroot', '-name', text])" - sys.exit(1) - dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) session_bus = dbus.SessionBus() name = dbus.service.BusName("org.freedesktop.Notifications", session_bus)