Added support for simple sessions

This commit is contained in:
Jan-Bulthuis 2025-02-22 06:36:08 +01:00
parent 9a22c117b5
commit 4b5f812e95
2 changed files with 17 additions and 3 deletions

View File

@ -53,7 +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![],
env: vec![String::from("NIXGREETY_SIMPLE=1")],
}],
}
}

View File

@ -9,6 +9,15 @@ use std::{
use crate::fs::resolve_link;
pub fn handle_session() -> io::Result<()> {
match env::var("NIXGREETY_SIMPLE") {
Ok(_) => handle_simple_session(),
Err(_) => handle_hm_session(),
}
Ok(())
}
fn handle_hm_session() {
println!(">>> Activating environment <<<");
let generation = env::var("NIXGREETY_GENERATION").unwrap();
Command::new(format!("{}/activate", generation))
@ -48,6 +57,11 @@ pub fn handle_session() -> io::Result<()> {
Command::new(format!("{}/activate", generation.display()))
.status()
.unwrap();
Ok(())
}
fn handle_simple_session() {
let generation = env::var("NIXGREETY_GENERATION").unwrap();
Command::new(&generation)
.status()
.expect("Failed to create session");
}