Čajový problém řeším pomocí dvou skriptů, spouštím:
./čaj.sh 5
který pošle do Ubuntu notifikaci skriptem notifikace.py a zabubnuje, že už je hotovo:
~$ cat čaj.sh
#!/bin/bash
sleep $((60 * ${1}))
./notifikace.py ČAJ hotovo
~$ cat notifikace.py
#!/usr/bin/env python
try:
import gtk, pygtk, os, os.path, pynotify
pygtk.require('2.0')
except:
print "Error: need python-notify, python-gtk2 and gtk"
import sys # input arguments
if __name__ == '__main__':
if not pynotify.init("Timekpr notification"):
sys.exit(1)
try:
n = pynotify.Notification(sys.argv[1], sys.argv[2])
except IndexError:
n = pynotify.Notification("Notifikace", "Chyba špatné vstupní parametry!!")
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)
os.system("mplayer -really-quiet /usr/share/sounds/ubuntu/stereo/system-ready.ogg 2>/dev/null")