add wine binary path to the config

This commit is contained in:
hippoz 2021-03-23 04:32:17 +02:00
parent bc00493659
commit 757e2f8daa
No known key found for this signature in database
GPG key ID: 7C52899193467641
2 changed files with 8 additions and 6 deletions

View file

@ -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()
}
}
}

View file

@ -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)