From 8d192317badfd71a7cd8f0115ba9e6fc951c1874 Mon Sep 17 00:00:00 2001 From: Warwick Marangos Date: Wed, 9 Dec 2020 20:59:10 -0500 Subject: [PATCH] feat(notification): add sound player executable option (#1301) Pass the path to the player executable as a players array to play-sound so that it will check if the executable exists. --- docs/reference/notification.md | 1 + src/config.ts | 1 + src/notification/sound.ts | 4 +++- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/reference/notification.md b/docs/reference/notification.md index 3a0ef298a0..2f31673841 100644 --- a/docs/reference/notification.md +++ b/docs/reference/notification.md @@ -8,6 +8,7 @@ You can test your notification configuration by running `npm run test:notificati |---|---| | `DESKTOP_NOTIFICATIONS` | Display desktop notifications using [node-notifier](https://www.npmjs.com/package/node-notifier). | | `PLAY_SOUND` | Play this sound notification if a product is found. Relative path accepted, valid formats: wav, mp3, flac, E.g.: `path/to/notification.wav`, [free sounds available](https://notificationsounds.com/) | +| `SOUND_PLAYER` | Override the default sound player using the specified executable. | ???+ attention If you're on Windows, you must have the proper library to run. diff --git a/src/config.ts b/src/config.ts index 34dda3e2c5..cb8cd3758d 100644 --- a/src/config.ts +++ b/src/config.ts @@ -270,6 +270,7 @@ const notifications = { channel: envOrString(process.env.SLACK_CHANNEL), token: envOrString(process.env.SLACK_TOKEN) }, + soundPlayer: envOrString(process.env.SOUND_PLAYER), telegram: { accessToken: envOrString(process.env.TELEGRAM_ACCESS_TOKEN), chatId: envOrArray(process.env.TELEGRAM_CHAT_ID) diff --git a/src/notification/sound.ts b/src/notification/sound.ts index 9e164516e5..4bbe9bb2c1 100644 --- a/src/notification/sound.ts +++ b/src/notification/sound.ts @@ -6,7 +6,9 @@ import {logger} from '../logger'; let player: PlaySound; if (config.notifications.playSound) { - player = playerLib(); + player = config.notifications.soundPlayer + ? playerLib({players: [config.notifications.soundPlayer]}) + : playerLib(); if (player.player === null) { logger.warn("✖ couldn't find sound player");