Skip to content

Commit 1a7bf86

Browse files
committed
More robus DND detection on Linux
1 parent 009173d commit 1a7bf86

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

app/utils/dndManager.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class DndManager extends EventEmitter {
3131
this._checkDnd()
3232
log.info('Stretchly: starting Do Not Disturb monitoring')
3333
if (process.platform === 'linux') {
34-
log.info(`System: Your Desktop seems to be ${process.env.ORIGINAL_XDG_CURRENT_DESKTOP}`)
34+
log.info(`System: Your Desktop seems to be ${this._desktopEnviroment}.`)
3535
}
3636
}
3737

@@ -43,10 +43,16 @@ class DndManager extends EventEmitter {
4343
log.info('Stretchly: stopping Do Not Disturb monitoring')
4444
}
4545

46-
async _isDndEnabledLinux () {
47-
const de = process.env.ORIGINAL_XDG_CURRENT_DESKTOP.toLowerCase()
46+
get _desktopEnviroment () {
47+
// https://github.com/electron/electron/issues/40795
4848
// https://specifications.freedesktop.org/mime-apps-spec/latest/file.html
4949
// https://specifications.freedesktop.org/menu-spec/latest/onlyshowin-registry.html
50+
return process.env.ORIGINAL_XDG_CURRENT_DESKTOP ||
51+
process.env.XDG_CURRENT_DESKTOP || 'unknown'
52+
}
53+
54+
async _isDndEnabledLinux () {
55+
const de = this._desktopEnviroment.toLocaleLowerCase()
5056

5157
switch (true) {
5258
case de.includes('kde'):
@@ -69,7 +75,7 @@ class DndManager extends EventEmitter {
6975
}
7076
} catch (e) { }
7177
break
72-
case de.includes('gnome'):
78+
case de.includes('gnome') || de.includes('unity'):
7379
try {
7480
const exec = this.util.promisify(require('node:child_process').exec)
7581
const { stdout } = await exec('gsettings get org.gnome.desktop.notifications show-banners')
@@ -100,7 +106,7 @@ class DndManager extends EventEmitter {
100106
return await this._getConfigValue('~/.config/lxqt/notifications.conf', 'doNotDisturb')
101107
default:
102108
if (!this._unsupDEErrorShown) {
103-
log.info(`Stretchly: ${process.env.ORIGINAL_XDG_CURRENT_DESKTOP} not supported for DND detection, yet.`)
109+
log.info(`Stretchly: ${this._desktopEnviroment} not supported for DND detection, yet.`)
104110
this._unsupDEErrorShown = true
105111
}
106112
return false

0 commit comments

Comments
 (0)