sideright: make idle inhibitor synced on ags restart

This commit is contained in:
end-4
2024-02-22 16:36:42 +07:00
parent a93399b150
commit d36c5a9779
3 changed files with 10 additions and 16 deletions
+7 -14
View File
@@ -89,7 +89,6 @@ export const HyprToggleIcon = async (icon, name, hyprlandConfigValue, props = {}
export const ModuleNightLight = (props = {}) => Widget.Button({ // TODO: Make this work
attribute: {
enabled: false,
yellowlight: undefined,
},
className: 'txt-small sidebar-iconbutton',
tooltipText: 'Night Light',
@@ -142,27 +141,21 @@ export const ModuleInvertColors = async (props = {}) => {
export const ModuleIdleInhibitor = (props = {}) => Widget.Button({ // TODO: Make this work
attribute: {
enabled: false,
inhibitor: undefined,
},
className: 'txt-small sidebar-iconbutton',
tooltipText: 'Keep system awake',
onClicked: (self) => {
self.attribute.enabled = !self.attribute.enabled;
self.toggleClassName('sidebar-button-active', self.attribute.enabled);
if (self.attribute.enabled) {
self.attribute.inhibitor = Utils.subprocess(
[`${App.configDir}/scripts/wayland-idle-inhibitor.py`],
(output) => print(output),
(err) => logError(err),
self,
);
}
else {
self.attribute.inhibitor.force_exit();
}
if (self.attribute.enabled) Utils.execAsync(['bash', '-c', `pidof wayland-idle-inhibitor.py || ${App.configDir}/scripts/wayland-idle-inhibitor.py`]).catch(print)
else Utils.execAsync('pkill -f wayland-idle-inhibitor.py').catch(print);
},
child: MaterialIcon('coffee', 'norm'),
setup: setupCursorHover,
setup: (self) => {
setupCursorHover(self);
self.attribute.enabled = !!exec('pidof wayland-idle-inhibitor.py');
self.toggleClassName('sidebar-button-active', self.attribute.enabled);
},
...props,
});
@@ -4,6 +4,7 @@ import sys
from dataclasses import dataclass
from signal import SIGINT, SIGTERM, signal
from threading import Event
import setproctitle
from pywayland.client.display import Display
from pywayland.protocol.idle_inhibit_unstable_v1.zwp_idle_inhibit_manager_v1 import (
@@ -78,4 +79,5 @@ def main() -> None:
if __name__ == "__main__":
setproctitle.setproctitle("wayland-idle-inhibitor.py")
main()
+1 -2
View File
@@ -22,8 +22,7 @@ webp-pixbuf-loader gtk-layer-shell gtk3 gtksourceview3 gobject-introspection upo
polkit-gnome gnome-keyring gnome-control-center blueberry networkmanager brightnessctl wlsunset gnome-bluetooth-3.0
### Widgets
# wayland-idle-inhibitor-git : providing `wayland-idle-inhibitor.py' used by the `Keep system awake' button in `.config/ags/widgets/sideright/quicktoggles.js'.
wayland-idle-inhibitor-git hypridle-git hyprlock-git wlogout wl-clipboard hyprpicker-git grim tesseract slurp anyrun-git
python-pywayland python-psutil hypridle-git hyprlock-git wlogout wl-clipboard hyprpicker-git grim tesseract slurp anyrun-git
### Fonts and Themes
adw-gtk3-git qt5ct gradience-git fontconfig lexend-fonts-git ttf-jetbrains-mono-nerd ttf-material-symbols-variable-git ttf-space-mono-nerd fish foot starship