added sound notifications (used in mail for now) and more settings UI work

This commit is contained in:
Kevin Froman 2020-02-18 05:32:17 -06:00
parent aea4815fbd
commit 83ef9dc3ca
10 changed files with 111 additions and 32 deletions

View file

@ -13,7 +13,7 @@ else:
from utils.readstatic import get_static_dir
import config
from onionrplugins.onionrevents import event as plugin_api_event
"""
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -34,16 +34,22 @@ if not config.get('general.show_notifications', True):
notification_sound_file = get_static_dir() + "sounds/notification1.mp3"
def notify(title: str = "Onionr", message: str = ""):
"""Cross platform method to show a notification."""
if not notifications_enabled:
return
plugin_api_event("notification", data={"title": title, "message": message})
simplenotify.notify(title, message)
def notification_with_sound(sound = '', **kwargs):
if not notifications_enabled:
return
if not sound:
sound = notification_sound_file
try:
Popen(["mpv", notification_sound_file])
Popen(["mpv", sound])
except FileNotFoundError:
pass
notify(**kwargs)