From 433799271274c9f2ab520a49527ebfe2992dcfbd Mon Sep 17 00:00:00 2001 From: Coutinho de Souza Date: Thu, 6 Feb 2025 21:50:03 +0000 Subject: [PATCH] wayland: create tray.target if xsession is not enabled (#6332) Create a internal/read-only trayTarget option for the xsession, which is also used in wayland's config, if the former is not enabled. Remove all other definitions of `systemd.user.targets.tray`, i. e, the ones from the following modules: hyprland, sway, river and wayfire. --- modules/services/window-managers/hyprland.nix | 7 ------- .../services/window-managers/i3-sway/sway.nix | 7 ------- modules/services/window-managers/river.nix | 7 ------- modules/services/window-managers/wayfire.nix | 7 ------- modules/wayland.nix | 6 +++++- modules/xsession.nix | 21 +++++++++++++------ 6 files changed, 20 insertions(+), 35 deletions(-) diff --git a/modules/services/window-managers/hyprland.nix b/modules/services/window-managers/hyprland.nix index ec73f99f6..35e47a152 100644 --- a/modules/services/window-managers/hyprland.nix +++ b/modules/services/window-managers/hyprland.nix @@ -312,12 +312,5 @@ in { [ "xdg-desktop-autostart.target" ]; }; }; - - systemd.user.targets.tray = { - Unit = { - Description = "Home Manager System Tray"; - Requires = [ "graphical-session-pre.target" ]; - }; - }; }; } diff --git a/modules/services/window-managers/i3-sway/sway.nix b/modules/services/window-managers/i3-sway/sway.nix index 4148fcf1d..36d27328e 100644 --- a/modules/services/window-managers/i3-sway/sway.nix +++ b/modules/services/window-managers/i3-sway/sway.nix @@ -553,13 +553,6 @@ in { optional cfg.systemd.xdgAutostart "xdg-desktop-autostart.target"; }; }; - - systemd.user.targets.tray = { - Unit = { - Description = "Home Manager System Tray"; - Requires = [ "graphical-session-pre.target" ]; - }; - }; } ]); } diff --git a/modules/services/window-managers/river.nix b/modules/services/window-managers/river.nix index 06d458411..cc10a4344 100644 --- a/modules/services/window-managers/river.nix +++ b/modules/services/window-managers/river.nix @@ -201,12 +201,5 @@ in { After = [ "graphical-session-pre.target" ]; }; }; - - systemd.user.targets.tray = { - Unit = { - Description = "Home Manager System Tray"; - Requires = [ "graphical-session-pre.target" ]; - }; - }; }; } diff --git a/modules/services/window-managers/wayfire.nix b/modules/services/window-managers/wayfire.nix index c551eb05f..e52201c79 100644 --- a/modules/services/window-managers/wayfire.nix +++ b/modules/services/window-managers/wayfire.nix @@ -189,12 +189,5 @@ After = [ "graphical-session-pre.target" ]; }; }; - - systemd.user.targets.tray = { - Unit = { - Description = "Home Manager System Tray"; - Requires = [ "graphical-session-pre.target" ]; - }; - }; }; } diff --git a/modules/wayland.nix b/modules/wayland.nix index 9a485c56c..6bf36162a 100644 --- a/modules/wayland.nix +++ b/modules/wayland.nix @@ -1,4 +1,4 @@ -{ lib, ... }: +{ config, lib, ... }: { meta.maintainers = [ lib.maintainers.thiagokokada ]; @@ -21,4 +21,8 @@ }; }; }; + + config = lib.mkIf (!config.xsession.enable) { + systemd.user.targets.tray = config.xsession.trayTarget; + }; } diff --git a/modules/xsession.nix b/modules/xsession.nix index 269ce1fa0..edb99300e 100644 --- a/modules/xsession.nix +++ b/modules/xsession.nix @@ -13,6 +13,20 @@ in { xsession = { enable = mkEnableOption "X Session"; + trayTarget = mkOption { + readOnly = true; + internal = true; + visible = false; + description = "Common tray.target for both xsession and wayland"; + type = types.attrs; + default = { + Unit = { + Description = "Home Manager System Tray"; + Requires = [ "graphical-session-pre.target" ]; + }; + }; + }; + scriptPath = mkOption { type = types.str; default = ".xsession"; @@ -163,12 +177,7 @@ in { }; }; - tray = { - Unit = { - Description = "Home Manager System Tray"; - Requires = [ "graphical-session-pre.target" ]; - }; - }; + tray = cfg.trayTarget; }; };