feat: set XDG_SESSION_TYPE=wayland just before graphical-session.target
This commit is contained in:
parent
be418fde28
commit
b724bddf49
2 changed files with 27 additions and 10 deletions
30
src/main.rs
30
src/main.rs
|
|
@ -56,9 +56,10 @@ async fn main() -> Result<()> {
|
||||||
let session_tx_clone = session_tx.clone();
|
let session_tx_clone = session_tx.clone();
|
||||||
let _conn = ConnectionBuilder::session()?
|
let _conn = ConnectionBuilder::session()?
|
||||||
.name("com.system76.CosmicSession")?
|
.name("com.system76.CosmicSession")?
|
||||||
.serve_at("/com/system76/CosmicSession", service::SessionService {
|
.serve_at(
|
||||||
session_tx,
|
"/com/system76/CosmicSession",
|
||||||
})?
|
service::SessionService { session_tx },
|
||||||
|
)?
|
||||||
.build()
|
.build()
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
|
|
@ -112,15 +113,9 @@ async fn start(
|
||||||
)
|
)
|
||||||
.wrap_err("failed to start compositor")?;
|
.wrap_err("failed to start compositor")?;
|
||||||
|
|
||||||
// TODO: do we still need to sleep here if we are waiting for cosmic-comp's environment variables?
|
|
||||||
sleep(Duration::from_millis(2000)).await;
|
sleep(Duration::from_millis(2000)).await;
|
||||||
|
|
||||||
process_manager
|
let mut env_vars = env_rx
|
||||||
.start(Process::new().with_executable("cosmic-settings-daemon"))
|
|
||||||
.await
|
|
||||||
.expect("failed to start settings daemon");
|
|
||||||
|
|
||||||
let env_vars = env_rx
|
|
||||||
.await
|
.await
|
||||||
.expect("failed to receive environmental variables")
|
.expect("failed to receive environmental variables")
|
||||||
.into_iter()
|
.into_iter()
|
||||||
|
|
@ -130,6 +125,21 @@ async fn start(
|
||||||
env_vars
|
env_vars
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// now that cosmic-comp is ready, set XDG_SESSION_TYPE=wayland for new processes
|
||||||
|
std::env::set_var("XDG_SESSION_TYPE", "wayland");
|
||||||
|
env_vars.push(("XDG_SESSION_TYPE".to_string(), "wayland".to_string()));
|
||||||
|
systemd::set_systemd_environment("XDG_SESSION_TYPE", "wayland").await;
|
||||||
|
|
||||||
|
process_manager
|
||||||
|
.start(Process::new().with_executable("cosmic-settings-daemon"))
|
||||||
|
.await
|
||||||
|
.expect("failed to start settings daemon");
|
||||||
|
|
||||||
|
// notifying the user service manager that we've reached the graphical-session.target,
|
||||||
|
// which should only happen after:
|
||||||
|
// - cosmic-comp is ready
|
||||||
|
// - we've set any related variables
|
||||||
|
// - cosmic-settings-daemon is ready
|
||||||
systemd::start_systemd_target().await;
|
systemd::start_systemd_target().await;
|
||||||
// Always stop the target when the process exits or panics.
|
// Always stop the target when the process exits or panics.
|
||||||
scopeguard::defer! {
|
scopeguard::defer! {
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,13 @@
|
||||||
|
|
||||||
use std::process::{Command, Stdio};
|
use std::process::{Command, Stdio};
|
||||||
|
|
||||||
|
pub async fn set_systemd_environment(key: &str, value: &str) {
|
||||||
|
run_optional_command(
|
||||||
|
"systemctl",
|
||||||
|
&["--user", "set-environment", &format!("{key}={value}")],
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
pub async fn start_systemd_target() {
|
pub async fn start_systemd_target() {
|
||||||
run_optional_command(
|
run_optional_command(
|
||||||
"systemctl",
|
"systemctl",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue