Skip to content

Conversation

@cmeissl
Copy link
Contributor

@cmeissl cmeissl commented Nov 10, 2024

Currently niri creates a separate scope per spawn action matching the name of the executable.
So for example launching the non flatpak version of firefox through fuzzel will result in this firefox instance
to run under a scope name app-niri-fuzzel-<PID>.scope.
This can be problematic in combination with xdg-portal, which will use the scope name as a fallback for the
non accessible app id.

To solve this, this PR tries to mimic what systemd-sway does, moving toplevels to systemd scopes matching their app id.
In addition to moving the process it also add slices like systemd-sway offers. This allows to override resource
limits per app id slice.

The code is more a PoC and needs a major cleanup. The worst part is finding out all child pids that should also be moved to the new scope.

Cargo.toml Outdated
wayland-scanner = "0.31.5"
xcursor = "0.3.8"
zbus = { version = "~3.15.2", optional = true }
zvariant = { version = "~3.15.2", optional = true }
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's exported under zbus::zvariant::

}
}

let _ = write!(slice_name, ".slice");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why a slice and not a scope btw? All apps are in app.slice, and I only have the few pre-created slices on my system.

└─ systemctl --user | grep .slice
  -.slice
  app.slice
  background.slice
  session.slice
  user.slice

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be both, the scope is named like app-niri-<app_id>-{pid}.scope and the slice is named app-niri-<app_id>.slice. This allows to override limits per app_id

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants