add wine binary path to the config
This commit is contained in:
parent
bc00493659
commit
757e2f8daa
2 changed files with 8 additions and 6 deletions
|
@ -6,7 +6,8 @@ use serde::{Serialize, Deserialize};
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize)]
|
#[derive(Serialize, Deserialize)]
|
||||||
pub struct MustConfig {
|
pub struct MustConfig {
|
||||||
pub wine_prefix_path: String
|
pub wine_prefix_path: String,
|
||||||
|
pub wine_binary_path: String
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::default::Default for MustConfig {
|
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");
|
let mut home = dirs::data_dir().expect("err: conf: failed to get home folder");
|
||||||
home.push("must-prefix");
|
home.push("must-prefix");
|
||||||
Self {
|
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()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
use std::fs;
|
|
||||||
|
|
||||||
#[path = "config.rs"]
|
#[path = "config.rs"]
|
||||||
mod config;
|
mod config;
|
||||||
|
|
||||||
pub fn wine_launch(program_path: &str) {
|
pub fn wine_launch(program_path: &str) {
|
||||||
println!("info: wine_launch: looking for wine binary");
|
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 cfg = config::get_config().expect("err: wine_launch: failed to read config");
|
||||||
let wine_binary = which::which("wine").expect("err: wine_launch: failed to get wine binary path");
|
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());
|
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)
|
Command::new(wine_binary)
|
||||||
.env("WINEPREFIX", wine_prefix)
|
.env("WINEPREFIX", wine_prefix)
|
||||||
.arg(program_path)
|
.arg(program_path)
|
||||||
|
|
Loading…
Reference in a new issue