use wlsunset for night light

This commit is contained in:
end-4
2023-12-29 11:33:01 +07:00
parent 46dfd0190d
commit 0832ba6b61
+17 -9
View File
@@ -68,24 +68,32 @@ export const HyprToggleIcon = (icon, name, hyprlandConfigValue, props = {}) => W
...props, ...props,
}) })
export const ModuleNightLight = (props = {}) => Widget.Button({ export const ModuleNightLight = (props = {}) => Widget.Button({ // TODO: Make this work
properties: [
['enabled', false],
['yellowlight', undefined],
],
className: 'txt-small sidebar-iconbutton', className: 'txt-small sidebar-iconbutton',
tooltipText: 'Night Light', tooltipText: 'Night Light',
onClicked: (button) => { onClicked: (self) => {
const shaderPath = JSON.parse(exec('hyprctl -j getoption decoration:screen_shader')).str; self._enabled = !self._enabled;
if (shaderPath != "[[EMPTY]]" && shaderPath != "") { self.toggleClassName('sidebar-button-active', self._enabled);
execAsync(['bash', '-c', `hyprctl keyword decoration:screen_shader ''`]).catch(print); if (self._enabled) {
button.toggleClassName('sidebar-button-active', false); self._inhibitor = Utils.subprocess(
['wlsunset'],
(output) => print(output),
(err) => logError(err),
self,
);
} }
else { else {
execAsync(['bash', '-c', `hyprctl keyword decoration:screen_shader ~/.config/hypr/shaders/extradark.frag`]).catch(print); self._inhibitor.force_exit();
button.toggleClassName('sidebar-button-active', true);
} }
}, },
child: MaterialIcon('nightlight', 'norm'), child: MaterialIcon('nightlight', 'norm'),
setup: setupCursorHover, setup: setupCursorHover,
...props, ...props,
}) });
export const ModuleInvertColors = (props = {}) => Widget.Button({ export const ModuleInvertColors = (props = {}) => Widget.Button({
className: 'txt-small sidebar-iconbutton', className: 'txt-small sidebar-iconbutton',