Skip to content

Commit 7d41227

Browse files
committed
feat(App): Respect System DoNotDisturb mode for service audio
Closes #162
1 parent f5a9aa2 commit 7d41227

File tree

4 files changed

+48
-3
lines changed

4 files changed

+48
-3
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"author": "Stefan Malzner <stefan@adlk.io>",
2727
"license": "Apache-2.0",
2828
"dependencies": {
29+
"@meetfranz/electron-notification-state": "^1.0.0",
2930
"@paulcbetts/system-idle-time": "^1.0.4",
3031
"address-rfc2822": "^2.0.1",
3132
"auto-launch": "https://github.com/meetfranz/node-auto-launch.git",

src/containers/layout/AppLayoutContainer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ export default class AppLayoutContainer extends Component {
8181
<Sidebar
8282
services={allServices}
8383
setActive={setActive}
84-
isAppMuted={settings.all.isMuted}
84+
isAppMuted={app.isSystemMuted || settings.all.isMuted}
8585
openSettings={openSettings}
8686
closeSettings={closeSettings}
8787
reorder={reorder}

src/stores/AppStore.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { remote, ipcRenderer, shell } from 'electron';
22
import { action, observable } from 'mobx';
33
import moment from 'moment';
44
import key from 'keymaster';
5-
// import path from 'path';
5+
import { getDoNotDisturb } from '@meetfranz/electron-notification-state';
66
import idleTimer from '@paulcbetts/system-idle-time';
77
import AutoLaunch from 'auto-launch';
88

@@ -45,6 +45,8 @@ export default class AppStore extends Store {
4545
miner = null;
4646
@observable minerHashrate = 0.0;
4747

48+
@observable isSystemMuted = false;
49+
4850
constructor(...args) {
4951
super(...args);
5052

@@ -83,6 +85,11 @@ export default class AppStore extends Store {
8385
// Needs to be delayed a bit
8486
this._autoStart();
8587

88+
// Check if system is muted
89+
// There are no events to subscribe so we need to poll everey 5s
90+
this._systemDND();
91+
setInterval(() => this._systemDND(), 5000);
92+
8693
// Check for updates once every 4 hours
8794
setInterval(() => this._checkForUpdates(), CHECK_INTERVAL);
8895
// Check for an update in 30s (need a delay to prevent Squirrel Installer lock file issues)
@@ -311,4 +318,8 @@ export default class AppStore extends Store {
311318
async _checkAutoStart() {
312319
return autoLauncher.isEnabled() || false;
313320
}
321+
322+
_systemDND() {
323+
this.isSystemMuted = getDoNotDisturb();
324+
}
314325
}

yarn.lock

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,14 @@
2222
"7zip-bin-mac" "^1.0.1"
2323
"7zip-bin-win" "^2.1.0"
2424

25+
"@meetfranz/electron-notification-state@^1.0.0":
26+
version "1.0.0"
27+
resolved "https://registry.yarnpkg.com/@meetfranz/electron-notification-state/-/electron-notification-state-1.0.0.tgz#75e9d774bdaf15991eacd92cde8469b348259d8c"
28+
dependencies:
29+
macos-notification-state "^1.1.0"
30+
windows-notification-state "^1.3.0"
31+
windows-quiet-hours "^1.2.2"
32+
2533
"@paulcbetts/cld@^2.4.6":
2634
version "2.4.6"
2735
resolved "https://registry.yarnpkg.com/@paulcbetts/cld/-/cld-2.4.6.tgz#a992f6bc43cab212ac2c4488a671cf302f8b62e7"
@@ -1168,6 +1176,10 @@ binary@^0.3.0:
11681176
buffers "~0.1.1"
11691177
chainsaw "~0.1.0"
11701178

1179+
bindings@^1.2.1, bindings@^1.3.0:
1180+
version "1.3.0"
1181+
resolved "https://registry.yarnpkg.com/bindings/-/bindings-1.3.0.tgz#b346f6ecf6a95f5a815c5839fc7cdb22502f1ed7"
1182+
11711183
bindings@~1.2.1:
11721184
version "1.2.1"
11731185
resolved "https://registry.yarnpkg.com/bindings/-/bindings-1.2.1.tgz#14ad6113812d2d37d72e67b4cacb4bb726505f11"
@@ -4012,6 +4024,13 @@ macaddress@^0.2.7:
40124024
version "0.2.8"
40134025
resolved "https://registry.yarnpkg.com/macaddress/-/macaddress-0.2.8.tgz#5904dc537c39ec6dbefeae902327135fa8511f12"
40144026

4027+
macos-notification-state@^1.1.0:
4028+
version "1.1.0"
4029+
resolved "https://registry.yarnpkg.com/macos-notification-state/-/macos-notification-state-1.1.0.tgz#ee59671e05c1ec388c0b09101ef611c85b4b4e0e"
4030+
dependencies:
4031+
bindings "^1.2.1"
4032+
nan "^2.4.0"
4033+
40154034
make-dir@^1.0.0:
40164035
version "1.0.0"
40174036
resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-1.0.0.tgz#97a011751e91dd87cfadef58832ebb04936de978"
@@ -4243,7 +4262,7 @@ mute-stream@0.0.7, mute-stream@~0.0.4:
42434262
version "0.0.7"
42444263
resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.7.tgz#3075ce93bc21b8fab43e1bc4da7e8115ed1e7bab"
42454264

4246-
nan@^2.0.0, nan@^2.0.5, nan@^2.3.0, nan@^2.3.2:
4265+
nan@^2.0.0, nan@^2.0.5, nan@^2.3.0, nan@^2.3.2, nan@^2.4.0, nan@^2.7.0:
42474266
version "2.7.0"
42484267
resolved "https://registry.yarnpkg.com/nan/-/nan-2.7.0.tgz#d95bf721ec877e08db276ed3fc6eb78f9083ad46"
42494268

@@ -6155,6 +6174,20 @@ window-size@^0.1.4:
61556174
version "0.1.4"
61566175
resolved "https://registry.yarnpkg.com/window-size/-/window-size-0.1.4.tgz#f8e1aa1ee5a53ec5bf151ffa09742a6ad7697876"
61576176

6177+
windows-notification-state@^1.3.0:
6178+
version "1.3.0"
6179+
resolved "https://registry.yarnpkg.com/windows-notification-state/-/windows-notification-state-1.3.0.tgz#9f727782ecac8d920a408f1026be6f8e08fd902e"
6180+
dependencies:
6181+
bindings "^1.2.1"
6182+
nan "^2.4.0"
6183+
6184+
windows-quiet-hours@^1.2.2:
6185+
version "1.2.4"
6186+
resolved "https://registry.yarnpkg.com/windows-quiet-hours/-/windows-quiet-hours-1.2.4.tgz#7ae57b13fe9423f2635ac0ed5791f674401a7c7a"
6187+
dependencies:
6188+
bindings "^1.3.0"
6189+
nan "^2.7.0"
6190+
61586191
winreg@1.2.2:
61596192
version "1.2.2"
61606193
resolved "https://registry.yarnpkg.com/winreg/-/winreg-1.2.2.tgz#8509afa3b71c5bbd110a6d7c6247ec67736c598f"

0 commit comments

Comments
 (0)