feat: uwsm for wayland session management

This commit is contained in:
Patrick 2024-10-27 12:56:32 +01:00
parent 51fad81bdc
commit c33810a8cd
Signed by: patrick
GPG key ID: 451F95EFB8BECD0F
9 changed files with 44 additions and 22 deletions

View file

@ -28,4 +28,18 @@ lib.optionalAttrs (!minimal) {
pkgs.xdg-desktop-portal-gtk pkgs.xdg-desktop-portal-gtk
]; ];
}; };
services.displayManager.enable = true;
programs.uwsm = {
enable = true;
waylandCompositors = {
hyprland = {
binPath = "/etc/profiles/per-user/patrick/bin/Hyprland";
prettyName = "Hyprland";
};
sway = {
binPath = "/etc/profiles/per-user/patrick/bin/sway";
prettyName = "Sway";
};
};
};
} }

View file

@ -46,6 +46,6 @@ writeShellApplication {
fi fi
# kitty should be from user env # kitty should be from user env
kitty --detach -d "$(readlink "/proc/''${SELECTED}/cwd")" $TERMINAL --detach -d "$(readlink "/proc/''${SELECTED}/cwd")"
''; '';
} }

View file

@ -1,9 +1,13 @@
{ pkgs, ... }: { lib, ... }:
{ {
stylix.targets.fuzzel.enable = true; stylix.targets.fuzzel.enable = true;
home.packages = with pkgs; [ programs.fuzzel = {
(writeShellScriptBin "fuzzel" '' enable = true;
${lib.getExe fuzzel} --background-color=000000ff settings = {
'') main = {
]; launch-prefix = "uwsm app --";
};
colors.background = lib.mkForce "000000ff";
};
};
} }

View file

@ -142,9 +142,9 @@ in
"SUPER + SHIFT,comma,movetoworkspace,-1" "SUPER + SHIFT,comma,movetoworkspace,-1"
"SUPER + SHIFT,period,movetoworkspace,+1" "SUPER + SHIFT,period,movetoworkspace,+1"
"SUPER,b,exec,firefox" "SUPER,b,exec,uwsm app -- firefox"
"SUPER,t,exec,kitty" "SUPER,t,exec,uwsm app -- kitty"
",Menu,exec,fuzzel" ",Menu,exec,uwsm app -- fuzzel"
"SUPER,c,exec,${lib.getExe pkgs.scripts.clone-term}" "SUPER,c,exec,${lib.getExe pkgs.scripts.clone-term}"
"CTRL,F7,pass,class:^(discord)$" "CTRL,F7,pass,class:^(discord)$"
@ -153,7 +153,7 @@ in
"CTRL,F8,pass,class:^(TeamSpeak 3)$" "CTRL,F8,pass,class:^(TeamSpeak 3)$"
"CTRL,F9,exec,systemctl --user start swww-update-wallpaper" "CTRL,F9,exec,systemctl --user start swww-update-wallpaper"
"SUPER + SHIFT,q,exit" "SUPER + SHIFT,q,exec,uwsm stop"
] ]
++ flip concatMap (map toString (lib.lists.range 1 9)) (x: [ ++ flip concatMap (map toString (lib.lists.range 1 9)) (x: [
"SUPER,${monitor_binds."${x}"},workspace,${x}" "SUPER,${monitor_binds."${x}"},workspace,${x}"
@ -172,6 +172,7 @@ in
"GDK_BACKEND,wayland" "GDK_BACKEND,wayland"
"WLR_DRM_NO_ATOMIC,1" # retest on newest nvidia driver "WLR_DRM_NO_ATOMIC,1" # retest on newest nvidia driver
"XDG_SESSION_TYPE,wayland" "XDG_SESSION_TYPE,wayland"
"TERMINAL,uwsm app -- kitty"
] ]
++ optionals (elem "nvidia" nixosConfig.services.xserver.videoDrivers) [ ++ optionals (elem "nvidia" nixosConfig.services.xserver.videoDrivers) [
# See https://wiki.hyprland.org/Nvidia/ # See https://wiki.hyprland.org/Nvidia/
@ -198,10 +199,6 @@ in
}; };
decoration.rounding = 4; decoration.rounding = 4;
exec-once = [ exec-once = [
"dbus-update-activation-environment --systemd WAYLAND_DISPLAY XDG_CURRENT_DESKTOP"
"systemctl --user import-environment WAYLAND_DISPLAY XDG_CURRENT_DESKTOP"
"systemctl --user restart xdg-desktop-portal.service"
"${pkgs.waybar}/bin/waybar"
"${pkgs.swaynotificationcenter}/bin/swaync" "${pkgs.swaynotificationcenter}/bin/swaync"
]; ];
misc = { misc = {
@ -299,6 +296,7 @@ in
exec-once = ${pkgs.xorg.xprop}/bin/xprop -root -f _XWAYLAND_GLOBAL_OUTPUT_SCALE 32c -set _XWAYLAND_GLOBAL_OUTPUT_SCALE 2 exec-once = ${pkgs.xorg.xprop}/bin/xprop -root -f _XWAYLAND_GLOBAL_OUTPUT_SCALE 32c -set _XWAYLAND_GLOBAL_OUTPUT_SCALE 2
exec-once = ${float_script} exec-once = ${float_script}
env = XCURSOR_SIZE,48 env = XCURSOR_SIZE,48
exec-once = uwsm finalize
''; '';
}; };

View file

@ -15,6 +15,7 @@
command = "swaymsg input \"*\" xkb_switch_layout 1"; command = "swaymsg input \"*\" xkb_switch_layout 1";
always = true; always = true;
} }
{ command = "uwsm finalize"; }
]; ];
input = { input = {
"*" = { "*" = {

View file

@ -21,9 +21,9 @@ in
services = { services = {
swww = { swww = {
Install.WantedBy = [ "graphical-session.target" ]; Install.WantedBy = [ "graphical-session.target" ];
Unit.After = [ "graphical-session.target" ];
Unit = { Unit = {
Description = "Wayland wallpaper daemon"; Description = "Wayland wallpaper daemon";
PartOf = [ "graphical-session.target" ];
}; };
Service = { Service = {
ExecStart = "${pkgs.swww}/bin/swww-daemon"; ExecStart = "${pkgs.swww}/bin/swww-daemon";
@ -31,7 +31,6 @@ in
}; };
}; };
swww-update-wallpaper = { swww-update-wallpaper = {
Install.WantedBy = [ "default.target" ];
Unit.Description = "Update the wallpaper"; Unit.Description = "Update the wallpaper";
Service = { Service = {
Type = "oneshot"; Type = "oneshot";
@ -42,7 +41,8 @@ in
}; };
}; };
timers.swww-update-wallpaper = { timers.swww-update-wallpaper = {
Install.WantedBy = [ "timers.target" ]; Install.WantedBy = [ "graphical-session.target" ];
Unit.After = [ "graphical-session.target" ];
Unit.Description = "Periodically switch to a new wallpaper"; Unit.Description = "Periodically switch to a new wallpaper";
Timer.OnCalendar = "*:0/3"; # Every 5 minutes Timer.OnCalendar = "*:0/3"; # Every 5 minutes
}; };

View file

@ -5,9 +5,13 @@
... ...
}: }:
{ {
systemd.user.services."waybar" = {
Unit.After = [ "graphical-session.target" ];
Service.Slice = [ "app-graphical.slice" ];
};
programs.waybar = { programs.waybar = {
enable = true; enable = true;
systemd.enable = false; systemd.enable = true;
style = style =
( (
{ {

View file

@ -24,6 +24,8 @@
".config/google-chrome" ".config/google-chrome"
".cache/google-chrome" ".cache/google-chrome"
".config/gh"
".local/share/osu" ".local/share/osu"
".config/obs-studio" ".config/obs-studio"

View file

@ -62,9 +62,8 @@
''; '';
# Autostart hyprland if on tty1 (once, don't restart after logout) # Autostart hyprland if on tty1 (once, don't restart after logout)
programs.zsh.initExtra = lib.mkOrder 9999 '' programs.zsh.initExtra = lib.mkOrder 9999 ''
if [[ -t 0 && "$(tty || true)" == /dev/tty1 && -z "$DISPLAY" && -z "$WAYLAND_DISPLAY" ]]; then if uwsm check may-start ; then
echo "Login shell detected. Starting hyprland..." exec systemd-cat -t uwsm_start uwsm start -S -F hyprland
dbus-run-session Hyprland
fi fi
''; '';
} }