Merge branch 'main' of ssh://code.freedombone.net:2222/bashrc/epicyon into main

main
Bob Mottram 2021-03-09 21:22:44 +00:00
commit 3157ab3d4f
6 changed files with 42 additions and 0 deletions

View File

@ -77,6 +77,26 @@ def _playNotificationSound(soundFilename: str, player='ffplay') -> None:
' -autoexit -hide_banner -nodisp') ' -autoexit -hide_banner -nodisp')
def _desktopNotification(notificationType: str,
title: str, message: str)) -> None:
"""Shows a desktop notification
"""
if not notificationType:
return
if notificationType == 'notify-send':
# Ubuntu
os.system('notify-send "' + title + '" "' + message + '"')
elif notificationType == 'osascript':
# Mac
os.system("osascript -e 'display notification \"" +
message + "\" with title \"" + title + "\"'")
elif notificationType == 'New-BurntToastNotification':
# Windows
os.system("New-BurntToastNotification -Text \"" +
title + "\", '" + message + "'")
def runNotificationsClient(baseDir: str, proxyType: str, httpPrefix: str, def runNotificationsClient(baseDir: str, proxyType: str, httpPrefix: str,
nickname: str, domain: str, port: int, nickname: str, domain: str, port: int,
password: str, screenreader: str, password: str, screenreader: str,
@ -108,6 +128,8 @@ def runNotificationsClient(baseDir: str, proxyType: str, httpPrefix: str,
likeSoundFilename = 'like.ogg' likeSoundFilename = 'like.ogg'
shareSoundFilename = 'share.ogg' shareSoundFilename = 'share.ogg'
player = 'ffplay' player = 'ffplay'
notificationType = 'notify-send'
instanceTitle = 'Epicyon'
while (1): while (1):
session = createSession(proxyType) session = createSession(proxyType)
speakerJson = \ speakerJson = \
@ -125,26 +147,44 @@ def runNotificationsClient(baseDir: str, proxyType: str, httpPrefix: str,
if speakerJson['notify']['dm'] != prevDM: if speakerJson['notify']['dm'] != prevDM:
_playNotificationSound(soundsDir + '/' + _playNotificationSound(soundsDir + '/' +
dmSoundFilename, player) dmSoundFilename, player)
_desktopNotification(notificationType,
instanceTitle,
'New direct message')
elif replySoundFilename: elif replySoundFilename:
if speakerJson['notify']['reply'] != prevReply: if speakerJson['notify']['reply'] != prevReply:
_playNotificationSound(soundsDir + '/' + _playNotificationSound(soundsDir + '/' +
replySoundFilename, player) replySoundFilename, player)
_desktopNotification(notificationType,
instanceTitle,
'New reply')
elif calendarSoundFilename: elif calendarSoundFilename:
if speakerJson['notify']['calendar'] != prevCalendar: if speakerJson['notify']['calendar'] != prevCalendar:
_playNotificationSound(soundsDir + '/' + _playNotificationSound(soundsDir + '/' +
calendarSoundFilename, player) calendarSoundFilename, player)
_desktopNotification(notificationType,
instanceTitle,
'New calendar event')
elif followSoundFilename: elif followSoundFilename:
if speakerJson['notify']['followRequests'] != prevFollow: if speakerJson['notify']['followRequests'] != prevFollow:
_playNotificationSound(soundsDir + '/' + _playNotificationSound(soundsDir + '/' +
followSoundFilename, player) followSoundFilename, player)
_desktopNotification(notificationType,
instanceTitle,
'New follow request')
elif likeSoundFilename: elif likeSoundFilename:
if speakerJson['notify']['likedBy'] != prevLike: if speakerJson['notify']['likedBy'] != prevLike:
_playNotificationSound(soundsDir + '/' + _playNotificationSound(soundsDir + '/' +
likeSoundFilename, player) likeSoundFilename, player)
_desktopNotification(notificationType,
instanceTitle,
'New like')
elif shareSoundFilename: elif shareSoundFilename:
if speakerJson['notify']['share'] != prevShare: if speakerJson['notify']['share'] != prevShare:
_playNotificationSound(soundsDir + '/' + _playNotificationSound(soundsDir + '/' +
shareSoundFilename, player) shareSoundFilename, player)
_desktopNotification(notificationType,
instanceTitle,
'New shared item')
prevDM = speakerJson['notify']['dm'] prevDM = speakerJson['notify']['dm']
prevReply = speakerJson['notify']['reply'] prevReply = speakerJson['notify']['reply']

View File

@ -92,6 +92,8 @@ def _speakerPronounce(baseDir: str, sayText: str, translate: {}) -> str:
"Gmail": "G-mail", "Gmail": "G-mail",
"OpenPGP": "Open P-G-P", "OpenPGP": "Open P-G-P",
"Tor": "Toor", "Tor": "Toor",
"fediverse": "fediiverse",
"Fediverse": "Fediiverse",
" foss ": " free and open source software ", " foss ": " free and open source software ",
" floss ": " free libre and open source software ", " floss ": " free libre and open source software ",
" FOSS ": "free and open source software", " FOSS ": "free and open source software",

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.