make multiple attempts for _get_values_of_seat0
Signed-off-by: Sahil Yeole <sahilyeole93@gmail.com>
This commit is contained in:
parent
c88219b769
commit
30c002831e
@ -124,7 +124,7 @@ fn line_values(indices: &[usize], line: &str) -> Vec<String> {
|
||||
|
||||
#[inline]
|
||||
pub fn get_values_of_seat0(indices: &[usize]) -> Vec<String> {
|
||||
_get_values_of_seat0(indices, true)
|
||||
_get_values_of_seat0(indices, true, 20)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
@ -132,9 +132,8 @@ pub fn get_values_of_seat0_with_gdm_wayland(indices: &[usize]) -> Vec<String> {
|
||||
_get_values_of_seat0(indices, false)
|
||||
}
|
||||
|
||||
fn _get_values_of_seat0(indices: &[usize], ignore_gdm_wayland: bool) -> Vec<String> {
|
||||
let mut retry_attempt = 0;
|
||||
loop{
|
||||
fn _get_values_of_seat0(indices: &[usize], ignore_gdm_wayland: bool, attempts: usize) -> Vec<String> {
|
||||
for _ in 0..attempts {
|
||||
if let Ok(output) = run_loginctl(None) {
|
||||
for line in String::from_utf8_lossy(&output.stdout).lines() {
|
||||
if line.contains("seat0") {
|
||||
@ -174,14 +173,11 @@ fn _get_values_of_seat0(indices: &[usize], ignore_gdm_wayland: bool) -> Vec<Stri
|
||||
}
|
||||
}
|
||||
|
||||
if retry_attempt >= 1 {
|
||||
// Wait for 300ms and try again
|
||||
std::thread::sleep(std::time::Duration::from_millis(300));
|
||||
}
|
||||
return line_values(indices, "");
|
||||
}
|
||||
// Increment the retry_attempt counter and wait for 5 seconds before retrying
|
||||
retry_attempt += 1;
|
||||
std::thread::sleep(Duration::from_secs(5));
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_active(sid: &str) -> bool {
|
||||
if let Ok(output) = run_loginctl(Some(vec!["show-session", "-p", "State", sid])) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user