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
];
};
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
# 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;
home.packages = with pkgs; [
(writeShellScriptBin "fuzzel" ''
${lib.getExe fuzzel} --background-color=000000ff
'')
];
programs.fuzzel = {
enable = true;
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,period,movetoworkspace,+1"
"SUPER,b,exec,firefox"
"SUPER,t,exec,kitty"
",Menu,exec,fuzzel"
"SUPER,b,exec,uwsm app -- firefox"
"SUPER,t,exec,uwsm app -- kitty"
",Menu,exec,uwsm app -- fuzzel"
"SUPER,c,exec,${lib.getExe pkgs.scripts.clone-term}"
"CTRL,F7,pass,class:^(discord)$"
@ -153,7 +153,7 @@ in
"CTRL,F8,pass,class:^(TeamSpeak 3)$"
"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: [
"SUPER,${monitor_binds."${x}"},workspace,${x}"
@ -172,6 +172,7 @@ in
"GDK_BACKEND,wayland"
"WLR_DRM_NO_ATOMIC,1" # retest on newest nvidia driver
"XDG_SESSION_TYPE,wayland"
"TERMINAL,uwsm app -- kitty"
]
++ optionals (elem "nvidia" nixosConfig.services.xserver.videoDrivers) [
# See https://wiki.hyprland.org/Nvidia/
@ -198,10 +199,6 @@ in
};
decoration.rounding = 4;
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"
];
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 = ${float_script}
env = XCURSOR_SIZE,48
exec-once = uwsm finalize
'';
};

View file

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

View file

@ -21,9 +21,9 @@ in
services = {
swww = {
Install.WantedBy = [ "graphical-session.target" ];
Unit.After = [ "graphical-session.target" ];
Unit = {
Description = "Wayland wallpaper daemon";
PartOf = [ "graphical-session.target" ];
};
Service = {
ExecStart = "${pkgs.swww}/bin/swww-daemon";
@ -31,7 +31,6 @@ in
};
};
swww-update-wallpaper = {
Install.WantedBy = [ "default.target" ];
Unit.Description = "Update the wallpaper";
Service = {
Type = "oneshot";
@ -42,7 +41,8 @@ in
};
};
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";
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 = {
enable = true;
systemd.enable = false;
systemd.enable = true;
style =
(
{

View file

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

View file

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