From 83514e0640c230120640b58c28b02abba5c5a364 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Mon, 15 Mar 2021 12:59:17 +0000 Subject: [PATCH] Make notification client display of new posts optional --- README_commandline.md | 2 +- epicyon.py | 7 +++++++ notifications_client.py | 32 +++++++++++++++++++++----------- 3 files changed, 29 insertions(+), 12 deletions(-) diff --git a/README_commandline.md b/README_commandline.md index 94e848f00..71f402ec0 100644 --- a/README_commandline.md +++ b/README_commandline.md @@ -406,7 +406,7 @@ python3 epicyon.py --speaker yournickname@yourdomain Or if you have [picospeaker](https://gitlab.com/ky1e/picospeaker) installed: ``` bash -python3 epicyon.py --screenreader picospeaker --notify yournickname@yourdomain +python3 epicyon.py --notifyShowNewPosts --screenreader picospeaker --notify yournickname@yourdomain ``` You can also use the **--password** option to provide the password. This will then stay running and incoming posts will be announced as they arrive. diff --git a/epicyon.py b/epicyon.py index 89b1ebb72..0d9f61284 100644 --- a/epicyon.py +++ b/epicyon.py @@ -300,6 +300,12 @@ parser.add_argument("--noKeyPress", type=str2bool, nargs='?', const=True, default=False, help="Notification daemon does not wait for keypresses") +parser.add_argument("--notifyShowNewPosts", + dest='notifyShowNewPosts', + type=str2bool, nargs='?', + const=True, default=False, + help="Notification client shows/speaks new posts " + + "as they arrive") parser.add_argument("--noapproval", type=str2bool, nargs='?', const=True, default=False, help="Allow followers without approval") @@ -1870,6 +1876,7 @@ if args.notifications: args.notificationType, args.noKeyPress, storeInboxPosts, + args.notifyShowNewPosts, args.debug) sys.exit() diff --git a/notifications_client.py b/notifications_client.py index 395dd17e2..9bbde6404 100644 --- a/notifications_client.py +++ b/notifications_client.py @@ -596,6 +596,7 @@ def runNotificationsClient(baseDir: str, proxyType: str, httpPrefix: str, notificationType: str, noKeyPress: bool, storeInboxPosts: bool, + showNewPosts: bool, debug: bool) -> None: """Runs the notifications and screen reader client, which announces new inbox items @@ -630,6 +631,15 @@ def runNotificationsClient(baseDir: str, proxyType: str, httpPrefix: str, sayStr = '/q or /quit to exit' _sayCommand(sayStr, sayStr, screenreader, systemLanguage, espeak) + + currTimeline = '' + currInboxIndex = 0 + if showNewPosts: + currInboxIndex = 0 + _showLocalBox('inbox', + screenreader, systemLanguage, espeak, + currInboxIndex, 10) + currTimeline = 'inbox' print('') keyPress = _waitForKeypress(2, debug) @@ -658,8 +668,6 @@ def runNotificationsClient(baseDir: str, proxyType: str, httpPrefix: str, personCache = {} currDMIndex = 0 currSentIndex = 0 - currInboxIndex = 0 - currTimeline = '' while (1): session = createSession(proxyType) speakerJson = \ @@ -765,18 +773,20 @@ def runNotificationsClient(baseDir: str, proxyType: str, httpPrefix: str, else: content = '🔓 ' + messageStr - # say the speaker's name - _sayCommand(nameStr, nameStr, screenreader, - systemLanguage, espeak, - nameStr, gender) + if showNewPosts: + # say the speaker's name + _sayCommand(nameStr, nameStr, screenreader, + systemLanguage, espeak, + nameStr, gender) - time.sleep(2) + time.sleep(2) - # speak the post content - _sayCommand(content, messageStr, screenreader, - systemLanguage, espeak, - nameStr, gender) + # speak the post content + _sayCommand(content, messageStr, screenreader, + systemLanguage, espeak, + nameStr, gender) + # store incoming post if encryptedMessage: speakerJson['content'] = content speakerJson['say'] = messageStr