added sound notifications (used in mail for now) and more settings UI work
This commit is contained in:
		
							parent
							
								
									aea4815fbd
								
							
						
					
					
						commit
						83ef9dc3ca
					
				
					 10 changed files with 111 additions and 32 deletions
				
			
		|  | @ -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) | ||||
|  |  | |||
|  | @ -19,7 +19,7 @@ QUOTES = [ | |||
|     ("Freedom of the press is guaranteed only to those who own one", | ||||
|     "A. J. Liebling"), | ||||
|     ("We kill people based on metadata", | ||||
|     "Authoritarians") | ||||
|     "") | ||||
| ] | ||||
| shuffle(QUOTES) | ||||
| QUOTE = QUOTES[0] | ||||
|  |  | |||
|  | @ -2,6 +2,8 @@ | |||
| 
 | ||||
| get static directory and read static data files | ||||
| """ | ||||
| from typing import Union | ||||
| import os | ||||
| """ | ||||
|     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 | ||||
|  | @ -17,9 +19,6 @@ get static directory and read static data files | |||
|     along with this program.  If not, see <https://www.gnu.org/licenses/>. | ||||
| """ | ||||
| 
 | ||||
| from typing import Union | ||||
| import os | ||||
| 
 | ||||
| 
 | ||||
| def get_static_dir()->str: | ||||
|     return os.path.dirname(os.path.realpath(__file__)) + '/../../static-data/' | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue