From 45242fe821d1c8cdd6664a3cb1052895bcaef27f Mon Sep 17 00:00:00 2001 From: GeckoEidechse Date: Mon, 5 Sep 2022 13:33:50 +0200 Subject: [PATCH] Switch to OS agnostic library for getting username Previous one did not support Windows --- Cargo.lock | 18 +++++++----------- Cargo.toml | 2 +- src/main.rs | 24 ++++++------------------ 3 files changed, 14 insertions(+), 30 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fbe80f1..7b8c001 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1530,7 +1530,7 @@ dependencies = [ "serde_json", "steamlocate", "tracing-subscriber", - "users", + "whoami", "zip", ] @@ -2585,16 +2585,6 @@ dependencies = [ "percent-encoding", ] -[[package]] -name = "users" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24cc0f6d6f267b73e5a2cadf007ba8f9bc39c6a6f9666f8cf25ea809a153b032" -dependencies = [ - "libc", - "log", -] - [[package]] name = "valuable" version = "0.1.0" @@ -2819,6 +2809,12 @@ dependencies = [ "winapi", ] +[[package]] +name = "whoami" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7884773ab69074615cb8f8425d0e53f11710786158704fca70f53e71b0e05504" + [[package]] name = "widestring" version = "0.5.1" diff --git a/Cargo.toml b/Cargo.toml index d1d3491..bd83421 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -30,7 +30,7 @@ anyhow = "1.0" # Find steam games steamlocate = "1.0.2" # Get current user username -users = "0.11.0" +whoami = "0.9.0" [profile.release] opt-level = 2 # fast and small wasm diff --git a/src/main.rs b/src/main.rs index 263fa2d..73bb5b5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -27,24 +27,12 @@ fn main() { } let mut native_options = eframe::NativeOptions::default(); - match users::get_current_username() { - Some(username) => { - println!("Username {:?}", username); - match username.to_str() { - Some(username) => { - println!("{}", username); - if username == "deck" { - // Run in fullscreen if user is Steam Deck (or just called `deck`) - native_options.maximized = true; - } - } - None => println!("Couldn't convert OS string"), - }; - } - None => { - println!("Failed to get current user username"); - } - }; + + // Run in fullscreen if user is Steam Deck (or just called `deck`) + // in the future, this should check for more Steam Deck specific settings + if whoami::username() == "deck" { + native_options.maximized = true; + } eframe::run_native( "northstar_dev_testing_helper_tool",