mirror of https://gitlab.com/bashrc2/epicyon
Desktop notification types
parent
51adb34be3
commit
6cb33821a3
|
@ -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']
|
||||||
|
|
Loading…
Reference in New Issue