Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions apps/we-gui/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ use settings_panel::{
ResolutionOption, UiSettings,
};
use we_core::{
config::{build_config, load_launch_settings, save_config, CgroupMode, LaunchSettings, WindowsLauncher},
config::{
build_config, load_launch_settings, save_config, CgroupMode, LaunchSettings,
WindowsLauncher,
},
steam::{self, WallpaperEngineInstallState},
wallpaper::{self, WallpaperEntry, WallpaperType},
};
Expand Down Expand Up @@ -486,7 +489,8 @@ impl App {
steam::default_config_path().unwrap_or_else(|| PathBuf::from("config.toml"));
let mut launch_settings =
load_launch_settings(&config_path).unwrap_or_else(|_| LaunchSettings::default());
let install_state = steam::detect_wallpaper_engine_install_state();
let install_state =
steam::detect_wallpaper_engine_install_state(launch_settings.wallpaper_exe.clone());
let install_notice = match &install_state {
WallpaperEngineInstallState::NotInstalled => Some(
"Wallpaper Engine is not installed. Please install it, or choose paths in Settings."
Expand All @@ -503,9 +507,11 @@ impl App {
None
}
};
let workshop_path = steam::discover_workshop_wallpaper_root()
.map(|p| p.display().to_string())
.unwrap_or_default();
if launch_settings.workshop_path.trim().is_empty() {
launch_settings.workshop_path = steam::discover_workshop_wallpaper_root()
.map(|p| p.display().to_string())
.unwrap_or_default();
}
let supported_resolutions = detect_supported_resolutions();
let wine_commands = steam::discover_wine_commands()
.into_iter()
Expand All @@ -529,7 +535,7 @@ impl App {
let ui_settings = UiSettings {
wallpaper_exe: launch_settings.wallpaper_exe.clone(),
executable_variant: infer_executable_variant(&launch_settings.wallpaper_exe),
workshop_path,
workshop_path: launch_settings.workshop_path.clone(),
launcher_mode: match launch_settings.launcher {
WindowsLauncher::Wine => LauncherModeOption::Wine,
WindowsLauncher::Proton => LauncherModeOption::Proton,
Expand Down
17 changes: 13 additions & 4 deletions crates/we-core/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ pub struct WineConfig {
#[serde(default)]
pub command_mode: WineCommandMode,
pub wallpaper_exe: String,
pub workshop_path: String,
pub args: Vec<String>,
#[serde(default)]
pub env: BTreeMap<String, String>,
Expand Down Expand Up @@ -122,6 +123,7 @@ pub enum CgroupMode {
#[derive(Debug, Clone)]
pub struct LaunchSettings {
pub wallpaper_exe: String,
pub workshop_path: String,
pub launcher: WindowsLauncher,
pub wine_command: String,
pub proton_path: Option<String>,
Expand All @@ -147,6 +149,7 @@ impl Default for LaunchSettings {
fn default() -> Self {
Self {
wallpaper_exe: String::new(),
workshop_path: String::new(),
launcher: WindowsLauncher::Wine,
wine_command: "wine".to_string(),
proton_path: None,
Expand Down Expand Up @@ -217,6 +220,7 @@ impl Default for AppConfig {
command: "wine".to_string(),
command_mode: WineCommandMode::ExeWithArgs,
wallpaper_exe: String::new(),
workshop_path: String::new(),
args: Vec::new(),
env: BTreeMap::new(),
},
Expand Down Expand Up @@ -247,6 +251,7 @@ pub fn build_config(
cfg.wine.command = settings.wine_command.clone();
cfg.wine.command_mode = WineCommandMode::ExeWithArgs;
cfg.wine.wallpaper_exe = settings.wallpaper_exe.clone();
cfg.wine.workshop_path = settings.workshop_path.clone();
cfg.wine.env.clear();
cfg.capture.wm_class_contains = settings.wm_class_contains.clone();
cfg.capture.title_contains = settings.play_in_window_title.clone();
Expand Down Expand Up @@ -374,9 +379,13 @@ pub fn build_config(
"STEAM_COMPAT_CLIENT_INSTALL_PATH".to_string(),
steam_root.display().to_string(),
);
}
if let Some(wallpaper_root) =
derive_steam_root_from_proton_path(exe_path.to_str().unwrap())
{
cfg.wine.env.insert(
"STEAM_COMPAT_DATA_PATH".to_string(),
steam_root
wallpaper_root
.join("steamapps")
.join("compatdata")
.join(WALLPAPER_ENGINE_APP_ID.to_string())
Expand Down Expand Up @@ -427,7 +436,6 @@ pub fn load_launch_settings(path: &Path) -> Result<LaunchSettings> {
let cfg: AppConfig =
toml::from_str(&raw).with_context(|| format!("invalid TOML in {}", path.display()))?;
let mut settings = LaunchSettings::default();

settings.fps_limit = cfg.general.fps_limit;
settings.show_fps = cfg.general.show_fps;
settings.hide_debug_window = cfg.general.hide_debug_window;
Expand All @@ -443,6 +451,8 @@ pub fn load_launch_settings(path: &Path) -> Result<LaunchSettings> {
settings.cgroup_cpu_max = cfg.cgroup.cpu_max;

settings.wallpaper_exe = cfg.wine.wallpaper_exe;
settings.workshop_path = cfg.wine.workshop_path;

match cfg.wine.command_mode {
WineCommandMode::ExeWithArgs => {
settings.launcher = WindowsLauncher::Wine;
Expand All @@ -458,8 +468,7 @@ pub fn load_launch_settings(path: &Path) -> Result<LaunchSettings> {
if let Some(width) = arg_value(&cfg.wine.args, "-width").and_then(|v| v.parse::<u32>().ok()) {
settings.width = width.max(1);
}
if let Some(height) = arg_value(&cfg.wine.args, "-height").and_then(|v| v.parse::<u32>().ok())
{
if let Some(height) = arg_value(&cfg.wine.args, "-height").and_then(|v| v.parse::<u32>().ok()) {
settings.height = height.max(1);
}
if let Some(x) = arg_value(&cfg.wine.args, "-x").and_then(|v| v.parse::<i32>().ok()) {
Expand Down
42 changes: 25 additions & 17 deletions crates/we-core/src/steam.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,28 +41,36 @@ pub fn discover_wallpaper_engine_exe() -> Option<PathBuf> {
None
}

pub fn detect_wallpaper_engine_install_state() -> WallpaperEngineInstallState {
for root in steam_common_roots() {
let app_dir = root.join("wallpaper_engine");
if !app_dir.is_dir() {
continue;
}
pub fn detect_wallpaper_engine_install_state(wallpaper_exe: String) -> WallpaperEngineInstallState {
if wallpaper_exe.trim().is_empty() {
for root in steam_common_roots() {
let app_dir = root.join("wallpaper_engine");
if !app_dir.is_dir() {
continue;
}

let exe64 = app_dir.join("wallpaper64.exe");
if exe64.is_file() {
return WallpaperEngineInstallState::Installed { app_dir, exe_path: exe64 };
}
let exe64 = app_dir.join("wallpaper64.exe");
if exe64.is_file() {
return WallpaperEngineInstallState::Installed { app_dir, exe_path: exe64 };
}

let exe32 = app_dir.join("wallpaper32.exe");
if exe32.is_file() {
return WallpaperEngineInstallState::Installed { app_dir, exe_path: exe32 };
}
let exe32 = app_dir.join("wallpaper32.exe");
if exe32.is_file() {
return WallpaperEngineInstallState::Installed { app_dir, exe_path: exe32 };
}

if app_dir.join("installer.exe").is_file() {
return WallpaperEngineInstallState::FirstRunRequired { app_dir };
if app_dir.join("installer.exe").is_file() {
return WallpaperEngineInstallState::FirstRunRequired { app_dir };
}
}
} else {
let exe64 = PathBuf::from(wallpaper_exe);
let mut app_dir = exe64.clone();
app_dir.pop();
if exe64.is_file() && exe64.ends_with("wallpaper64.exe") {
return WallpaperEngineInstallState::Installed { app_dir, exe_path: exe64 };
}
}

WallpaperEngineInstallState::NotInstalled
}

Expand Down