Skip to content

Commit

Permalink
add new ErrorCode when checking for XAUTHORITY
Browse files Browse the repository at this point in the history
  • Loading branch information
h-leth committed Jan 21, 2025
1 parent 7fe4e20 commit 7f55c48
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/post_login/x.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ pub enum XSetupError {
VTNREnvVar,
FillingXAuth,
InvalidUTF8Path,
NotUnicode,
XServerStart,
XServerTimeout,
XServerPrematureExit,
Expand All @@ -42,6 +43,7 @@ impl Display for XSetupError {
Self::VTNREnvVar => f.write_str("`XDG_VTNR` is not set"),
Self::FillingXAuth => f.write_str("Failed to fill `.Xauthority` file"),
Self::InvalidUTF8Path => f.write_str("Path that is given is not valid UTF8"),
Self::NotUnicode => f.writte_str("Existing `XAUTHORITY` does not contain valid unicode data"),

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

View workflow job for this annotation

GitHub Actions / Clippy

no method named `writte_str` found for mutable reference `&mut std::fmt::Formatter<'_>` in the current scope

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

View workflow job for this annotation

GitHub Actions / Check

no method named `writte_str` found for mutable reference `&mut std::fmt::Formatter<'_>` in the current scope
Self::XServerStart => f.write_str("Failed to start X server binary"),
Self::XServerTimeout => f.write_str("Timeout while waiting for X server to start"),
Self::XServerPrematureExit => {
Expand Down Expand Up @@ -87,7 +89,7 @@ pub fn setup_x(
// Setup xauth
info!("Check if `XAUTHORITY` enviroment variable is set");
let xauth_path = match env::var("XAUTHORITY") {
Ok(_) => PathBuf::from(env::var("XAUTHORITY").map_err(|_| XSetupError::InvalidUTF8Path)?),
Ok(_) => PathBuf::from(env::var("XAUTHORITY").map_err(|_| XSetupError::NotUnicode)?),
Err(_) => PathBuf::from(env::var("HOME").map_err(|_| XSetupError::HomeEnvVar)?)
.join(".Xauthority"),
};
Expand Down

0 comments on commit 7f55c48

Please sign in to comment.