home: nixify swayidle (#60)
Some checks are pending
flakehub / flakehub-publish (push) Waiting to run
git-mirror / gitlab-sync (push) Waiting to run
nix-build / default-build (push) Waiting to run
nix-build / fallarbor-build (push) Waiting to run
nix-build / lavaridge-build (push) Waiting to run
nix-build / mauville-build (push) Waiting to run
nix-build / petalburg-build (push) Waiting to run
nix-build / rustboro-build (push) Waiting to run
nix-check / fmt-check (push) Waiting to run
nix-check / eval-check (push) Waiting to run

* home/hyprland: nixify idled

* home/hyprland: don't pass before-sleep commands if autosuspend is disabled

* home/hyprland: simplify idled options

* home/sway: mirror hyprland idleD improvements
This commit is contained in:
Aly Raffauf 2024-07-23 17:04:23 -04:00 committed by GitHub
parent ba1d6fe0fd
commit ae0e007ba2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 47 additions and 34 deletions

View file

@ -26,21 +26,27 @@ in {
fi
'';
idleD = pkgs.writeShellScript "hyprland-idled" ''
${lib.getExe pkgs.swayidle} -w \
before-sleep '${lib.getExe pkgs.playerctl} pause' \
before-sleep '${lib.getExe pkgs.swaylock}' \
timeout 240 '${lib.getExe pkgs.brightnessctl} -s set 10' \
resume '${lib.getExe pkgs.brightnessctl} -r' \
timeout 300 '${lib.getExe pkgs.swaylock}' \
timeout 330 '${hyprctl} dispatch dpms off' \
resume '${hyprctl} dispatch dpms on' \
${
idleD = let
timeouts =
["timeout 120 '${lib.getExe pkgs.brightnessctl} -s set 10' resume '${lib.getExe pkgs.brightnessctl} -r'"]
++ (
if cfg.desktop.hyprland.autoSuspend
then ''timeout 900 'sleep 2 && ${lib.getExe' pkgs.systemd "systemctl"} suspend' \''
else ''\''
}
'';
then ["timeout 600 'sleep 2 && ${lib.getExe' pkgs.systemd "systemctl"} suspend'"]
else [
"timeout 600 '${lib.getExe pkgs.swaylock}'"
"timeout 630 '${hyprctl} dispatch dpms off' resume '${hyprctl} dispatch dpms on'"
]
);
beforeSleeps =
lib.optionals cfg.desktop.hyprland.autoSuspend
[
"before-sleep '${lib.getExe pkgs.playerctl} pause'"
"before-sleep '${lib.getExe pkgs.swaylock}'"
];
in
pkgs.writeShellScript "hyprland-idled"
"${lib.getExe pkgs.swayidle} -w ${lib.strings.concatStringsSep " " (timeouts ++ beforeSleeps)}";
tablet = pkgs.writeShellScript "hyprland-tablet" ''
STATE=`${lib.getExe pkgs.dconf} read /org/gnome/desktop/a11y/applications/screen-keyboard-enabled`

View file

@ -7,21 +7,27 @@
cfg = config.ar.home;
swaymsg = lib.getExe' config.wayland.windowManager.sway.package "swaymsg";
in {
idleD = pkgs.writeShellScript "sway-idled" ''
${lib.getExe pkgs.swayidle} -w \
before-sleep '${lib.getExe pkgs.playerctl} pause' \
before-sleep '${lib.getExe pkgs.swaylock}' \
timeout 240 '${lib.getExe pkgs.brightnessctl} -s set 10' \
resume '${lib.getExe pkgs.brightnessctl} -r' \
timeout 300 '${lib.getExe pkgs.swaylock}' \
timeout 330 '${swaymsg} "output * dpms off"' \
resume '${swaymsg} "output * dpms on"' \
${
idleD = let
timeouts =
["timeout 120 '${lib.getExe pkgs.brightnessctl} -s set 10' resume '${lib.getExe pkgs.brightnessctl} -r'"]
++ (
if cfg.desktop.sway.autoSuspend
then ''timeout 900 '${lib.getExe' pkgs.systemd "systemctl"} suspend' \''
else ''\''
}
'';
then ["timeout 600 'sleep 2 && ${lib.getExe' pkgs.systemd "systemctl"} suspend'"]
else [
"timeout 600 '${lib.getExe pkgs.swaylock}'"
"timeout 630 '${swaymsg} \"output * dpms off\"' resume '${swaymsg} \"output * dpms on\"'"
]
);
beforeSleeps =
lib.optionals cfg.desktop.sway.autoSuspend
[
"before-sleep '${lib.getExe pkgs.playerctl} pause'"
"before-sleep '${lib.getExe pkgs.swaylock}'"
];
in
pkgs.writeShellScript "sway-idled"
"${lib.getExe pkgs.swayidle} -w ${lib.strings.concatStringsSep " " (timeouts ++ beforeSleeps)}";
randomWallpaper = pkgs.writeShellScript "sway-randomWallpaper" ''
kill `pidof swaybg`

View file

@ -10,8 +10,9 @@
modifier = "Mod4";
in {
enable = true;
wrapperFeatures.gtk = true;
checkConfig = false;
package = lib.mkDefault pkgs.swayfx;
wrapperFeatures.gtk = true;
config = {
bars = [{command = lib.getExe pkgs.waybar;}];
@ -162,8 +163,8 @@ in {
"${modifier}+Shift+S" = "move scratchpad";
# Screenshots
"PRINT" = "exec ${helpers.screenshot.screen}";
"${modifier}+PRINT" = "exec ${helpers.screenshot.region}";
"PRINT" = "exec ${helpers.screenshot}";
"Control+F12" = "exec ${helpers.screenshot}";
# Show/hide waybar
"${modifier}+F11" = "exec pkill -SIGUSR1 waybar";

View file

@ -57,7 +57,7 @@
autologin = "aly";
};
gnome.enable = true;
hyprland.enable = true;
};
users.aly = {