Generation is now activated before handing back control to greetd

This commit is contained in:
Jan-Bulthuis 2025-02-25 19:12:34 +01:00
parent 4b5f812e95
commit 9d97505e02
2 changed files with 14 additions and 4 deletions

View File

@ -1,4 +1,4 @@
use std::{env, error::Error, os::unix::net::UnixStream};
use std::{env, error::Error, os::unix::net::UnixStream, process::Command};
use greetd_ipc::{codec::SyncCodec, AuthMessageType, ErrorType, Request, Response};
@ -36,6 +36,15 @@ pub fn login(
session.generation.clone()
)];
env.append(&mut session.env.clone());
// Activate the generation before handing control back to greetd
Command::new(format!(
"su -c \"{}/activate\" {}",
session.generation, user.name
))
.status()
.expect("Failed to activate environment");
Request::StartSession { cmd, env }.write_to(&mut stream)?;
}
}

View File

@ -20,9 +20,10 @@ pub fn handle_session() -> io::Result<()> {
fn handle_hm_session() {
println!(">>> Activating environment <<<");
let generation = env::var("NIXGREETY_GENERATION").unwrap();
Command::new(format!("{}/activate", generation))
.status()
.expect("Failed to activate environment");
// Activating the generation is now handled before handing control back to greetd
// Command::new(format!("{}/activate", generation))
// .status()
// .expect("Failed to activate environment");
println!(">>> Creating session <<<");
Command::new(format!("{}/session/init", generation))