From a53cd961f6b98b0a487eb6262e1990200048bf0f Mon Sep 17 00:00:00 2001 From: chayleaf Date: Tue, 7 Mar 2023 19:46:23 +0700 Subject: [PATCH] allow multiple types in rofi-steam-game-list --- home/home-daemon/default.nix | 6 +++--- home/rofi-steam-game-list/default.nix | 6 +++--- home/rofi-steam-game-list/src/main.rs | 11 ++++++----- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/home/home-daemon/default.nix b/home/home-daemon/default.nix index 5c59ba7..50ea3d0 100644 --- a/home/home-daemon/default.nix +++ b/home/home-daemon/default.nix @@ -1,11 +1,11 @@ -{ lib, rustPlatform }: +{ lib, rustPlatform, nix-gitignore }: rustPlatform.buildRustPackage { pname = "home-daemon"; version = "0.1"; - src = ../home-daemon; + src = nix-gitignore.gitignoreSource ["/target" "default.nix"] (lib.cleanSource ./.); - cargoLock.lockFile = ../home-daemon/Cargo.lock; + cargoLock.lockFile = ./Cargo.lock; meta = with lib; { description = "My custom home daemon"; diff --git a/home/rofi-steam-game-list/default.nix b/home/rofi-steam-game-list/default.nix index dd2a353..d4f1797 100644 --- a/home/rofi-steam-game-list/default.nix +++ b/home/rofi-steam-game-list/default.nix @@ -1,11 +1,11 @@ -{ lib, rustPlatform }: +{ lib, rustPlatform, nix-gitignore }: rustPlatform.buildRustPackage { pname = "rofi-steam-game-list"; version = "0.1"; - src = ../rofi-steam-game-list; + src = nix-gitignore.gitignoreSource ["/target" "default.nix"] (lib.cleanSource ./.); - cargoLock.lockFile = ../rofi-steam-game-list/Cargo.lock; + cargoLock.lockFile = ./Cargo.lock; meta = with lib; { description = "A program to list Steam games for Rofi"; diff --git a/home/rofi-steam-game-list/src/main.rs b/home/rofi-steam-game-list/src/main.rs index c5ee5f5..a9dbe93 100644 --- a/home/rofi-steam-game-list/src/main.rs +++ b/home/rofi-steam-game-list/src/main.rs @@ -255,11 +255,12 @@ fn read_time(s: String) -> io::Result { std::fs::metadata(s + "/Steam/appcache/appinfo.vdf")?.modified() } -fn read_appinfo(target_type: String, s: String) -> io::Result<(SystemTime, Vec<(u32, String)>)> { +fn read_appinfo(target_type: &str, s: String) -> io::Result<(SystemTime, Vec<(u32, String)>)> { let time = read_time(s.clone())?; let vec = read_file(s + "/Steam/appcache/appinfo.vdf")?; let data = read_app_info(&mut &vec[..])?; let mut ret = Vec::new(); + let target_types = target_type.split(',').collect::>(); for mut info in data.entries { if let Some(mut x) = info .info @@ -279,7 +280,7 @@ fn read_appinfo(target_type: String, s: String) -> io::Result<(SystemTime, Vec<( .and_then(|x| String::from_utf8(x).ok()) { t.make_ascii_lowercase(); - if t == target_type { + if target_types.contains(t.as_str()) { ret.push((info.app_id, n)); } } @@ -411,7 +412,7 @@ impl std::future::Future for PendingFut { fn main() { let target_type = std::env::var("STEAM_GAME_LIST_TYPE").map_or_else( - |_| "game".to_owned(), + |_| "game,application".to_owned(), |mut x| { x.make_ascii_lowercase(); x @@ -437,7 +438,7 @@ fn main() { * */ let xdg_home = xdg_home(); let xdg_home2 = xdg_home.clone(); - let xdg_home3 = xdg_home; + let xdg_home3 = xdg_home.clone(); let target_type2 = target_type.clone(); let target_type3 = target_type.clone(); let target_type4 = target_type.clone(); @@ -448,7 +449,7 @@ fn main() { let tx1 = tx0.clone(); std::thread::spawn(move || { tx0.send( - read_appinfo(target_type2, crate::xdg_home()).map_or_else(|_| { + read_appinfo(&target_type2, xdg_home).map_or_else(|_| { let _ = tx2.send(None); None }, |info| {