Skip to content

Commit

Permalink
Fixed bug where selecting a session from the menu would not execute t…
Browse files Browse the repository at this point in the history
…he right command.
  • Loading branch information
apognu committed Nov 8, 2023
1 parent fe58763 commit 6426cd5
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 4 additions & 0 deletions src/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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![],
Expand Down
3 changes: 2 additions & 1 deletion src/ipc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down Expand Up @@ -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);
}
}

Expand Down
7 changes: 1 addition & 6 deletions src/ui/sessions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
}
}
}
Expand Down

0 comments on commit 6426cd5

Please sign in to comment.