Add command-line options (#342)

* feat: forward requested command-line options

The CLI now forwards the `-ac`, `-audit`, `-auth`, `-core`,
`+extension`, `-extension`, `-glamor`, `-listen`, `-nolisten`, and `-verbose` flags
to `Xwayland`. In addition, command-line flags no longer require the
display to be the first parameter. Also the `-help` and `-version` flags
were added, which print the relevant message and return 0.

The match case structure should make it easier to add new arguments if
people have use for them. For example, I chose not to add the `-ld`,
`-lm`, and `-ls` flags since they are dependent on `Xwayland`'s
compile-time flags.
This commit is contained in:
En-En 2026-01-24 18:26:00 +00:00 committed by GitHub
parent 7af39ce419
commit 62bafcc3c9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 332 additions and 33 deletions

View file

@ -36,6 +36,9 @@ type RealServerState = ServerState<RealConnection>;
pub trait RunData {
fn display(&self) -> Option<&str>;
fn listenfds(&mut self) -> Vec<OwnedFd>;
fn flags(&self) -> &[String] {
&[]
}
fn server(&self) -> Option<UnixStream> {
None
}
@ -58,12 +61,16 @@ pub const fn timespec_from_millis(millis: u64) -> Timespec {
}
}
pub fn main(mut data: impl RunData) -> Option<()> {
pub fn version() -> &'static str {
let mut version = env!("VERGEN_GIT_DESCRIBE");
if version == "VERGEN_IDEMPOTENT_OUTPUT" {
version = env!("CARGO_PKG_VERSION");
}
info!("Starting xwayland-satellite version {version}");
version
}
pub fn main(mut data: impl RunData) -> Option<()> {
info!("Starting xwayland-satellite version {}", version());
let socket = ListeningSocket::bind_auto("xwls", 1..=128).unwrap();
let mut display = Display::new().unwrap();
@ -95,6 +102,7 @@ pub fn main(mut data: impl RunData) -> Option<()> {
"-displayfd",
&ready_tx.as_raw_fd().to_string(),
])
.args(data.flags())
.env("WAYLAND_DISPLAY", socket.socket_name().unwrap())
.stderr(Stdio::piped())
.spawn()