forked from Shinonome/dots-hyprland
sideright: hide night light button when unavailable
This commit is contained in:
@@ -78,38 +78,41 @@ export const HyprToggleIcon = async (icon, name, hyprlandConfigValue, props = {}
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const ModuleNightLight = (props = {}) => Widget.Button({
|
export const ModuleNightLight = async (props = {}) => {
|
||||||
attribute: {
|
if (!exec(`bash -c 'command -v gammastep'`)) return null;
|
||||||
enabled: false,
|
return Widget.Button({
|
||||||
},
|
attribute: {
|
||||||
className: 'txt-small sidebar-iconbutton',
|
enabled: false,
|
||||||
tooltipText: 'Night Light',
|
},
|
||||||
onClicked: (self) => {
|
className: 'txt-small sidebar-iconbutton',
|
||||||
self.attribute.enabled = !self.attribute.enabled;
|
tooltipText: 'Night Light',
|
||||||
self.toggleClassName('sidebar-button-active', self.attribute.enabled);
|
onClicked: (self) => {
|
||||||
if (self.attribute.enabled) Utils.execAsync('gammastep').catch(print)
|
self.attribute.enabled = !self.attribute.enabled;
|
||||||
else Utils.execAsync('pkill gammastep')
|
self.toggleClassName('sidebar-button-active', self.attribute.enabled);
|
||||||
.then(() => {
|
if (self.attribute.enabled) Utils.execAsync('gammastep').catch(print)
|
||||||
// disable the button until fully terminated to avoid race
|
else Utils.execAsync('pkill gammastep')
|
||||||
self.sensitive = false;
|
.then(() => {
|
||||||
const source = setInterval(() => {
|
// disable the button until fully terminated to avoid race
|
||||||
Utils.execAsync('pkill -0 gammastep')
|
self.sensitive = false;
|
||||||
.catch(() => {
|
const source = setInterval(() => {
|
||||||
self.sensitive = true;
|
Utils.execAsync('pkill -0 gammastep')
|
||||||
source.destroy();
|
.catch(() => {
|
||||||
});
|
self.sensitive = true;
|
||||||
}, 500);
|
source.destroy();
|
||||||
})
|
});
|
||||||
.catch(print);
|
}, 500);
|
||||||
},
|
})
|
||||||
child: MaterialIcon('nightlight', 'norm'),
|
.catch(print);
|
||||||
setup: (self) => {
|
},
|
||||||
setupCursorHover(self);
|
child: MaterialIcon('nightlight', 'norm'),
|
||||||
self.attribute.enabled = !!exec('pidof gammastep');
|
setup: (self) => {
|
||||||
self.toggleClassName('sidebar-button-active', self.attribute.enabled);
|
setupCursorHover(self);
|
||||||
},
|
self.attribute.enabled = !!exec('pidof gammastep');
|
||||||
...props,
|
self.toggleClassName('sidebar-button-active', self.attribute.enabled);
|
||||||
});
|
},
|
||||||
|
...props,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
export const ModuleInvertColors = async (props = {}) => {
|
export const ModuleInvertColors = async (props = {}) => {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ const togglesBox = Widget.Box({
|
|||||||
ToggleIconBluetooth(),
|
ToggleIconBluetooth(),
|
||||||
await ModuleRawInput(),
|
await ModuleRawInput(),
|
||||||
await HyprToggleIcon('touchpad_mouse', 'No touchpad while typing', 'input:touchpad:disable_while_typing', {}),
|
await HyprToggleIcon('touchpad_mouse', 'No touchpad while typing', 'input:touchpad:disable_while_typing', {}),
|
||||||
ModuleNightLight(),
|
await ModuleNightLight(),
|
||||||
await ModuleInvertColors(),
|
await ModuleInvertColors(),
|
||||||
ModuleIdleInhibitor(),
|
ModuleIdleInhibitor(),
|
||||||
]
|
]
|
||||||
|
|||||||
Reference in New Issue
Block a user