1
0
Fork 0
forked from wry/wry

config: allow spawning clients with tags

This commit is contained in:
Julian Orth 2026-02-27 21:00:20 +01:00
parent 8b19315f50
commit a1df575262
11 changed files with 80 additions and 7 deletions

View file

@ -348,7 +348,15 @@ impl ConfigClient {
.drain()
.map(|(a, b)| (a, b.into_raw_fd()))
.collect();
if fds.is_empty() {
if command.tag.is_some() {
self.send(&ClientMessage::Run3 {
prog: &command.prog,
args: command.args.clone(),
env,
fds,
tag: command.tag.as_deref(),
});
} else if fds.is_empty() {
self.send(&ClientMessage::Run {
prog: &command.prog,
args: command.args.clone(),

View file

@ -834,6 +834,13 @@ pub enum ClientMessage<'a> {
SetXWaylandEnabled {
enabled: bool,
},
Run3 {
prog: &'a str,
args: Vec<String>,
env: Vec<(String, String)>,
fds: Vec<(i32, i32)>,
tag: Option<&'a str>,
},
}
#[derive(Serialize, Deserialize, Debug)]

View file

@ -22,6 +22,7 @@ pub struct Command {
pub(crate) args: Vec<String>,
pub(crate) env: HashMap<String, String>,
pub(crate) fds: RefCell<HashMap<i32, OwnedFd>>,
pub(crate) tag: Option<String>,
}
impl Command {
@ -37,6 +38,7 @@ impl Command {
args: vec![],
env: Default::default(),
fds: Default::default(),
tag: Default::default(),
}
}
@ -97,6 +99,12 @@ impl Command {
self
}
/// Adds a tag to Wayland connections created by the spawned command.
pub fn tag(&mut self, tag: &str) -> &mut Self {
self.tag = Some(tag.to_owned());
self
}
/// Executes the command.
///
/// This consumes all attached file descriptors.