refactor: idiomatic Rust cleanup and quality improvements

- Replace .map().unwrap_or(false) with .is_some_and()/.is_ok_and()
- Use path.display() instead of {:?} for user-facing messages
- Replace Option<Option<Vec<String>>> with GamescopeUpdate enum
- Replace manual parent-walking loops with .ancestors() iterators
- Simplify kill()/kill_all() signatures to return () instead of Result
- Use tokio::task::spawn_blocking instead of hand-rolled thread+oneshot
- Read /proc/self/status for UID instead of spawning id subprocess
- Build Exec= line directly in render_desktop instead of string-replace
- Bump PKGBUILD pkgrel to 6
This commit is contained in:
funman300
2026-04-19 11:29:42 -07:00
parent 8447581fe6
commit 2f4f1c64d2
13 changed files with 86 additions and 98 deletions
+5 -7
View File
@@ -171,8 +171,7 @@ fn update(state: &mut Dashboard, msg: Message) -> Task<Message> {
.stdout(std::process::Stdio::null())
.stderr(std::process::Stdio::null())
.status()
.map(|s| s.success())
.unwrap_or(false);
.is_ok_and(|s| s.success());
map.insert(name, running);
}
map
@@ -183,7 +182,7 @@ fn update(state: &mut Dashboard, msg: Message) -> Task<Message> {
Message::PollDone(snapshot) => {
state.running = snapshot;
// Clear launch_busy for launchers that are now running
state.launch_busy.retain(|n| !state.running.get(n).copied().unwrap_or(false));
state.launch_busy.retain(|n| !state.running.get(n).copied().unwrap_or_default());
Task::none()
}
Message::ReloadConfig => {
@@ -237,7 +236,7 @@ fn update(state: &mut Dashboard, msg: Message) -> Task<Message> {
let name2 = name.clone();
state.running.insert(name, false);
Task::perform(
async_blocking(move || launcher::kill(&l).map_err(|e| e.to_string())),
async_blocking(move || { launcher::kill(&l); Ok::<(), String>(()) }),
move |res| Message::KillDone(name2.clone(), res),
)
}
@@ -700,8 +699,7 @@ fn toggle_flag(
fn service_is_installed() -> bool {
dirs::home_dir()
.map(|h| h.join(".config/autostart/umutray.desktop").exists())
.unwrap_or(false)
.is_some_and(|h| h.join(".config/autostart/umutray.desktop").exists())
}
fn subscription(_: &Dashboard) -> Subscription<Message> {
@@ -1054,7 +1052,7 @@ fn launcher_card<'a>(
// ── Games section ─────────────────────────────────────────────────────
let has_games = !l.games.is_empty();
let has_scan = scan_results.map(|r| !r.is_empty()).unwrap_or(false);
let has_scan = scan_results.is_some_and(|r| !r.is_empty());
if has_games || has_scan || scan_busy {
let game_count = l.games.len();