diff --git a/src/greetd.rs b/src/greetd.rs index 5aaa8e7..6b8fac0 100644 --- a/src/greetd.rs +++ b/src/greetd.rs @@ -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)?; } } diff --git a/src/session.rs b/src/session.rs index af8477e..2e25256 100644 --- a/src/session.rs +++ b/src/session.rs @@ -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))