🚨 Everything now seems to compile!
This commit is contained in:
parent
a4a791ed33
commit
f75e970847
3 changed files with 71 additions and 41 deletions
18
Cargo.lock
generated
18
Cargo.lock
generated
|
|
@ -453,7 +453,7 @@ checksum = "6c8af84674fe1f223a982c933a0ee1086ac4d4052aa0fb8060c12c6ad838e754"
|
|||
[[package]]
|
||||
name = "launch-pad"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/pop-os/launch-pad#2815570c919c6ff7b7d06c2ae6dd57c9acdbb927"
|
||||
source = "git+https://github.com/pop-os/launch-pad#2f81ce4ab3d52f52dbe7df20dc418fbec1a92d1a"
|
||||
dependencies = [
|
||||
"log",
|
||||
"slotmap",
|
||||
|
|
@ -476,9 +476,9 @@ checksum = "c0f80d65747a3e43d1596c7c5492d95d5edddaabd45a7fcdb02b95f644164966"
|
|||
|
||||
[[package]]
|
||||
name = "lock_api"
|
||||
version = "0.4.8"
|
||||
version = "0.4.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9f80bf5aacaf25cbfc8210d1cfb718f2bf3b11c4c54e5afe36c236853a8ec390"
|
||||
checksum = "435011366fe56583b16cf956f9df0095b405b82d76425bc8981c0e22e60ec4df"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"scopeguard",
|
||||
|
|
@ -584,9 +584,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "once_cell"
|
||||
version = "1.14.0"
|
||||
version = "1.15.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2f7254b99e31cad77da24b08ebf628882739a608578bb1bcdfc1f9c21260d7c0"
|
||||
checksum = "e82dad04139b71a90c080c8463fe0dc7902db5192d939bd0950f074d014339e1"
|
||||
|
||||
[[package]]
|
||||
name = "ordered-stream"
|
||||
|
|
@ -809,18 +809,18 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.144"
|
||||
version = "1.0.145"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0f747710de3dcd43b88c9168773254e809d8ddbdf9653b84e2554ab219f17860"
|
||||
checksum = "728eb6351430bccb993660dfffc5a72f91ccc1295abaa8ce19b27ebe4f75568b"
|
||||
dependencies = [
|
||||
"serde_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_derive"
|
||||
version = "1.0.144"
|
||||
version = "1.0.145"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "94ed3a816fb1d101812f83e789f888322c34e291f894f19590dc310963e87a00"
|
||||
checksum = "81fa1584d3d1bcacd84c277a0dfe21f5b0f6accf4a23d04d4c6d61f1af522b4c"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
|
|
|
|||
43
src/comp.rs
43
src/comp.rs
|
|
@ -1,5 +1,6 @@
|
|||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
use color_eyre::eyre::{Result, WrapErr};
|
||||
use launch_pad::{process::Process, ProcessManager};
|
||||
use sendfd::SendWithFd;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::{collections::HashMap, os::unix::prelude::*};
|
||||
|
|
@ -9,10 +10,7 @@ use tokio::{
|
|||
unix::{OwnedReadHalf, OwnedWriteHalf},
|
||||
UnixStream,
|
||||
},
|
||||
sync::{
|
||||
mpsc::{self, unbounded_channel},
|
||||
oneshot,
|
||||
},
|
||||
sync::{mpsc, oneshot},
|
||||
task::JoinHandle,
|
||||
};
|
||||
use tokio_util::sync::CancellationToken;
|
||||
|
|
@ -170,10 +168,12 @@ async fn send_fd(session_tx: &mut OwnedWriteHalf, stream: Vec<UnixStream>) -> Re
|
|||
}
|
||||
|
||||
pub fn run_compositor(
|
||||
process_manager: &ProcessManager,
|
||||
token: CancellationToken,
|
||||
mut socket_rx: mpsc::UnboundedReceiver<Vec<UnixStream>>,
|
||||
env_tx: oneshot::Sender<HashMap<String, String>>,
|
||||
) -> Result<JoinHandle<Result<()>>> {
|
||||
let process_manager = process_manager.clone();
|
||||
// Create a pair of unix sockets - one for us (session),
|
||||
// one for the compositor (comp)
|
||||
let (session, comp) = UnixStream::pair().wrap_err("failed to create pair of unix sockets")?;
|
||||
|
|
@ -195,13 +195,30 @@ pub fn run_compositor(
|
|||
async move {
|
||||
// Create a new process handler for cosmic-comp, with our compositor socket's
|
||||
// file descriptor as the `COSMIC_SESSION_SOCK` environment variable.
|
||||
ProcessHandler::new(tx, &token).run(
|
||||
"cosmic-comp",
|
||||
vec![],
|
||||
vec![("COSMIC_SESSION_SOCK".into(), comp.as_raw_fd().to_string())],
|
||||
vec![comp],
|
||||
&span,
|
||||
);
|
||||
let stdout_span = span.clone();
|
||||
let stderr_span = span.clone();
|
||||
process_manager
|
||||
.start_process(
|
||||
Process::new()
|
||||
.with_executable("cosmic-comp")
|
||||
.with_env([("COSMIC_SESSION_SOCK", comp.as_raw_fd().to_string())])
|
||||
.with_on_stdout(move |_, _, line| {
|
||||
let stdout_span = stdout_span.clone();
|
||||
async move {
|
||||
info!("{}", line);
|
||||
}
|
||||
.instrument(stdout_span)
|
||||
})
|
||||
.with_on_stderr(move |_, _, line| {
|
||||
let stderr_span = stderr_span.clone();
|
||||
async move {
|
||||
warn!("{}", line);
|
||||
}
|
||||
.instrument(stderr_span)
|
||||
}),
|
||||
)
|
||||
.await
|
||||
.expect("failed to launch compositor");
|
||||
// Create a new state object for IPC purposes.
|
||||
let mut ipc_state = IpcState {
|
||||
env_tx: Some(env_tx),
|
||||
|
|
@ -209,11 +226,11 @@ pub fn run_compositor(
|
|||
};
|
||||
loop {
|
||||
tokio::select! {
|
||||
// Receive events from the process handler channel,
|
||||
// exiting the loop if the process has exited.
|
||||
/*
|
||||
exit = receive_event(&mut rx) => if exit.is_none() {
|
||||
break;
|
||||
},
|
||||
*/
|
||||
// Receive IPC messages from the process,
|
||||
// exiting the loop if IPC errors.
|
||||
result = receive_ipc(&mut ipc_state, &mut session_rx) => if let Err(err) = result {
|
||||
|
|
|
|||
51
src/main.rs
51
src/main.rs
|
|
@ -34,11 +34,13 @@ async fn main() -> Result<()> {
|
|||
|
||||
info!("Starting cosmic-session");
|
||||
|
||||
let process_manager = ProcessManager::new().await;
|
||||
let token = CancellationToken::new();
|
||||
let (socket_tx, socket_rx) = mpsc::unbounded_channel();
|
||||
let (env_tx, env_rx) = oneshot::channel();
|
||||
let compositor_handle = comp::run_compositor(token.child_token(), socket_rx, env_tx)
|
||||
.wrap_err("failed to start compositor")?;
|
||||
let compositor_handle =
|
||||
comp::run_compositor(&process_manager, token.child_token(), socket_rx, env_tx)
|
||||
.wrap_err("failed to start compositor")?;
|
||||
systemd::start_systemd_target()
|
||||
.await
|
||||
.wrap_err("failed to start systemd target")?;
|
||||
|
|
@ -55,32 +57,43 @@ async fn main() -> Result<()> {
|
|||
.collect::<Vec<_>>();
|
||||
info!("got environmental variables: {:?}", env_vars);
|
||||
|
||||
let process_manager = ProcessManager::new().await;
|
||||
let mut sockets = Vec::with_capacity(2);
|
||||
|
||||
let (env, fd) = comp::create_privileged_socket(&mut sockets, &env_vars)
|
||||
.wrap_err("failed to create panel socket")?;
|
||||
process_manager.start(Process::new().with_executable("cosmic-panel").with_env(env));
|
||||
process_manager
|
||||
.start(Process::new().with_executable("cosmic-panel").with_env(env))
|
||||
.await
|
||||
.expect("failed to start panel");
|
||||
let (env, fd) = comp::create_privileged_socket(&mut sockets, &env_vars)
|
||||
.wrap_err("failed to create applet host")?;
|
||||
process_manager.start(
|
||||
Process::new()
|
||||
.with_executable("cosmic-applet-host")
|
||||
.with_env(env),
|
||||
);
|
||||
process_manager
|
||||
.start(
|
||||
Process::new()
|
||||
.with_executable("cosmic-applet-host")
|
||||
.with_env(env),
|
||||
)
|
||||
.await
|
||||
.expect("failed to start applet host");
|
||||
let (env, fd) = comp::create_privileged_socket(&mut sockets, &env_vars)
|
||||
.wrap_err("failed to create applet host")?;
|
||||
process_manager.start(
|
||||
Process::new()
|
||||
.with_executable("swaybg")
|
||||
.with_args(&[
|
||||
"-i",
|
||||
"/usr/share/backgrounds/pop/kate-hazen-COSMIC-desktop-wallpaper.png",
|
||||
])
|
||||
.with_env(env),
|
||||
);
|
||||
process_manager
|
||||
.start(
|
||||
Process::new()
|
||||
.with_executable("swaybg")
|
||||
.with_args(&[
|
||||
"-i",
|
||||
"/usr/share/backgrounds/pop/kate-hazen-COSMIC-desktop-wallpaper.png",
|
||||
])
|
||||
.with_env(env),
|
||||
)
|
||||
.await
|
||||
.expect("failed to start swaybg");
|
||||
socket_tx.send(sockets).unwrap();
|
||||
process_manager.start(Process::new().with_executable("cosmic-settings-daemon"));
|
||||
process_manager
|
||||
.start(Process::new().with_executable("cosmic-settings-daemon"))
|
||||
.await
|
||||
.expect("failed to start settings daemon");
|
||||
|
||||
let (exit_tx, exit_rx) = oneshot::channel();
|
||||
let _ = ConnectionBuilder::session()?
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue