Files
dotfiles/modules/hyprland/home.nix

131 lines
3.1 KiB
Nix

{
inputs,
config,
lib,
pkgs,
...
}:
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 = [
./settings.nix
./runner.nix
./screenshot.nix
];
options.modules.Hyprland = {
enable = lib.mkEnableOption "Hyprland";
suspend-on-hibernate = lib.mkEnableOption "soh";
};
# TODO, split this into its own module;
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;
};
programs = {
wlogout = {
enable = true;
layout = [
{
"label" = "lock";
"action" = "loginctl lock-session";
"text" = "Lock";
"keybind" = "l";
}
{
"label" = "hibernate";
"action" = "systemctl hibernate";
"text" = "Hibernate";
"keybind" = "h";
}
{
"label" = "logout";
"action" = "loginctl terminate-user $USER";
"text" = "Logout";
"keybind" = "e";
}
{
# TODO add hypr shutdown
"label" = "shutdown";
"action" = "systemctl poweroff";
"text" = "Shutdown";
"keybind" = "s";
}
{
"label" = "suspend";
"action" = "systemctl suspend";
"text" = "Suspend";
"keybind" = "u";
}
{
"label" = "reboot";
"action" = "systemctl reboot";
"text" = "Reboot";
"keybind" = "r";
}
];
};
};
systemd.user.services."hyprland_suspend" = lib.mkIf cfg.suspend-on-hibernate {
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";
};
};
};
}