diff --git a/install-desktop-notifications b/install-desktop-notifications index d3853110b..d6664e141 100755 --- a/install-desktop-notifications +++ b/install-desktop-notifications @@ -8,10 +8,10 @@ fi if [ ! -f /usr/bin/zenity ]; then if [ -f /usr/bin/apt ]; then - sudo apt install zenity + sudo apt -y install zenity fi if [ -f /usr/bin/pacman ]; then - sudo pacman -S zenity + sudo pacman -S --noconfirm zenity fi fi @@ -32,19 +32,28 @@ fi if [ ! -f /usr/bin/git ]; then if [ -f /usr/bin/apt ]; then - sudo apt install git + sudo apt -y install git fi if [ -f /usr/bin/pacman ]; then - sudo pacman -S git + sudo pacman -S --noconfirm git + fi +fi + +if [ ! -f /usr/bin/gpg ]; then + if [ -f /usr/bin/apt ]; then + sudo apt -y install gnupg + fi + if [ -f /usr/bin/pacman ]; then + sudo pacman -S --noconfirm gnupg fi fi if [ ! -f /usr/bin/python3 ]; then if [ -f /usr/bin/apt ]; then - sudo apt install python3 + sudo apt -y install python3 fi if [ -f /usr/bin/pacman ]; then - sudo pacman -S python + sudo pacman -S --noconfirm python fi fi @@ -65,7 +74,7 @@ if [ -f /usr/bin/notify-send ]; then notificationType='notify-send' else if [ -f /usr/bin/zenity ]; then - notificationType='zenity' + notificationType='zenity' fi fi if [[ ! "$notificationType" ]]; then @@ -73,6 +82,11 @@ if [[ ! "$notificationType" ]]; then exit 5 fi +if [ ! -d ${HOME}/.gnupg ]; then + echo 'Generating GPG key' + gpg --quick-generate-key "${HANDLE}" ed25519 cert +fi + { echo '[Unit]'; echo 'Description=Epicyon Desktop Notifications'; echo ''; diff --git a/notifications_client.py b/notifications_client.py index 06eb6188d..8e2bfd0c5 100644 --- a/notifications_client.py +++ b/notifications_client.py @@ -87,6 +87,8 @@ def _speakerEspeak(espeak, pitch: int, rate: int, srange: int, def _speakerPicospeaker(pitch: int, rate: int, systemLanguage: str, sayText: str) -> None: + """TTS using picospeaker + """ speakerLang = 'en-GB' if systemLanguage: if systemLanguage.startswith('fr'): @@ -363,6 +365,15 @@ def _readLocalBoxPost(boxName: str, index: int, sayStr = 'Reading ' + boxName + ' post ' + str(index) + '.' _sayCommand(sayStr, sayStr, screenreader, systemLanguage, espeak) + if speakerJson.get('id') and isPGPEncrypted(content): + sayStr = 'Encrypted message. Please enter your passphrase.' + _sayCommand(sayStr, sayStr, screenreader, systemLanguage, espeak) + content = pgpDecrypt(content, speakerJson['id']) + if isPGPEncrypted(content): + sayStr = 'Message could not be decrypted' + _sayCommand(sayStr, sayStr, screenreader, systemLanguage, espeak) + return + time.sleep(2) # say the speaker's name @@ -462,7 +473,9 @@ def _showLocalBox(notifyJson: {}, boxName: str, while len(name) < 16: name += ' ' content = speakerJson['content'] - if speakerJson.get('detectedLinks'): + if isPGPEncrypted(content): + content = '🔒' + content + elif speakerJson.get('detectedLinks'): if len(speakerJson['detectedLinks']) > 0: content = '🔗' + content if len(content) > 40: @@ -853,15 +866,13 @@ def runNotificationsClient(baseDir: str, proxyType: str, httpPrefix: str, if speakerJson.get('id') and \ isPGPEncrypted(messageStr): encryptedMessage = True - messageStr = pgpDecrypt(messageStr, - speakerJson['id']) content = messageStr if speakerJson.get('content'): if not encryptedMessage: content = speakerJson['content'] else: - content = '🔓 ' + messageStr + content = '🔒 Encrypted message' if showNewPosts: # say the speaker's name @@ -877,12 +888,7 @@ def runNotificationsClient(baseDir: str, proxyType: str, httpPrefix: str, nameStr, gender) # store incoming post - if encryptedMessage: - speakerJson['content'] = content - speakerJson['say'] = messageStr - speakerJson['decrypted'] = True - _storeMessage(speakerJson, 'dm') - elif speakerJson.get('direct'): + if encryptedMessage or speakerJson.get('direct'): speakerJson['decrypted'] = False _storeMessage(speakerJson, 'dm') else: