Redesign targets for graphical

This commit is contained in:
Natsu Kagami 2025-01-16 18:10:23 +01:00
parent c00150dd95
commit 26df6113e7
Signed by: nki
GPG key ID: 55A032EB38B49ADB
8 changed files with 78 additions and 40 deletions

View file

@ -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;
@ -242,7 +233,6 @@ in
qt.style.package = [ pkgs.kdePackages.breeze ];
qt.style.name = "Breeze";
xdg.configFile =
let
f = pkg: {
@ -275,6 +265,26 @@ in
# dconf.settings."desktop/ibus/general/hotkey" = {
# triggers = hm.gvariant.mkArray hm.gvariant.type.string [ "<Super>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 = [ "graphical-session.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 = [ "graphical-session.target" ];
};
};
};
}

View file

@ -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;

View file

@ -10,7 +10,7 @@ let
wallpaper = config.linux.graphical.wallpaper;
xwayland-display = ":12";
xwayland-display = ":0";
in
{
@ -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,33 @@ 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.swaync.Install.WantedBy = [ "niri.service" ];
systemd.user.services.swaync.Unit.After = [ "niri.service" ];
systemd.user.targets.tray.Unit.After = [ "niri.service" ];
systemd.user.targets.xwayland.Unit.After = [ "niri.service" ];
# 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.UpheldBy = [ "niri.service" ];
Service.Slice = "session.slice";
Service.Type = "notify";
Service.ExecStart = "${lib.getExe pkgs.xwayland-satellite} ${xwayland-display}";
};
programs.niri.settings = {
environment = {
QT_QPA_PLATFORM = "wayland";
@ -106,16 +130,8 @@ 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" ]; }
];
layout = {
@ -141,7 +157,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;

View file

@ -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;

View file

@ -256,7 +256,7 @@ in
lib.mkIf cfg.enable {
enable = true;
systemd.enable = true;
systemd.target = "graphical-session.target";
systemd.target = "tray.target";
settings = cfg.makeBars barWith;
style = ''
* {

View file

@ -46,6 +46,10 @@
tap = "enabled";
};
};
programs.my-niri.enable = true;
programs.niri.settings = {
input.keyboard.xkb.options = "ctrl:swapcaps";
};
programs.my-waybar.extraSettings =
let
change-mode = pkgs.writeScript "change-mode" ''

View file

@ -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 {

View file

@ -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;
};