Add start-cosmic script; cosmic-session.target

This commit is contained in:
Lucy 2022-07-12 11:55:53 -04:00
parent 7be35d6153
commit bc07650f01
No known key found for this signature in database
GPG key ID: EBC517FAD666BBF1
6 changed files with 74 additions and 2 deletions

View file

@ -5,6 +5,7 @@ extern crate tracing;
mod comp;
mod generic;
mod process;
mod systemd;
use async_signals::Signals;
use color_eyre::{eyre::WrapErr, Result};
@ -37,6 +38,9 @@ async fn main() -> Result<()> {
if let Err(err) = comp::run_compositor(token.child_token(), socket_rx, env_tx) {
error!("compositor errored: {:?}", err);
}
systemd::start_systemd_target()
.await
.wrap_err("failed to start systemd target")?;
let env_vars = env_rx
.await
.expect("failed to receive environmental variables")

28
src/systemd.rs Normal file
View file

@ -0,0 +1,28 @@
// SPDX-License-Identifier: GPL-3.0-only
use color_eyre::{
eyre::{eyre, WrapErr},
Result,
};
use tokio::process::Command;
pub async fn start_systemd_target() -> Result<()> {
let output = Command::new("systemctl")
.arg("--user")
.arg("start")
.arg("cosmic-session.target")
.spawn()
.wrap_err("failed to start systemd target")?
.wait()
.await
.wrap_err("failed to wait for systemd target to start")?;
if output.success() {
Ok(())
} else {
Err(eyre!(
"failed to start systemd target: code {}",
output.code().unwrap_or(-1),
))
}
}