✨ Add start-cosmic script; cosmic-session.target
This commit is contained in:
parent
7be35d6153
commit
bc07650f01
6 changed files with 74 additions and 2 deletions
|
|
@ -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
28
src/systemd.rs
Normal 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),
|
||||
))
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue