2
from plyer.facades import Notification
3
from plyer.utils import whereis_exe
6
class NotifySendNotification(Notification):
7
''' Pops up a notification using notify-send
9
def _notify(self, **kwargs):
10
subprocess.call(["notify-send",
12
kwargs.get('message')])
15
class NotifyDbus(Notification):
16
''' notify using dbus interface
19
def _notify(self, **kwargs):
20
summary = kwargs.get('title', "title")
21
body = kwargs.get('message', "body")
22
app_name = kwargs.get('app_name', '')
23
app_icon = kwargs.get('app_icon', '')
24
timeout = kwargs.get('timeout', 5000)
25
actions = kwargs.get('actions', [])
26
hints = kwargs.get('hints', [])
27
replaces_id = kwargs.get('replaces_id', 0)
29
_bus_name = 'org.freedesktop.Notifications'
30
_object_path = '/org/freedesktop/Notifications'
31
_interface_name = _bus_name
34
session_bus = dbus.SessionBus()
35
obj = session_bus.get_object(_bus_name, _object_path)
36
interface = dbus.Interface(obj, _interface_name)
37
interface.Notify(app_name, replaces_id, app_icon,
38
summary, body, actions, hints, timeout)
47
sys.stderr.write("python-dbus not installed. try:"
48
"`sudo pip install python-dbus`.")
49
if whereis_exe('notify-send'):
50
return NotifySendNotification()
51
sys.stderr.write("notify-send not found.")