qol(Hibernate/Sleep): Now works 🎉

This commit is contained in:
2025-12-03 10:42:03 +00:00
parent 40d22f087d
commit 10582a5727
3 changed files with 90 additions and 21 deletions

View File

@@ -7,6 +7,18 @@
}:
let
cfg = config.modules.Hyprland;
suspend = pkgs.writeShellScript "hyprland_suspend" ''
#!/bin/bash
case "$1" in
suspend)
killall -STOP Hyprland
;;
resume)
killall -CONT Hyprland
;;
esac
'';
in
{
imports = [
@@ -17,33 +29,76 @@ in
options.modules.Hyprland = {
enable = lib.mkEnableOption "Hyprland";
};
config.wayland.windowManager.hyprland = lib.mkIf cfg.enable {
enable = true;
# set the flake package
# settings = { };
systemd.variables = [ "--all" ];
package = inputs.hyprland.packages.${pkgs.stdenv.hostPlatform.system}.hyprland;
portalPackage =
inputs.hyprland.packages.${pkgs.stdenv.hostPlatform.system}.xdg-desktop-portal-hyprland;
};
# TODO, split this into its own module;
config.programs = lib.mkIf cfg.enable {
wlogout = {
config = lib.mkIf cfg.enable {
wayland.windowManager.hyprland = {
enable = true;
# set the flake package
# settings = { };
systemd.variables = [ "--all" ];
package = inputs.hyprland.packages.${pkgs.stdenv.hostPlatform.system}.hyprland;
portalPackage =
inputs.hyprland.packages.${pkgs.stdenv.hostPlatform.system}.xdg-desktop-portal-hyprland;
};
foot = {
enable = true;
settings = {
main = {
term = "xterm-256color";
programs = {
wlogout = {
enable = true;
};
foot = {
enable = true;
settings = {
main = {
term = "xterm-256color";
font = "CaskaydiaCove Nerd Font Mono:size=12";
};
font = "CaskaydiaCove Nerd Font Mono:size=12";
};
mouse = {
hide-when-typing = "yes";
mouse = {
hide-when-typing = "yes";
};
};
};
};
systemd.user.services."hyprland_suspend" = {
Unit = {
Description = "Suspend hyprland";
Before = [
"systemd-suspend.service"
"systemd-hibernate.service"
"nvidia-suspend.service"
"nvidia-hibernate.service"
];
};
Install = {
WantedBy = [
"systemd-suspend.service"
"systemd-hibernate.service"
];
};
Service = {
Type = "oneshot";
ExecStart = "${suspend} suspend";
};
};
systemd.user.services."hyprland_resume" = {
Unit = {
Description = "Resume hyprland";
After = [
"systemd-suspend.service"
"systemd-hibernate.service"
"nvidia-resume.service"
];
};
Install = {
WantedBy = [
"systemd-suspend.service"
"systemd-hibernate.service"
];
};
Service = {
Type = "oneshot";
ExecStart = "${suspend} resume";
};
};
};
}

View File

@@ -14,6 +14,19 @@ in
};
config = lib.mkIf cfg.enable {
programs.xwayland.enable = true;
boot.kernelParams = [
"resume=UUID=d9b81619-5772-4ac4-bcd5-552e1e784f9e"
"resume_offset=141042944"
];
boot.resumeDevice = "/dev/disk/by-uuid/d9b81619-5772-4ac4-bcd5-552e1e784f9e";
powerManagement.enable = true;
swapDevices = [
# [[ Hibernate ]]
{
device = "/var/lib/swapfile";
size = 48 * 1024; # 48GB in MB
}
];
programs.hyprland = {
enable = true;
# set the flake package