{
  lib,
  config,
  pkgs,
  ...
}: let
  cfg = config.marleyos.programs.xwayland-satellite;
in {
  options.marleyos.programs.xwayland-satellite.enable = lib.mkEnableOption "xwayland-satellite";

  config = lib.mkIf cfg.enable {
    home.packages = with pkgs; [
      xwayland-satellite
    ];

    systemd.user.services."xwayland-satellite" = {
      Unit = {
        Description = "Xwayland outside your Wayland";
        BindsTo = ["xdg-desktop-autostart.target"];
        PartOf = ["xdg-desktop-autostart.target"];
        After = ["xdg-desktop-autostart.target"];
        Requisite = ["xdg-desktop-autostart.target"];
      };

      Service = {
        Type = "notify";
        NotifyAccess = "all";
        ExecStart = lib.getExe pkgs.xwayland-satellite;
        StandardOutput = "journal";
      };

      Install = {
        WantedBy = ["xdg-desktop-autostart.target"];
      };
    };

    home.sessionVariables.DISPLAY = ":0";
  };
}
