diff --git a/home/modules/linux/graphical/default.nix b/home/modules/linux/graphical/default.nix index b6fc562..fd81d0e 100644 --- a/home/modules/linux/graphical/default.nix +++ b/home/modules/linux/graphical/default.nix @@ -117,15 +117,6 @@ in ]; }; - # Yellow light! - services.wlsunset = { - enable = true; - - # Lausanne - latitude = "46.31"; - longitude = "6.38"; - }; - # Cursor home.pointerCursor = { package = pkgs.suwako-cursors; @@ -236,7 +227,6 @@ in qt.style.package = [ pkgs.kdePackages.breeze ]; qt.style.name = "Breeze"; - xdg.configFile = let f = pkg: { @@ -269,6 +259,26 @@ in # dconf.settings."desktop/ibus/general/hotkey" = { # triggers = hm.gvariant.mkArray hm.gvariant.type.string [ "z" ]; # }; + + # Some graphical targets + systemd.user.targets = { + # For system trays, usually after graphical-session and graphical-session-pre + tray = { + Unit.Description = lib.mkDefault "System tray"; + Unit.After = [ "graphical-session-pre.target" ]; + Unit.Before = [ "graphical-session.target" ]; + Unit.BindsTo = [ "graphical-session.target" ]; + Install.WantedBy = [ "plasma-workspace.target" ]; + }; + # XWayland target + xwayland = { + Unit.Description = "XWayland support"; + Unit.After = [ "graphical-session-pre.target" ]; + Unit.Before = [ "graphical-session.target" ]; + Unit.BindsTo = [ "graphical-session.target" ]; + Install.WantedBy = [ "plasma-workspace.target" ]; + }; + }; }; } diff --git a/home/modules/linux/graphical/wayland.nix b/home/modules/linux/graphical/wayland.nix index a0a0b27..6aa2b9f 100644 --- a/home/modules/linux/graphical/wayland.nix +++ b/home/modules/linux/graphical/wayland.nix @@ -100,6 +100,16 @@ with lib; ANKI_WAYLAND = "1"; }; + # Yellow light! + services.wlsunset = { + enable = true; + + # Lausanne + latitude = "46.31"; + longitude = "6.38"; + }; + + # Notification system # services.dunst = { # enable = true; diff --git a/home/modules/programs/my-niri.nix b/home/modules/programs/my-niri.nix index a06df33..f198d65 100644 --- a/home/modules/programs/my-niri.nix +++ b/home/modules/programs/my-niri.nix @@ -41,6 +41,11 @@ in default = true; description = "whether workspace always exists"; }; + monitor = lib.mkOption { + type = lib.types.nullOr lib.types.str; + default = null; + description = "Default monitor to spawn workspace in"; + }; }; }); description = "A mapping of ordering to workspace names, for fixed workspaces"; @@ -54,14 +59,44 @@ in "02" = { name = "💬 chat"; }; "03" = { name = "⚙️ code"; }; "04" = { name = "🎶 music"; }; - "05" = { name = "🔧 extra"; fixed = false; }; - "06" = { name = "🧰 6"; fixed = false; }; - "07" = { name = "🔩 7"; fixed = false; }; - "08" = { name = "🛠️ 8"; fixed = false; }; - "09" = { name = "🔨 9"; fixed = false; }; - "10" = { name = "🎲 misc"; fixed = false; }; - "99" = { name = "📧 Email"; fixed = false; }; + "05" = { name = "🔧 extra"; }; + "06" = { name = "🧰 6"; }; + "07" = { name = "🔩 7"; }; + "08" = { name = "🛠️ 8"; }; + "09" = { name = "🔨 9"; }; + "10" = { name = "🎲 misc"; }; + "99" = { name = "📧 Email"; }; }; + # systemd.user.services.niri = lib.mkIf cfg.enable { + # Unit.Wants = [ "tray.target" "xwayland.target" ]; + # }; + systemd.user.services.niri = lib.mkIf cfg.enable { + Unit = { + Description = "A scrollable-tiling Wayland compositor"; + BindsTo = [ "graphical-session.target" ]; + Before = [ "graphical-session.target" "tray.target" "swaync.service" "xdg-desktop-autostart.target" ]; + Wants = [ "graphical-session-pre.target" "swaync.service" "xdg-desktop-autostart.target" ]; + After = [ "graphical-session-pre.target" ]; + }; + + Service.Slice = "session.slice"; + Service.Type = "notify"; + Service.ExecStart = "${lib.getExe config.programs.niri.package} --session"; + }; + + # xwayland-satellite + systemd.user.services.niri-xwayland-satellite = lib.mkIf cfg.enable { + Unit = { + Description = "XWayland Client for niri"; + PartOf = [ "xwayland.target" ]; + Before = [ "xwayland.target" "xdg-desktop-autostart.target" ]; + After = [ "niri.service" ]; + }; + Install.RequiredBy = [ "niri.service" ]; + Service.Slice = "session.slice"; + Service.ExecStart = "${lib.getExe pkgs.xwayland-satellite} ${xwayland-display}"; + }; + programs.niri.settings = { environment = { QT_QPA_PLATFORM = "wayland"; @@ -106,16 +141,10 @@ in spawn-at-startup = [ # Wallpaper { command = [ (lib.getExe pkgs.swaybg) "-i" "${wallpaper}" "-m" "fill" ]; } - # IME - { command = [ "fcitx5" ]; } - # XWayland - { command = [ (lib.getExe pkgs.xwayland-satellite) xwayland-display ]; } # Waybar - { command = [ "systemctl" "--user" "start" "swaync.service" ]; } { command = [ "systemctl" "--user" "start" "xdg-desktop-portal-gtk.service" "xdg-desktop-portal.service" ]; } - { command = [ "systemctl" "--user" "reset-failed" "waybar.service" "wlsunset.service" ]; } - # Startup - { command = [ (lib.getExe pkgs.dex) "-ae" "niri" ]; } + # Export XWayland DISPLAY + { command = [ "sh" "-c" "systemctl --user set-environment DISPLAY=${xwayland-display} && systemctl --user start xwayland.target" ]; } ]; layout = { @@ -141,7 +170,11 @@ in workspaces = let fixedWorkspaces = lib.filterAttrs (_: w: w.fixed) cfg.workspaces; - workspaceConfig = lib.mapAttrs (_: w: { inherit (w) name; }) fixedWorkspaces; + workspaceConfig = lib.mapAttrs + (_: w: { inherit (w) name; } // (lib.optionalAttrs (w.monitor != null) { + open-on-output = w.monitor; + })) + fixedWorkspaces; in workspaceConfig; diff --git a/home/modules/programs/my-sway/default.nix b/home/modules/programs/my-sway/default.nix index 093f6e5..8117d87 100644 --- a/home/modules/programs/my-sway/default.nix +++ b/home/modules/programs/my-sway/default.nix @@ -91,6 +91,10 @@ in }; }; + config.systemd.user.targets.sway-session = mkIf cfg.enable { + Unit.Before = [ "tray.target" "xwayland.target" ]; + }; + # Enable waybar config.programs.my-waybar = mkIf cfg.enable { enable = true; diff --git a/home/modules/programs/my-waybar.nix b/home/modules/programs/my-waybar.nix index 0f9bcd7..de030c9 100644 --- a/home/modules/programs/my-waybar.nix +++ b/home/modules/programs/my-waybar.nix @@ -42,6 +42,10 @@ in default = ""; }; }; + config.systemd.user.services.waybar = lib.mkIf cfg.enable { + Unit.BindsTo = [ "tray.target" ]; + Unit.After = [ "tray.target" ]; + }; config.programs.waybar = let barWith = { showMedia ? true, showConnectivity ? true, extraSettings ? { }, ... }: lib.mkMerge ([{ diff --git a/home/nki-x1c1.nix b/home/nki-x1c1.nix index e9ee09a..0824a89 100644 --- a/home/nki-x1c1.nix +++ b/home/nki-x1c1.nix @@ -68,6 +68,8 @@ in ]; }; programs.my-niri.enable = true; + # Assign some of the workspaces to big screen + programs.my-niri.workspaces = lib.genAttrs [ "06" "07" "08" "09" "10" ] (_: { monitor = config.common.monitors.work.name; }); programs.niri.settings = { # input.keyboard.xkb.options = "ctrl:swapcaps"; input.mouse = lib.mkForce { diff --git a/modules/common/linux/default.nix b/modules/common/linux/default.nix index 0ccc742..36bef19 100644 --- a/modules/common/linux/default.nix +++ b/modules/common/linux/default.nix @@ -56,18 +56,6 @@ let # https://github.com/sodiboo/niri-flake/blob/main/docs.md programs.niri.enable = true; programs.niri.package = pkgs.niri-stable; - systemd.user.services.niri = { - description = "A scrollable-tiling Wayland compositor"; - bindsTo = [ "graphical-session.target" ]; - before = [ "graphical-session.target" ]; - wants = [ "graphical-session-pre.target" ]; - after = [ "graphical-session-pre.target" ]; - - serviceConfig.Slice = "session.slice"; - serviceConfig.Type = "notify"; - serviceConfig.ExecStart = "${lib.getExe config.programs.niri.package} --session"; - path = mkForce [ ]; - }; # Override gnome-keyring disabling services.gnome.gnome-keyring.enable = lib.mkForce false; };