fix(hyprland): make services more reliable

This commit is contained in:
Moritz Böhme 2023-04-30 18:35:46 +02:00
parent 35ddc6a33c
commit 6fad257d5b
Signed by: moritz
GPG key ID: 970C6E89EB0547A9

View file

@ -44,6 +44,7 @@ in
wayland.windowManager.hyprland = { wayland.windowManager.hyprland = {
enable = true; enable = true;
package = hyprland; package = hyprland;
recommendedEnvironment = true;
extraConfig = import ./config.nix args; extraConfig = import ./config.nix args;
}; };
}; };
@ -59,7 +60,7 @@ in
# start using systemd service # start using systemd service
systemd = { systemd = {
enable = true; enable = true;
target = "hyprland-session.target"; target = "graphical-session.target";
}; };
settings = { settings = {
@ -87,11 +88,11 @@ in
events = [ events = [
{ {
event = "before-sleep"; event = "before-sleep";
command = "${pkgs.swaylock-effects}/bin/swaylock -fF"; command = "${pkgs.swaylock}/bin/swaylock -fF";
} }
{ {
event = "lock"; event = "lock";
command = "${pkgs.swaylock-effects}/bin/swaylock -fF"; command = "${pkgs.swaylock}/bin/swaylock -fF";
} }
]; ];
timeouts = [ timeouts = [
@ -105,10 +106,8 @@ in
command = "${pkgs.systemd}/bin/loginctl lock-session"; command = "${pkgs.systemd}/bin/loginctl lock-session";
} }
]; ];
systemdTarget = "hyprland-session.target";
}; };
# start swayidle as part of hyprland, not sway
systemd.user.services.swayidle.Install.WantedBy = lib.mkForce [ "hyprland-session.target" ];
}; };
# adds pam module for swaylock # adds pam module for swaylock
@ -116,27 +115,28 @@ in
# start hyprpaper daemon using systemd unit (to set wallpaper) # start hyprpaper daemon using systemd unit (to set wallpaper)
systemd.user.services.hyprpaper = { systemd.user.services.hyprpaper =
enable = true; let
path = [ pkgs.hyprpaper ]; wallpaper = "/home/moritz/.config/wallpapers/a_short_walk.png";
wantedBy = [ "hyprland-session.target" ]; config = pkgs.writeTextFile {
after = [ "hyprland-session.target" ]; name = "hyprpaper.conf";
script = "hyprpaper"; text = ''
};
# set hyprpaper conf (for setting initial background)
home-manager.users.moritz.xdg.configFile."hypr/hyprpaper.conf" = {
text =
let
setWallpaper = wallpaper: ''
preload = ${wallpaper} preload = ${wallpaper}
wallpaper = ,${wallpaper} wallpaper = ,${wallpaper}
''; '';
in };
setWallpaper "/home/moritz/.config/wallpapers/a_short_walk.png"; in
onChange = "${pkgs.systemd}/bin/systemctl restart --user hyprpaper.service"; {
}; enable = true;
partOf = [ "graphical-session.target" ];
wantedBy = [ "graphical-session.target" ];
after = [ "graphical-session.target" ];
serviceConfig = {
ExecStart = "${pkgs.hyprpaper}/bin/hyprpaper -c ${config}";
RestartSec = "1s";
Restart = "on-failure";
};
};
# only consider graphical-session.target started when hyprland-sesstion.target is reached # only consider graphical-session.target started when hyprland-sesstion.target is reached
systemd.user.targets.hyprland-session = { systemd.user.targets.hyprland-session = {
@ -144,6 +144,17 @@ in
before = [ "graphical-session.target" ]; before = [ "graphical-session.target" ];
}; };
systemd.user.services.xdg-desktop-portal-hyprland = {
after = [ "hyprland-session.target" ];
wantedBy = [ "hyprland-session.target" ];
};
home-manager.users.moritz.systemd.user.services.nextcloud-client = {
Service = {
RestartSec = "1s";
Restart = "on-failure";
};
};
# add user packages for wayland and hyprland in particular # add user packages for wayland and hyprland in particular
users.users.moritz.packages = with pkgs; [ users.users.moritz.packages = with pkgs; [
@ -206,7 +217,7 @@ in
# dekstop portal (for screensharing) # dekstop portal (for screensharing)
xdg.portal = { xdg.portal = {
enable = true; enable = true;
wlr.enable = true; wlr.enable = mkForce false;
extraPortals = [ pkgs.xdg-desktop-portal-hyprland ]; extraPortals = [ pkgs.xdg-desktop-portal-hyprland ];
}; };
}; };