Skip to content

Commit

Permalink
feat(notification): add sound player executable option (#1301)
Browse files Browse the repository at this point in the history
Pass the path to the player executable as a players array to play-sound so that it will check if the executable exists.
  • Loading branch information
warmar authored Dec 10, 2020
1 parent 3841666 commit 8d19231
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/reference/notification.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 3 additions & 1 deletion src/notification/sound.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit 8d19231

Please sign in to comment.