Created
December 10, 2012 09:58
-
-
Save dulichan/4249683 to your computer and use it in GitHub Desktop.
Fedora Notification Wrapper for simple notification
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try: | |
import gtk, pynotify | |
pygtk.require('2.0') | |
except: | |
print "Error: need python-notify, python-gtk2 and gtk" | |
class NotificationWrapper: | |
def __init__(self, title="Testing Title", message="Testing message"): | |
self.title = title | |
self.message = message | |
def showNotification(self): | |
n = pynotify.Notification(self.title, self.message) | |
# Below example is for icons | |
# n = pynotify.Notification("Moo title", "test", "file:///path/to/icon.png") | |
n.set_urgency(pynotify.URGENCY_CRITICAL) | |
n.set_timeout(10000) # 10 seconds | |
n.set_category("device") | |
#Call an icon | |
helper = gtk.Button() | |
icon = helper.render_icon(gtk.STOCK_DIALOG_WARNING, gtk.ICON_SIZE_DIALOG) | |
n.set_icon_from_pixbuf(icon) | |
if not n.show(): | |
print "Failed to send notification" | |
sys.exit(1) | |
## Call this script and pass in title and message as argument | |
n = NotificationWrapper( sys.argv[1], sys.argv[2]) | |
n.showNotification() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment