From 757e2f8daacb4a7cafc0505d9cb2d12d6f129f77 Mon Sep 17 00:00:00 2001 From: hippoz Date: Tue, 23 Mar 2021 04:32:17 +0200 Subject: [PATCH] add wine binary path to the config --- src/config.rs | 6 ++++-- src/winectl.rs | 8 ++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/config.rs b/src/config.rs index f62cfb7..8fdd6d1 100644 --- a/src/config.rs +++ b/src/config.rs @@ -6,7 +6,8 @@ use serde::{Serialize, Deserialize}; #[derive(Serialize, Deserialize)] pub struct MustConfig { - pub wine_prefix_path: String + pub wine_prefix_path: String, + pub wine_binary_path: String } impl std::default::Default for MustConfig { @@ -14,7 +15,8 @@ impl std::default::Default for MustConfig { let mut home = dirs::data_dir().expect("err: conf: failed to get home folder"); home.push("must-prefix"); Self { - wine_prefix_path: home.to_str().expect("err: conf: failed to get home folder").to_string() + wine_prefix_path: home.to_str().expect("err: conf: failed to get home folder").to_string(), + wine_binary_path: which::which("wine").expect("err: conf: failed to get wine binary path").to_str().unwrap().to_string() } } } diff --git a/src/winectl.rs b/src/winectl.rs index d7ccb71..5e3b27a 100644 --- a/src/winectl.rs +++ b/src/winectl.rs @@ -1,15 +1,15 @@ use std::process::Command; -use std::fs; #[path = "config.rs"] mod config; pub fn wine_launch(program_path: &str) { println!("info: wine_launch: looking for wine binary"); - let wine_prefix = config::get_config().expect("err: wine_launch: failed to read config").wine_prefix_path; - let wine_binary = which::which("wine").expect("err: wine_launch: failed to get wine binary path"); + let cfg = config::get_config().expect("err: wine_launch: failed to read config"); + let wine_prefix = cfg.wine_prefix_path; + let wine_binary = cfg.wine_binary_path; println!("info: wine_launch: launching program {:?} with wine {:?} in {:?}", program_path, wine_binary.to_str(), wine_prefix.to_string()); - fs::create_dir_all(&wine_prefix).expect("err: wine_launch: failed to create wineprefix"); + std::fs::create_dir_all(&wine_prefix).expect("err: wine_launch: failed to create wineprefix"); Command::new(wine_binary) .env("WINEPREFIX", wine_prefix) .arg(program_path)