Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

check if $XAUTHORITY is set #220

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/post_login/x.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,12 @@
let vtnr_value = env::var("XDG_VTNR").map_err(|_| XSetupError::VTNREnvVar)?;

// Setup xauth
let xauth_dir = PathBuf::from(env::var("HOME").map_err(|_| XSetupError::HomeEnvVar)?);
let xauth_path = xauth_dir.join(".Xauthority");
info!("Check if `XAUTHORITY` enviroment variable is set");
let xauth_path = match env::var("XAUTHORITY") {
Ok(var) => PathBuf::from(env::var(var).map_err(|_| XSetupError::FillingXAuth)?),
Err(_) => PathBuf::from(env::var("HOME").map_err(|_| XSetupError::HomeEnvVar)?)
.join(".Xauthority"),
};

info!(
"Filling `.Xauthority` file at `{xauth_path}`",
Expand Down Expand Up @@ -119,7 +123,7 @@
})?;

let xauth_path = xauth_path.to_str().ok_or(XSetupError::InvalidUTF8Path)?;
process_env.set("XAUTHORITY", xauth_path);
process_env.set_or_own("XAUTHORITY", xauth_path);

let doubledigit_vtnr = if vtnr_value.len() == 1 {
format!("0{vtnr_value}")
Expand Down Expand Up @@ -163,7 +167,7 @@
let start_time = time::SystemTime::now();
loop {
if config.x11.xserver_timeout_secs == 0
|| start_time.elapsed().map_or(false, |t| {

Check failure on line 170 in src/post_login/x.rs

View workflow job for this annotation

GitHub Actions / Clippy

this `map_or` is redundant
t.as_secs() > config.x11.xserver_timeout_secs.into()
})
{
Expand Down
Loading