Skip to content

Commit

Permalink
desktop: use uwsm to run hyprland
Browse files Browse the repository at this point in the history
This is much more robust than starting the session from the compositor config.

It will also become the upstream-sanctioned method to start a hyprland session
with proper systemd integration: hyprwm/Hyprland#8339
  • Loading branch information
Atemu committed Nov 10, 2024
1 parent 96f1b7c commit 34fffbd
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions modules/desktop/module.nix
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ in

services.displayManager.defaultSession =
if this.hypr.enable
then "hyprland"
then "Hyprland-uwsm"
else if this.tablet
then "gnome"
else "none+i3";
Expand All @@ -91,11 +91,13 @@ in
'';

programs.hyprland.enable = this.hypr.enable;
systemd.user.targets.hypr-session = lib.mkIf this.hypr.enable {
bindsTo = [ "graphical-session.target" ];
wants = [ "graphical-session-pre.target" ];
after = [ "graphical-session-pre.target" ];

programs.uwsm.enable = true;
programs.uwsm.waylandCompositors.Hyprland = {
binPath = lib.getExe config.programs.hyprland.package;
prettyName = "Hyprland";
};

systemd.user.services.hypridle = lib.mkIf this.hypr.enable {
serviceConfig = {
ExecStart = lib.getExe config.services.hypridle.package;
Expand All @@ -107,24 +109,27 @@ in
procps
swaylock
];
partOf = [ "graphical-session.target" ];
after = [ "graphical-session.target" ];
wantedBy = [ "hypr-session.target" ];
wantedBy = [ "[email protected]" ];
after = [ "[email protected]" ]; # TODO should this be [email protected] instead?
before = [ "[email protected]" ];
partOf = [ "[email protected]" ];
};

# A second hypridle daemon that activates power savings after 2s of idle
systemd.user.services.hypridle-power = lib.mkIf this.hypr.hypridle-power {
serviceConfig = {
# Quiet because I don't care about logging these actions and they're very frequent
ExecStart = "${lib.getExe config.services.hypridle.package} -c ${./hypridle-power.conf} --quiet";
};
path = [ config.services.power-profiles-daemon.package ];
partOf = [ "graphical-session.target" ];
wantedBy = [ "wayland-session@Hyprland.target" ];
after = [
"graphical-session.target"
"[email protected]"
# Let the regular hypridle register itself first to avoid any issues/races
"hypridle.service"
];
wantedBy = [ "hypr-session.target" ];
before = [ "[email protected]" ];
partOf = [ "[email protected]" ];
};
assertions = [
{
Expand Down

0 comments on commit 34fffbd

Please sign in to comment.