Added session XDG env variables

This commit is contained in:
Jan-Bulthuis 2025-02-22 03:27:35 +01:00
parent ae34531d36
commit c11fc482ef
3 changed files with 11 additions and 8 deletions

View File

@ -53,6 +53,7 @@ pub fn gather_sessions(user: &User) -> Vec<Session> {
false => vec![Session {
name: String::from("Shell"),
generation: user.shell.to_str().unwrap().to_owned(),
env: vec![],
}],
}
}
@ -92,15 +93,15 @@ fn gather_specialisations(path: &PathBuf) -> Vec<Session> {
fn gather_session_data(path: &PathBuf, reset_path: &PathBuf) -> Session {
let session_path = path.join("session");
let env_file = read_to_string(session_path.join("env")).unwrap();
let name = read_to_string(session_path.join("name")).unwrap();
// let init = format!(
// "sh -c \"{} && {} && {}\"",
// path.join("activate").display(),
// session_path.join("init").display(),
// reset_path.join("activate").display()
// );
let generation = path.to_str().unwrap().to_owned();
let env = env_file.lines().map(String::from).collect();
Session { name, generation }
Session {
name,
generation,
env,
}
}

View File

@ -31,10 +31,11 @@ pub fn login(
} else {
starting = true;
let cmd = vec![String::from("nixgreety session")];
let env = vec![format!(
let mut env = vec![format!(
"NIXGREETY_GENERATION={}",
session.generation.clone()
)];
env.append(&mut session.env.clone());
Request::StartSession { cmd, env }.write_to(&mut stream)?;
}
}

View File

@ -128,6 +128,7 @@ impl Display for User {
struct Session {
name: String,
generation: String,
env: Vec<String>,
}
impl Display for Session {