Send a socket as COSMIC_SESSION_SOCK to the compositor

This commit is contained in:
Lucy 2022-06-27 13:54:24 -04:00
parent be2b800716
commit a732dafc36
No known key found for this signature in database
GPG key ID: EBC517FAD666BBF1

View file

@ -1,12 +1,22 @@
use std::os::unix::prelude::IntoRawFd;
// SPDX-License-Identifier: GPL-3.0-only
use crate::process::{ProcessEvent, ProcessHandler};
use tokio::sync::{mpsc::unbounded_channel, oneshot};
use tokio::{
net::UnixStream,
sync::{mpsc::unbounded_channel, oneshot},
};
use tokio_util::sync::CancellationToken;
pub async fn run_compositor(token: CancellationToken, wayland_display_tx: oneshot::Sender<String>) {
let mut wayland_display_tx = Some(wayland_display_tx);
let (tx, mut rx) = unbounded_channel::<ProcessEvent>();
ProcessHandler::new(tx, &token).run("cosmic-comp", vec![], vec![]);
let (session, comp) = UnixStream::pair().expect("failed to create pair of unix sockets");
let comp = comp.into_std().unwrap().into_raw_fd();
ProcessHandler::new(tx, &token).run("cosmic-comp", vec![], vec![(
"COSMIC_SESSION_SOCK".into(),
comp.to_string(),
)]);
while let Some(event) = rx.recv().await {
match event {
ProcessEvent::Started => {