element-desktop icon indicating copy to clipboard operation
element-desktop copied to clipboard

Respect OS Do Not Disturb mode

Open pepyakin opened this issue 7 years ago • 19 comments

Description

In macOS there is a special mode called "Do not disturb" (DND). It is designed for cases when you need to focus on something or you just merely need to disable all notifications (imagine being on a talk but still being connected to the internet). If you activate this mode apps become silent, all notifications are not shown, etc.

However, it seems like that the Riot macOS app doesn't respect this setting and still will produce sounds. This is not solvable with individual notification settings (basically there is too many people you actually want to keep notifications while not in DND) and it is awkward to disable all notifications settings because it is too easy to forget to turn them off and turn them off again only for one app.

Version information

MacOS 10.14.1 Version 0.17.6 (0.17.6)

pepyakin avatar Nov 28 '18 15:11 pepyakin

:/ I don't think Electron has a built in way to tell if DND is enabled. Looks like Electron recommends using this library https://github.com/felixrieseberg/electron-notification-state which only has one commit... maybe it's just really stable and good at it's current state?

aaronraimist avatar Nov 28 '18 18:11 aaronraimist

That felixrieseberg library just wraps two other libraries for fetching mac/windows notification states (also written by felixrieseberg, and with 7 and 9 commits respectively). Scanning the code it does look feasible that it might just work?

lampholder avatar Nov 30 '18 09:11 lampholder

As explained in vector-im/element-web#13941, the same happens in linux.

yajo avatar Jun 06 '20 13:06 yajo

The Do Not Disturb mode on gnome is the dconf setting /org/gnome/desktop/notifications/show-banners. Element notifs should already be blocked by the setting, but sounds won't be. We will need to find a library that allows us to listen on dbus for when this value is updated.

Half-Shot avatar Aug 10 '20 15:08 Half-Shot

https://github.com/vector-im/element-desktop/pull/133 should hopefully address folks on GNOME

Half-Shot avatar Aug 10 '20 18:08 Half-Shot

Just to be clear, the preferred way on MacOS is to use the notifications API, so that do-not-disturb mode and other OS behavior is consistent.

otheus avatar Nov 10 '20 14:11 otheus

Electron does not support accessing that API seemingly, but closest we can get is to try and read the DND state using https://www.electronjs.org/docs/tutorial/notifications#do-not-disturb--session-state

t3chguy avatar Nov 10 '20 16:11 t3chguy

Op here. FWIW, for me this was solved by migrating to the web version, to PWA app within Chrome to be exact.

pepyakin avatar Nov 10 '20 16:11 pepyakin

Electron does not support accessing that API seemingly, but closest we can get is to try and read the DND state using https://www.electronjs.org/docs/tutorial/notifications#do-not-disturb--session-state

Electron refers to the same package of felixrieseberg in there official docs, but in the package's GitHub repo I found more than one issue complaint that this package is deprecated for the newer versions of node, I think it's a bad Idea to rely on it in element. maybe we can fork it update it's dependencies and republish it, then use it into our codebase or ...
"it" refers to the packages that this lib wrap, since it just a warper for : macos-notification-state and windows-notification-state written with the same guy as @lampholder said

tawfiek avatar Mar 23 '21 15:03 tawfiek

@tawfiek In general, I think this is a good idea. It always seems suspect to me to rely on 3rd party libraries whose code has not been audited and which cannot be absolutely authenticated. AFter all, this is communication software for private data...

otheus avatar Apr 30 '21 15:04 otheus

We have a do not disturb mode in user settings now. We could hook the OS level setting to honour that user preference.

From what I understand we will only be able to do that on the Electron side as the media queries are not exposing any of that

germain-gg avatar Jan 31 '22 12:01 germain-gg

We have a do not disturb mode in user settings now.

This was removed from labs in https://github.com/matrix-org/matrix-react-sdk/commit/4d7b7c4cc8027a6991295e063f10f7c1bdc9ee1f and I miss it dearly.

HarHarLinks avatar Jun 17 '22 21:06 HarHarLinks

There seem to be a user space lib to detect dnd mode on mac: https://github.com/felixrieseberg/macos-notification-state

My workaround is to close element app when I'm expecting to focus on work. Not ideal one may say /sarcasm

pszypowicz avatar Jun 18 '22 18:06 pszypowicz

surely there is a way 4 years later to use the native notification system and get do not disturb following for free, right? Is this not annoying others?

JMoVS avatar Nov 01 '22 14:11 JMoVS

There is some related spec work (currently not progressing):

https://github.com/matrix-org/matrix-spec-proposals/pull/3026 https://github.com/matrix-org/matrix-spec-proposals/pull/3767

HarHarLinks avatar Nov 01 '22 14:11 HarHarLinks

Hi @HarHarLinks , the mentioned specs are unrelated to this bug. They are a great feature, but the bug here is about being a good platform citizen as a desktop app.

JMoVS avatar Nov 01 '22 14:11 JMoVS

I would really like this feature to be implemented. Element is the only application I run on my desktop (Fedora Linux 38 with KDE Plasma Desktop) that does not respect the system-wide do-not-disturb setting. Even Slack (also an Electron app) respects the setting properly.

Conan-Kudo avatar May 07 '23 22:05 Conan-Kudo

Here's a PR from Mattermost, another electron-based messenger, implementing this:

https://github.com/mattermost/desktop/pull/1629

uzantome avatar Mar 11 '24 14:03 uzantome

@uzantome looks like it only supports Linux & Windows, and would create extra cost on the latter as it'd require signing extra binaries

t3chguy avatar Mar 11 '24 14:03 t3chguy