diff --git a/neutauri_bundler/src/data.rs b/neutauri_bundler/src/data.rs index 6fdc1a1..6d1edc4 100644 --- a/neutauri_bundler/src/data.rs +++ b/neutauri_bundler/src/data.rs @@ -238,7 +238,7 @@ impl Default for Config { max_inner_size: None, resizable: true, fullscreen: false, - title: "".to_string(), + title: "".into(), maximized: false, visible: true, transparent: false, @@ -246,9 +246,9 @@ impl Default for Config { always_on_top: false, window_icon: None, spa: false, - url: Some("/index.html".to_string()), + url: Some("/index.html".into()), html: None, - initialization_script: Some("".to_string()), + initialization_script: Some("".into()), } } } diff --git a/neutauri_bundler/src/main.rs b/neutauri_bundler/src/main.rs index db2a98e..7354f2e 100644 --- a/neutauri_bundler/src/main.rs +++ b/neutauri_bundler/src/main.rs @@ -30,7 +30,7 @@ fn options() -> fs::OpenOptions { fn main() -> wry::Result<()> { let arg = std::env::args() .nth(1) - .unwrap_or_else(|| "neutauri.toml".to_string()); + .unwrap_or_else(|| "neutauri.toml".into()); if arg == "--help" || arg == "-h" { println!("Usage: neutauri_bundler [neutauri.toml]"); return Ok(()); diff --git a/neutauri_runtime/src/data.rs b/neutauri_runtime/src/data.rs index 12f21bb..aa6d377 100644 --- a/neutauri_runtime/src/data.rs +++ b/neutauri_runtime/src/data.rs @@ -206,7 +206,7 @@ impl Default for Config { max_inner_size: None, resizable: true, fullscreen: false, - title: "".to_string(), + title: "".into(), maximized: false, visible: true, transparent: false, @@ -214,9 +214,9 @@ impl Default for Config { always_on_top: false, window_icon: None, spa: false, - url: Some("/index.html".to_string()), + url: Some("/index.html".into()), html: None, - initialization_script: Some("".to_string()), + initialization_script: Some("".into()), } } } diff --git a/neutauri_runtime/src/main.rs b/neutauri_runtime/src/main.rs index ae4de7f..aff4e8b 100644 --- a/neutauri_runtime/src/main.rs +++ b/neutauri_runtime/src/main.rs @@ -1,15 +1,15 @@ #![windows_subsystem = "windows"] -use std::path; +use std::path::PathBuf; use wry::{ application::{ dpi::{PhysicalSize, Size}, - event::{Event, WindowEvent, StartCause}, + event::{Event, StartCause, WindowEvent}, event_loop::{ControlFlow, EventLoop}, window::{Fullscreen, Icon, Window, WindowBuilder}, }, - webview::{RpcRequest, WebViewBuilder, WebContext}, + webview::{RpcRequest, WebContext, WebViewBuilder}, }; mod data; @@ -114,13 +114,29 @@ fn main() -> wry::Result<()> { }; let path = std::env::current_exe()?; let path = path.file_stem().unwrap_or_else(|| "neutauri_app".as_ref()); - let mut web_context = if cfg!(windows) { - let config_path = std::env::var("APPDATA").unwrap_or_else(|_| ".".into()); - let config_path = path::Path::new(&config_path).join(path); + let mut web_context = if cfg!(target_os = "windows") { + let config_path = match std::env::var("APPDATA") { + Ok(dir) => PathBuf::from(dir), + Err(_) => PathBuf::from("."), + } + .join(path); WebContext::new(Some(config_path)) - } else if cfg!(linux) { - let config_path = std::env::var("HOME").unwrap_or_else(|_| ".".into()); - let config_path = path::Path::new(&config_path).join(".local/share/").join(path); + } else if cfg!(target_os = "linux") { + let config_path = match std::env::var("XDG_CONFIG_DIR") { + Ok(dir) => PathBuf::from(dir), + Err(_) => match std::env::var("HOME") { + Ok(dir) => PathBuf::from(dir).join(".config"), + Err(_) => PathBuf::from("."), + }, + } + .join(path); + WebContext::new(Some(config_path)) + } else if cfg!(target_os = "macos") { + let config_path = match std::env::var("HOME") { + Ok(dir) => PathBuf::from(dir).join("Library/Application Support/"), + Err(_) => PathBuf::from("."), + } + .join(path); WebContext::new(Some(config_path)) } else { WebContext::new(None)