mirror of
https://github.com/element-hq/element-desktop
synced 2025-03-15 00:47:47 +01:00
fix lint
This commit is contained in:
parent
688ebb7171
commit
dcd6e3f8b9
@ -2,6 +2,8 @@
|
||||
// Always false if the platform doesn't support it.
|
||||
global.isDoNotDisturb = false;
|
||||
|
||||
const LINUX_SETTING_COMMAND = "gsettings get org.gnome.desktop.notifications show-banners";
|
||||
|
||||
function init() {
|
||||
if (process.platform === "linux") {
|
||||
return initForLinux();
|
||||
@ -12,15 +14,15 @@ async function initForLinux() {
|
||||
// TODO: This is specific to the GNOME desktop implementation of DND
|
||||
|
||||
const DBus = require('dbus-next');
|
||||
const child_process = require('child_process');
|
||||
const { execSync } = require('child_process');
|
||||
// First we need to determine the value of dnd.
|
||||
try {
|
||||
// XXX: After much flailing about, I couldn't find another acceptable way to fetch this setting value.
|
||||
const value = child_process.execSync("gsettings get org.gnome.desktop.notifications show-banners", { encoding: "utf-8"}).trim();
|
||||
const value = execSync(LINUX_SETTING_COMMAND, { encoding: "utf-8" }).trim();
|
||||
if (value) {
|
||||
// Anything other than true will be safely false.
|
||||
// Invert because show-banners === do-disturb :)
|
||||
global.isDoNotDisturb = !Boolean(value === 'true');
|
||||
global.isDoNotDisturb = value !== 'true';
|
||||
console.log(`do-not-disturb value has been detected as: ${global.isDoNotDisturb}`);
|
||||
}
|
||||
} catch (ex) {
|
||||
@ -34,8 +36,8 @@ async function initForLinux() {
|
||||
process.on("exit", () => {
|
||||
session.disconnect();
|
||||
});
|
||||
let obj = await session.getProxyObject('ca.desrt.dconf', '/ca/desrt/dconf/Writer/user');
|
||||
let signaller = obj.getInterface('ca.desrt.dconf.Writer');
|
||||
const obj = await session.getProxyObject('ca.desrt.dconf', '/ca/desrt/dconf/Writer/user');
|
||||
const signaller = obj.getInterface('ca.desrt.dconf.Writer');
|
||||
signaller.on('Notify', (settingName) => {
|
||||
if (settingName == '/org/gnome/desktop/notifications/show-banners') {
|
||||
// The D-BUS signal will only tell you that the setting changed, but annoyingly
|
||||
@ -48,4 +50,4 @@ async function initForLinux() {
|
||||
|
||||
module.exports = {
|
||||
init,
|
||||
}
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user