Fixed bug where selecting a session from the menu would not execute the right command.

This commit is contained in:
Antoine POPINEAU 2023-11-08 08:22:52 +01:00
parent fe587635f5
commit 6426cd597b
No known key found for this signature in database
GPG Key ID: E8379674E92D25D2
3 changed files with 7 additions and 7 deletions

View File

@ -157,6 +157,10 @@ pub fn delete_last_user_session_path(username: &str) {
let _ = fs::remove_file(format!("{LAST_SESSION_PATH}-{username}"));
}
pub fn delete_last_user_session(username: &str) {
let _ = fs::remove_file(&format!("{LAST_SESSION}-{username}"));
}
pub fn get_users(min_uid: u16, max_uid: u16) -> Vec<User> {
match File::open("/etc/passwd") {
Err(_) => vec![],

View File

@ -7,7 +7,7 @@ use tokio::sync::{
};
use crate::{
info::{delete_last_user_session_path, write_last_user_session, write_last_user_session_path, write_last_username},
info::{delete_last_user_session, delete_last_user_session_path, write_last_user_session, write_last_user_session_path, write_last_username},
ui::sessions::{Session, SessionSource, SessionType},
AuthStatus, Greeter, Mode,
};
@ -116,6 +116,7 @@ impl Ipc {
SessionSource::Session(index) => {
if let Some(Session { path: Some(session_path), .. }) = greeter.sessions.options.get(index) {
write_last_user_session_path(&greeter.username, session_path);
delete_last_user_session(&greeter.username);
}
}

View File

@ -37,12 +37,7 @@ impl SessionSource {
match self {
SessionSource::None => None,
SessionSource::Command(command) => Some(command.as_str()),
SessionSource::Session(index) => greeter
.sessions
.options
.get(*index)
.and_then(|session| session.path.as_ref())
.and_then(|path| path.as_os_str().to_str()),
SessionSource::Session(index) => greeter.sessions.options.get(*index).map(|session| session.command.as_str()),
}
}
}