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

main
Bob Mottram 2021-03-15 14:58:42 +00:00
commit 207cbd792c
1 changed files with 38 additions and 14 deletions

View File

@ -11,6 +11,7 @@ import html
import time import time
import sys import sys
import select import select
import webbrowser
from pathlib import Path from pathlib import Path
from random import randint from random import randint
from utils import getStatusNumber from utils import getStatusNumber
@ -37,9 +38,26 @@ from pgp import pgpEncryptToActor
def _clearScreen() -> None: def _clearScreen() -> None:
"""Clears the screen
"""
os.system('cls' if os.name == 'nt' else 'clear') os.system('cls' if os.name == 'nt' else 'clear')
def _showDesktopBanner() -> None:
"""Shows the banner at the top
"""
bannerFilename = 'banner.txt'
if not os.path.isfile(bannerFilename):
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:
print(banner + '\n')
def _waitForKeypress(timeout: int, debug: bool) -> str: def _waitForKeypress(timeout: int, debug: bool) -> str:
"""Waits for a keypress with a timeout """Waits for a keypress with a timeout
Returns the key pressed, or None on timeout Returns the key pressed, or None on timeout
@ -379,12 +397,7 @@ def _showLocalBox(boxName: str,
# title # title
_clearScreen() _clearScreen()
bannerFilename = 'theme/starlight/banner.txt' _showDesktopBanner()
if os.path.isfile(bannerFilename):
with open(bannerFilename, 'r') as bannerFile:
banner = bannerFile.read()
if banner:
print(banner + '\n')
print(indent + boxName.upper() + '\n') print(indent + boxName.upper() + '\n')
maxPostIndex = len(index) maxPostIndex = len(index)
@ -419,6 +432,8 @@ def _showLocalBox(boxName: str,
while len(content) < 40: while len(content) < 40:
content += ' ' content += ' '
content = (content[:40]) if len(content) > 40 else content content = (content[:40]) if len(content) > 40 else content
if speakerJson.get('detectedLinks'):
content = '🔗' + content
print(indent + str(posStr) + ' | ' + str(name) + ' | ' + print(indent + str(posStr) + ' | ' + str(name) + ' | ' +
str(published) + ' | ' + str(content) + ' |') str(published) + ' | ' + str(content) + ' |')
ctr += 1 ctr += 1
@ -624,12 +639,7 @@ def runNotificationsClient(baseDir: str, proxyType: str, httpPrefix: str,
indent = '' indent = ''
_clearScreen() _clearScreen()
bannerFilename = 'theme/starlight/banner.txt' _showDesktopBanner()
if os.path.isfile(bannerFilename):
with open(bannerFilename, 'r') as bannerFile:
banner = bannerFile.read()
if banner:
print(banner + '\n')
espeak = None espeak = None
if screenreader: if screenreader:
@ -863,7 +873,8 @@ def runNotificationsClient(baseDir: str, proxyType: str, httpPrefix: str,
screenreader, systemLanguage, espeak, screenreader, systemLanguage, espeak,
currSentIndex, 10) currSentIndex, 10)
currTimeline = 'sent' currTimeline = 'sent'
elif keyPress == 'show' or keyPress.startswith('show in'): elif (keyPress == 'show' or keyPress.startswith('show in') or
keyPress == 'clear'):
currInboxIndex = 0 currInboxIndex = 0
_showLocalBox('inbox', _showLocalBox('inbox',
screenreader, systemLanguage, espeak, screenreader, systemLanguage, espeak,
@ -1130,3 +1141,16 @@ def runNotificationsClient(baseDir: str, proxyType: str, httpPrefix: str,
systemLanguage, espeak) systemLanguage, espeak)
else: else:
print('No --screenreader option was specified') 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('')