mirror of https://gitlab.com/bashrc2/epicyon
Merge branch 'main' of ssh://code.freedombone.net:2222/bashrc/epicyon into main
commit
7a8d8768db
|
|
@ -408,3 +408,11 @@ python3 epicyon.py --screenreader picospeaker --notify yournickname@yourdomain -
|
||||||
```
|
```
|
||||||
|
|
||||||
This will then stay running and incoming posts will be announced as they arrive.
|
This will then stay running and incoming posts will be announced as they arrive.
|
||||||
|
|
||||||
|
## Desktop notifications
|
||||||
|
|
||||||
|
You can get desktop notifications either by running the screen reader as shown above, or if you only want notifications and not spoken messages then you can run the client as follows, without the *screenreader* option:
|
||||||
|
|
||||||
|
``` bash
|
||||||
|
python3 epicyon.py --notify yournickname@yourdomain --password [yourpassword]
|
||||||
|
```
|
||||||
|
|
|
||||||
|
|
@ -310,6 +310,9 @@ parser.add_argument("--positivevoting", type=str2bool, nargs='?',
|
||||||
parser.add_argument("--debug", type=str2bool, nargs='?',
|
parser.add_argument("--debug", type=str2bool, nargs='?',
|
||||||
const=True, default=False,
|
const=True, default=False,
|
||||||
help="Show debug messages")
|
help="Show debug messages")
|
||||||
|
parser.add_argument("--notificationSounds", type=str2bool, nargs='?',
|
||||||
|
const=True, default=True,
|
||||||
|
help="Play notification sounds")
|
||||||
parser.add_argument("--authenticatedFetch", type=str2bool, nargs='?',
|
parser.add_argument("--authenticatedFetch", type=str2bool, nargs='?',
|
||||||
const=True, default=False,
|
const=True, default=False,
|
||||||
help="Enable authentication on GET requests" +
|
help="Enable authentication on GET requests" +
|
||||||
|
|
@ -1932,7 +1935,7 @@ if args.notifications:
|
||||||
runNotificationsClient(baseDir, proxyType, httpPrefix,
|
runNotificationsClient(baseDir, proxyType, httpPrefix,
|
||||||
nickname, domain, port, args.password,
|
nickname, domain, port, args.password,
|
||||||
args.screenreader, args.language,
|
args.screenreader, args.language,
|
||||||
args.debug)
|
args.notificationSounds, args.debug)
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
if federationList:
|
if federationList:
|
||||||
|
|
|
||||||
|
|
@ -98,13 +98,37 @@ def _desktopNotification(notificationType: str,
|
||||||
title + "\", '" + message + "'")
|
title + "\", '" + message + "'")
|
||||||
|
|
||||||
|
|
||||||
|
def _sayCommand(sayStr: str, screenreader: str,
|
||||||
|
systemLanguage: str, espeak=None) -> None:
|
||||||
|
"""Speaks a command
|
||||||
|
"""
|
||||||
|
print(sayStr)
|
||||||
|
if not screenreader:
|
||||||
|
return
|
||||||
|
|
||||||
|
cmdSpeakerName = 'screen reader'
|
||||||
|
pitch = getSpeakerPitch(cmdSpeakerName,
|
||||||
|
screenreader, 'They/Them')
|
||||||
|
rate = getSpeakerRate(cmdSpeakerName, screenreader)
|
||||||
|
srange = getSpeakerRange(cmdSpeakerName)
|
||||||
|
|
||||||
|
if screenreader == 'espeak':
|
||||||
|
_speakerEspeak(espeak, pitch, rate, srange, sayStr)
|
||||||
|
elif screenreader == 'picospeaker':
|
||||||
|
_speakerPicospeaker(pitch, rate,
|
||||||
|
systemLanguage, sayStr)
|
||||||
|
|
||||||
|
|
||||||
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,
|
||||||
systemLanguage: str, debug: bool) -> None:
|
systemLanguage: str,
|
||||||
|
notificationSounds: bool,
|
||||||
|
debug: bool) -> None:
|
||||||
"""Runs the notifications and screen reader client,
|
"""Runs the notifications and screen reader client,
|
||||||
which announces new inbox items
|
which announces new inbox items
|
||||||
"""
|
"""
|
||||||
|
espeak = None
|
||||||
if screenreader:
|
if screenreader:
|
||||||
if screenreader == 'espeak':
|
if screenreader == 'espeak':
|
||||||
print('Setting up espeak')
|
print('Setting up espeak')
|
||||||
|
|
@ -116,8 +140,13 @@ def runNotificationsClient(baseDir: str, proxyType: str, httpPrefix: str,
|
||||||
print('Running ' + screenreader + ' for ' + nickname + '@' + domain)
|
print('Running ' + screenreader + ' for ' + nickname + '@' + domain)
|
||||||
else:
|
else:
|
||||||
print('Running desktop notifications for ' + nickname + '@' + domain)
|
print('Running desktop notifications for ' + nickname + '@' + domain)
|
||||||
|
if notificationSounds:
|
||||||
|
print('Notification sounds ON')
|
||||||
|
else:
|
||||||
|
print('Notification sounds OFF')
|
||||||
print('/q or /quit to exit')
|
print('/q or /quit to exit')
|
||||||
|
|
||||||
|
originalScreenReader = screenreader
|
||||||
domainFull = getFullDomain(domain, port)
|
domainFull = getFullDomain(domain, port)
|
||||||
actor = httpPrefix + '://' + domainFull + '/users/' + nickname
|
actor = httpPrefix + '://' + domainFull + '/users/' + nickname
|
||||||
prevSay = ''
|
prevSay = ''
|
||||||
|
|
@ -155,47 +184,57 @@ def runNotificationsClient(baseDir: str, proxyType: str, httpPrefix: str,
|
||||||
soundsDir = 'theme/default/sounds'
|
soundsDir = 'theme/default/sounds'
|
||||||
if speakerJson['notify']['dm'] != prevDM:
|
if speakerJson['notify']['dm'] != prevDM:
|
||||||
if speakerJson['notify']['dm'] is True:
|
if speakerJson['notify']['dm'] is True:
|
||||||
_playNotificationSound(soundsDir + '/' +
|
if notificationSounds:
|
||||||
dmSoundFilename, player)
|
_playNotificationSound(soundsDir + '/' +
|
||||||
|
dmSoundFilename, player)
|
||||||
_desktopNotification(notificationType, title,
|
_desktopNotification(notificationType, title,
|
||||||
'New direct message ' +
|
'New direct message ' +
|
||||||
actor + '/dm')
|
actor + '/dm')
|
||||||
prevDM = speakerJson['notify']['dm']
|
prevDM = speakerJson['notify']['dm']
|
||||||
elif speakerJson['notify']['reply'] != prevReply:
|
elif speakerJson['notify']['reply'] != prevReply:
|
||||||
if speakerJson['notify']['reply'] is True:
|
if speakerJson['notify']['reply'] is True:
|
||||||
_playNotificationSound(soundsDir + '/' +
|
if notificationSounds:
|
||||||
replySoundFilename, player)
|
_playNotificationSound(soundsDir + '/' +
|
||||||
|
replySoundFilename,
|
||||||
|
player)
|
||||||
_desktopNotification(notificationType, title,
|
_desktopNotification(notificationType, title,
|
||||||
'New reply ' +
|
'New reply ' +
|
||||||
actor + '/tlreplies')
|
actor + '/tlreplies')
|
||||||
prevReply = speakerJson['notify']['reply']
|
prevReply = speakerJson['notify']['reply']
|
||||||
elif speakerJson['notify']['calendar'] != prevCalendar:
|
elif speakerJson['notify']['calendar'] != prevCalendar:
|
||||||
if speakerJson['notify']['calendar'] is True:
|
if speakerJson['notify']['calendar'] is True:
|
||||||
_playNotificationSound(soundsDir + '/' +
|
if notificationSounds:
|
||||||
calendarSoundFilename, player)
|
_playNotificationSound(soundsDir + '/' +
|
||||||
|
calendarSoundFilename,
|
||||||
|
player)
|
||||||
_desktopNotification(notificationType, title,
|
_desktopNotification(notificationType, title,
|
||||||
'New calendar event ' +
|
'New calendar event ' +
|
||||||
actor + '/calendar')
|
actor + '/calendar')
|
||||||
prevCalendar = speakerJson['notify']['calendar']
|
prevCalendar = speakerJson['notify']['calendar']
|
||||||
elif speakerJson['notify']['followRequests'] != prevFollow:
|
elif speakerJson['notify']['followRequests'] != prevFollow:
|
||||||
if speakerJson['notify']['followRequests'] is True:
|
if speakerJson['notify']['followRequests'] is True:
|
||||||
_playNotificationSound(soundsDir + '/' +
|
if notificationSounds:
|
||||||
followSoundFilename, player)
|
_playNotificationSound(soundsDir + '/' +
|
||||||
|
followSoundFilename,
|
||||||
|
player)
|
||||||
_desktopNotification(notificationType, title,
|
_desktopNotification(notificationType, title,
|
||||||
'New follow request ' +
|
'New follow request ' +
|
||||||
actor + '/followers#buttonheader')
|
actor + '/followers#buttonheader')
|
||||||
prevFollow = speakerJson['notify']['followRequests']
|
prevFollow = speakerJson['notify']['followRequests']
|
||||||
elif speakerJson['notify']['likedBy'] != prevLike:
|
elif speakerJson['notify']['likedBy'] != prevLike:
|
||||||
_playNotificationSound(soundsDir + '/' +
|
if notificationSounds:
|
||||||
likeSoundFilename, player)
|
_playNotificationSound(soundsDir + '/' +
|
||||||
|
likeSoundFilename, player)
|
||||||
_desktopNotification(notificationType, title,
|
_desktopNotification(notificationType, title,
|
||||||
'New like ' +
|
'New like ' +
|
||||||
speakerJson['notify']['likedBy'])
|
speakerJson['notify']['likedBy'])
|
||||||
prevLike = speakerJson['notify']['likedBy']
|
prevLike = speakerJson['notify']['likedBy']
|
||||||
elif speakerJson['notify']['share'] != prevShare:
|
elif speakerJson['notify']['share'] != prevShare:
|
||||||
if speakerJson['notify']['share'] is True:
|
if speakerJson['notify']['share'] is True:
|
||||||
_playNotificationSound(soundsDir + '/' +
|
if notificationSounds:
|
||||||
shareSoundFilename, player)
|
_playNotificationSound(soundsDir + '/' +
|
||||||
|
shareSoundFilename,
|
||||||
|
player)
|
||||||
_desktopNotification(notificationType, title,
|
_desktopNotification(notificationType, title,
|
||||||
'New shared item ' +
|
'New shared item ' +
|
||||||
actor + '/shares')
|
actor + '/shares')
|
||||||
|
|
@ -257,3 +296,37 @@ def runNotificationsClient(baseDir: str, proxyType: str, httpPrefix: str,
|
||||||
keyPress = keyPress[1:]
|
keyPress = keyPress[1:]
|
||||||
if keyPress == 'q' or keyPress == 'quit' or keyPress == 'exit':
|
if keyPress == 'q' or keyPress == 'quit' or keyPress == 'exit':
|
||||||
break
|
break
|
||||||
|
elif keyPress == 'sounds on' or keyPress == 'sound':
|
||||||
|
sayStr = 'Notification sounds ON'
|
||||||
|
_sayCommand(sayStr, screenreader,
|
||||||
|
systemLanguage, espeak)
|
||||||
|
notificationSounds = True
|
||||||
|
elif keyPress == 'sounds off' or keyPress == 'nosound':
|
||||||
|
sayStr = 'Notification sounds OFF'
|
||||||
|
_sayCommand(sayStr, screenreader,
|
||||||
|
systemLanguage, espeak)
|
||||||
|
notificationSounds = False
|
||||||
|
elif (keyPress == 'speak' or
|
||||||
|
keyPress == 'screen reader on' or
|
||||||
|
keyPress == 'speaker on' or
|
||||||
|
keyPress == 'talker on' or
|
||||||
|
keyPress == 'reader on'):
|
||||||
|
if originalScreenReader:
|
||||||
|
screenreader = originalScreenReader
|
||||||
|
sayStr = 'Screen reader ON'
|
||||||
|
_sayCommand(sayStr, screenreader,
|
||||||
|
systemLanguage, espeak)
|
||||||
|
else:
|
||||||
|
print('No --screenreader option was specified')
|
||||||
|
elif (keyPress == 'mute' or
|
||||||
|
keyPress == 'screen reader off' or
|
||||||
|
keyPress == 'speaker off' or
|
||||||
|
keyPress == 'talker off' or
|
||||||
|
keyPress == 'reader off'):
|
||||||
|
if originalScreenReader:
|
||||||
|
screenreader = None
|
||||||
|
sayStr = 'Screen reader OFF'
|
||||||
|
_sayCommand(sayStr, originalScreenReader,
|
||||||
|
systemLanguage, espeak)
|
||||||
|
else:
|
||||||
|
print('No --screenreader option was specified')
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue