hyprland/sway: add autoSuspend option independent of osConfig

This commit is contained in:
Aly Raffauf 2024-04-24 20:41:50 -04:00
parent f0daec2312
commit fd27d272fe
3 changed files with 20 additions and 5 deletions

View file

@ -11,6 +11,11 @@
options = { options = {
alyraffauf.desktop.hyprland.enable = alyraffauf.desktop.hyprland.enable =
lib.mkEnableOption "Enables hyprland with extra apps."; lib.mkEnableOption "Enables hyprland with extra apps.";
alyraffauf.desktop.hyprland.autoSuspend = lib.mkOption {
description = "Whether to autosuspend on idle.";
default = true;
type = lib.types.bool;
};
}; };
config = lib.mkIf config.alyraffauf.desktop.hyprland.enable { config = lib.mkIf config.alyraffauf.desktop.hyprland.enable {
@ -94,11 +99,14 @@
lock = pkgs.swaylock + ''/bin/swaylock -l -f -c 303446 --indicator-idle-visible --font "Noto SansM Nerd Font Regular" --ring-color ca9ee6 --inside-color 303446''; lock = pkgs.swaylock + ''/bin/swaylock -l -f -c 303446 --indicator-idle-visible --font "Noto SansM Nerd Font Regular" --ring-color ca9ee6 --inside-color 303446'';
idled = idled =
if osConfig.networking.hostName == "mauville" if config.alyraffauf.desktop.hyprland.autoSuspend
then ''${pkgs.swayidle}/bin/swayidle -w timeout 240 '${pkgs.brightnessctl}/bin/brightnessctl -s set 10' resume '${pkgs.brightnessctl}/bin/brightnessctl -r' timeout 300 '${lock}' timeout 330 '${config.wayland.windowManager.hyprland.package}/bin/hyprctl dispatch dpms off' resume '${config.wayland.windowManager.hyprland.package}/bin/hyprctl dispatch dpms off' before-sleep '${lock}' then ''
${pkgs.swayidle}/bin/swayidle -w timeout 240 '${pkgs.brightnessctl}/bin/brightnessctl -s set 10' resume '${pkgs.brightnessctl}/bin/brightnessctl -r' timeout 300 '${lock}' timeout 330 '${config.wayland.windowManager.hyprland.package}/bin/hyprctl dispatch dpms off' resume '${config.wayland.windowManager.hyprland.package}/bin/hyprctl dispatch dpms off' timeout 900 '${pkgs.systemd}/bin/systemctl suspend' before-sleep '${lock}'
'' ''
else '' else ''
${pkgs.swayidle}/bin/swayidle -w timeout 240 '${pkgs.brightnessctl}/bin/brightnessctl -s set 10' resume '${pkgs.brightnessctl}/bin/brightnessctl -r' timeout 300 '${lock}' timeout 330 '${config.wayland.windowManager.hyprland.package}/bin/hyprctl dispatch dpms off' resume '${config.wayland.windowManager.hyprland.package}/bin/hyprctl dispatch dpms off' timeout 900 '${pkgs.systemd}/bin/systemctl suspend' before-sleep '${lock}' ${pkgs.swayidle}/bin/swayidle -w timeout 240 '${pkgs.brightnessctl}/bin/brightnessctl -s set 10' resume '${pkgs.brightnessctl}/bin/brightnessctl -r' timeout 300 '${lock}' timeout 330 '${config.wayland.windowManager.hyprland.package}/bin/hyprctl dispatch dpms off' resume '${config.wayland.windowManager.hyprland.package}/bin/hyprctl dispatch dpms off' before-sleep '${lock}'
''; '';
hyprnome = pkgs.hyprnome + "/bin/hyprnome"; hyprnome = pkgs.hyprnome + "/bin/hyprnome";

View file

@ -8,6 +8,11 @@
imports = [./randomWallpaper.nix]; imports = [./randomWallpaper.nix];
options = { options = {
alyraffauf.desktop.sway.enable = lib.mkEnableOption "Sway with extra apps."; alyraffauf.desktop.sway.enable = lib.mkEnableOption "Sway with extra apps.";
alyraffauf.desktop.sway.autoSuspend = lib.mkOption {
description = "Whether to autosuspend on idle.";
default = true;
type = lib.types.bool;
};
}; };
config = lib.mkIf config.alyraffauf.desktop.sway.enable { config = lib.mkIf config.alyraffauf.desktop.sway.enable {
@ -78,7 +83,7 @@
logout = pkgs.wlogout + "/bin/wlogout"; logout = pkgs.wlogout + "/bin/wlogout";
lock = pkgs.swaylock + ''/bin/swaylock -l -f -c 303446 --indicator-idle-visible --font "Noto SansM Nerd Font Regular" --ring-color ca9ee6 --inside-color 303446''; lock = pkgs.swaylock + ''/bin/swaylock -l -f -c 303446 --indicator-idle-visible --font "Noto SansM Nerd Font Regular" --ring-color ca9ee6 --inside-color 303446'';
idled = idled =
if osConfig.networking.hostName == "mauville" if config.alyraffauf.desktop.sway.autoSuspend
then '' then ''
${pkgs.swayidle}/bin/swayidle -w \ ${pkgs.swayidle}/bin/swayidle -w \
timeout 240 '${pkgs.brightnessctl}/bin/brightnessctl -s set 10' \ timeout 240 '${pkgs.brightnessctl}/bin/brightnessctl -s set 10' \
@ -86,6 +91,7 @@
timeout 300 '${lock}' \ timeout 300 '${lock}' \
timeout 330 '${config.wayland.windowManager.sway.package}/bin/swaymsg "output * dpms off"' \ timeout 330 '${config.wayland.windowManager.sway.package}/bin/swaymsg "output * dpms off"' \
resume '${config.wayland.windowManager.sway.package}/bin/swaymsg "output * dpms on"' \ resume '${config.wayland.windowManager.sway.package}/bin/swaymsg "output * dpms on"' \
timeout 900 '${pkgs.systemd}/bin/systemctl suspend' \
before-sleep '${lock}' before-sleep '${lock}'
'' ''
else '' else ''
@ -95,7 +101,6 @@
timeout 300 '${lock}' \ timeout 300 '${lock}' \
timeout 330 '${config.wayland.windowManager.sway.package}/bin/swaymsg "output * dpms off"' \ timeout 330 '${config.wayland.windowManager.sway.package}/bin/swaymsg "output * dpms off"' \
resume '${config.wayland.windowManager.sway.package}/bin/swaymsg "output * dpms on"' \ resume '${config.wayland.windowManager.sway.package}/bin/swaymsg "output * dpms on"' \
timeout 900 '${pkgs.systemd}/bin/systemctl suspend' \
before-sleep '${lock}' before-sleep '${lock}'
''; '';

View file

@ -9,5 +9,7 @@
imports = [../../homeManagerModules ../../aly.nix]; imports = [../../homeManagerModules ../../aly.nix];
xdg.userDirs.music = "/mnt/Media/Music"; xdg.userDirs.music = "/mnt/Media/Music";
home.stateVersion = "23.11"; home.stateVersion = "23.11";
alyraffauf.desktop.hyprland.autoSuspend = false;
alyraffauf.desktop.sway.autoSuspend = false;
}; };
} }