From 5849ef37ff8009e9a6bec98411fcafa7cb3e6e0e Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Mon, 15 Mar 2021 14:29:20 +0000 Subject: [PATCH 1/6] Show or clear --- notifications_client.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/notifications_client.py b/notifications_client.py index 54b346584..84057e616 100644 --- a/notifications_client.py +++ b/notifications_client.py @@ -863,7 +863,8 @@ def runNotificationsClient(baseDir: str, proxyType: str, httpPrefix: str, screenreader, systemLanguage, espeak, currSentIndex, 10) currTimeline = 'sent' - elif keyPress == 'show' or keyPress.startswith('show in'): + elif (keyPress == 'show' or keyPress.startswith('show in') or + keyPress == 'clear'): currInboxIndex = 0 _showLocalBox('inbox', screenreader, systemLanguage, espeak, From c7eb730c061d9ef53f4cb350bac2af35d3f861f9 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Mon, 15 Mar 2021 14:30:59 +0000 Subject: [PATCH 2/6] Tidying --- notifications_client.py | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/notifications_client.py b/notifications_client.py index 84057e616..7ed10f5b9 100644 --- a/notifications_client.py +++ b/notifications_client.py @@ -37,9 +37,22 @@ from pgp import pgpEncryptToActor def _clearScreen() -> None: + """Clears the screen + """ os.system('cls' if os.name == 'nt' else 'clear') +def _showDesktopBanner() -> None: + """Shows the banner at the top + """ + bannerFilename = 'theme/starlight/banner.txt' + if os.path.isfile(bannerFilename): + with open(bannerFilename, 'r') as bannerFile: + banner = bannerFile.read() + if banner: + print(banner + '\n') + + def _waitForKeypress(timeout: int, debug: bool) -> str: """Waits for a keypress with a timeout Returns the key pressed, or None on timeout @@ -379,12 +392,7 @@ def _showLocalBox(boxName: str, # title _clearScreen() - bannerFilename = 'theme/starlight/banner.txt' - if os.path.isfile(bannerFilename): - with open(bannerFilename, 'r') as bannerFile: - banner = bannerFile.read() - if banner: - print(banner + '\n') + _showDesktopBanner() print(indent + boxName.upper() + '\n') maxPostIndex = len(index) @@ -619,17 +627,12 @@ def runNotificationsClient(baseDir: str, proxyType: str, httpPrefix: str, """Runs the notifications and screen reader client, which announces new inbox items """ - indent = ' ' + indent = ' ' if showNewPosts: indent = '' _clearScreen() - bannerFilename = 'theme/starlight/banner.txt' - if os.path.isfile(bannerFilename): - with open(bannerFilename, 'r') as bannerFile: - banner = bannerFile.read() - if banner: - print(banner + '\n') + _showDesktopBanner() espeak = None if screenreader: From 0a7f21416320716b789cb59853c19aa864947f81 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Mon, 15 Mar 2021 14:31:33 +0000 Subject: [PATCH 3/6] Less indentation --- notifications_client.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/notifications_client.py b/notifications_client.py index 7ed10f5b9..95767540f 100644 --- a/notifications_client.py +++ b/notifications_client.py @@ -46,11 +46,12 @@ def _showDesktopBanner() -> None: """Shows the banner at the top """ bannerFilename = 'theme/starlight/banner.txt' - if os.path.isfile(bannerFilename): - with open(bannerFilename, 'r') as bannerFile: - banner = bannerFile.read() - if banner: - print(banner + '\n') + if not os.path.isfile(bannerFilename): + return + with open(bannerFilename, 'r') as bannerFile: + banner = bannerFile.read() + if banner: + print(banner + '\n') def _waitForKeypress(timeout: int, debug: bool) -> str: From 42e11d3b83742f8296f5e898de517b4b0d1fa2b7 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Mon, 15 Mar 2021 14:36:03 +0000 Subject: [PATCH 4/6] Customisable desktop client banner --- notifications_client.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/notifications_client.py b/notifications_client.py index 95767540f..439937d0b 100644 --- a/notifications_client.py +++ b/notifications_client.py @@ -45,9 +45,12 @@ def _clearScreen() -> None: def _showDesktopBanner() -> None: """Shows the banner at the top """ - bannerFilename = 'theme/starlight/banner.txt' + bannerFilename = 'banner.txt' if not os.path.isfile(bannerFilename): - return + bannerTheme = 'starlight' + bannerFilename = 'theme/' + bannerTheme + '/banner.txt' + if not os.path.isfile(bannerFilename): + return with open(bannerFilename, 'r') as bannerFile: banner = bannerFile.read() if banner: From a640a6f61ade661cc61a64bf5442bc7943dc10fd Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Mon, 15 Mar 2021 14:53:21 +0000 Subject: [PATCH 5/6] Opening web links with the desktop client --- notifications_client.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/notifications_client.py b/notifications_client.py index 439937d0b..4ad9b2a0d 100644 --- a/notifications_client.py +++ b/notifications_client.py @@ -11,6 +11,7 @@ import html import time import sys import select +import webbrowser from pathlib import Path from random import randint from utils import getStatusNumber @@ -1138,3 +1139,16 @@ def runNotificationsClient(baseDir: str, proxyType: str, httpPrefix: str, systemLanguage, espeak) else: print('No --screenreader option was specified') + elif keyPress.startswith('open '): + if speakerJson.get('detectedLinks'): + sayStr = 'Opening web links in browser.' + _sayCommand(sayStr, sayStr, originalScreenReader, + systemLanguage, espeak) + for url in speakerJson['detectedLinks']: + if '://' in url: + webbrowser.open(url) + else: + sayStr = 'There are no web links to open.' + _sayCommand(sayStr, sayStr, originalScreenReader, + systemLanguage, espeak) + print('') From dcde088955768c2972e26a978682aeb108e93d6e Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Mon, 15 Mar 2021 14:58:28 +0000 Subject: [PATCH 6/6] Add icon to indicate web links --- notifications_client.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/notifications_client.py b/notifications_client.py index 4ad9b2a0d..f4eaff0e3 100644 --- a/notifications_client.py +++ b/notifications_client.py @@ -432,6 +432,8 @@ def _showLocalBox(boxName: str, while len(content) < 40: content += ' ' content = (content[:40]) if len(content) > 40 else content + if speakerJson.get('detectedLinks'): + content = '🔗' + content print(indent + str(posStr) + ' | ' + str(name) + ' | ' + str(published) + ' | ' + str(content) + ' |') ctr += 1