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 = {
alyraffauf.desktop.hyprland.enable =
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 {
@ -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'';
idled =
if osConfig.networking.hostName == "mauville"
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}'
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' timeout 900 '${pkgs.systemd}/bin/systemctl suspend' before-sleep '${lock}'
''
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";

View file

@ -8,6 +8,11 @@
imports = [./randomWallpaper.nix];
options = {
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 {
@ -78,7 +83,7 @@
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'';
idled =
if osConfig.networking.hostName == "mauville"
if config.alyraffauf.desktop.sway.autoSuspend
then ''
${pkgs.swayidle}/bin/swayidle -w \
timeout 240 '${pkgs.brightnessctl}/bin/brightnessctl -s set 10' \
@ -86,6 +91,7 @@
timeout 300 '${lock}' \
timeout 330 '${config.wayland.windowManager.sway.package}/bin/swaymsg "output * dpms off"' \
resume '${config.wayland.windowManager.sway.package}/bin/swaymsg "output * dpms on"' \
timeout 900 '${pkgs.systemd}/bin/systemctl suspend' \
before-sleep '${lock}'
''
else ''
@ -95,7 +101,6 @@
timeout 300 '${lock}' \
timeout 330 '${config.wayland.windowManager.sway.package}/bin/swaymsg "output * dpms off"' \
resume '${config.wayland.windowManager.sway.package}/bin/swaymsg "output * dpms on"' \
timeout 900 '${pkgs.systemd}/bin/systemctl suspend' \
before-sleep '${lock}'
'';

View file

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