From dcd6e3f8b94dc7b7446d82bf2aec0f3778a8f266 Mon Sep 17 00:00:00 2001 From: Will Hunt Date: Mon, 10 Aug 2020 18:44:39 +0100 Subject: [PATCH] fix lint --- src/do-not-disturb.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/do-not-disturb.js b/src/do-not-disturb.js index b6a71885..37af2ba6 100644 --- a/src/do-not-disturb.js +++ b/src/do-not-disturb.js @@ -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, -} \ No newline at end of file +};