disable night light button until gammastep fully terminated

This commit is contained in:
MoetaYuko
2024-05-02 13:34:45 +08:00
parent 2fc464123f
commit d17ba79cdd
+13 -1
View File
@@ -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) => {