From d17ba79cddb4be1b951de50f0ee74e493317d3f7 Mon Sep 17 00:00:00 2001 From: MoetaYuko Date: Thu, 2 May 2024 13:34:45 +0800 Subject: [PATCH] disable night light button until gammastep fully terminated --- .config/ags/modules/sideright/quicktoggles.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/.config/ags/modules/sideright/quicktoggles.js b/.config/ags/modules/sideright/quicktoggles.js index 300e5236b..39b08c908 100644 --- a/.config/ags/modules/sideright/quicktoggles.js +++ b/.config/ags/modules/sideright/quicktoggles.js @@ -88,7 +88,19 @@ export const ModuleNightLight = (props = {}) => Widget.Button({ self.attribute.enabled = !self.attribute.enabled; self.toggleClassName('sidebar-button-active', self.attribute.enabled); if (self.attribute.enabled) Utils.execAsync('gammastep').catch(print) - else Utils.execAsync('pkill gammastep').catch(print); + else Utils.execAsync('pkill gammastep') + .then(() => { + // disable the button until fully terminated to avoid race + self.sensitive = false; + const source = setInterval(() => { + Utils.execAsync('pkill -0 gammastep') + .catch(() => { + self.sensitive = true; + source.destroy(); + }); + }, 500); + }) + .catch(print); }, child: MaterialIcon('nightlight', 'norm'), setup: (self) => {