Skip to content

Commit

Permalink
linux fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Levminer committed Jul 16, 2024
1 parent ce3c90b commit 6040a85
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 11 deletions.
32 changes: 26 additions & 6 deletions platforms/core/src/settings.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use serde::{Deserialize, Serialize};
use std::path::Path;
use uuid::Uuid;

const fn default_string() -> String {
Expand Down Expand Up @@ -49,6 +48,25 @@ pub struct Settings {
pub version: Option<u8>,
}

#[cfg(target_os = "windows")]
fn get_settings_path() -> std::path::PathBuf {
std::path::PathBuf::from("C:\\ProgramData\\Cores")
}

#[cfg(not(target_os = "windows"))]
fn get_settings_path() -> std::path::PathBuf {
use directories::BaseDirs;

match BaseDirs::new() {
Some(base_dirs) => {
return base_dirs.config_dir().to_path_buf();
}
None => {
return std::path::PathBuf::from("/");
}
};
}

fn check_if_settings_exits() {
let sample_settings = Settings {
version: Some(1),
Expand All @@ -62,7 +80,7 @@ fn check_if_settings_exits() {
license_activated: "".to_string(),
};

let program_data = Path::new("C:\\ProgramData");
let program_data = get_settings_path();

// Check if folder exists
if !program_data.join("Cores").exists() {
Expand Down Expand Up @@ -95,11 +113,12 @@ pub fn get_settings() -> Settings {

println!("Getting settings");

let program_data = Path::new("C:\\ProgramData");
let program_data = get_settings_path();

check_if_settings_exits();

let file = std::fs::read_to_string(program_data.join("Cores").join("settings.json")).expect("Failed to read settings file");
let file = std::fs::read_to_string(program_data.join("Cores").join("settings.json"))
.expect("Failed to read settings file");
let settings: Result<Settings, _> = serde_json::from_str(&file);

match settings {
Expand All @@ -120,11 +139,12 @@ pub fn get_settings() -> Settings {

#[tauri::command]
pub fn set_settings(settings: String) {
let program_data = Path::new("C:\\ProgramData");
let program_data = get_settings_path();

println!("Setting settings");

check_if_settings_exits();

std::fs::write(program_data.join("Cores").join("settings.json"), settings).expect("Failed to write settings file");
std::fs::write(program_data.join("Cores").join("settings.json"), settings)
.expect("Failed to write settings file");
}
6 changes: 1 addition & 5 deletions platforms/core/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,7 @@
"minWidth": 600,
"minHeight": 500,
"maximized": true,
"theme": "Dark",
"transparent": true,
"windowEffects": {
"effects": ["mica"]
}
"theme": "Dark"
}
],
"security": {
Expand Down
12 changes: 12 additions & 0 deletions platforms/core/tauri.windows.conf.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"app": {
"windows": [
{
"transparent": true,
"windowEffects": {
"effects": ["mica"]
}
}
]
}
}
4 changes: 4 additions & 0 deletions platforms/interface/app/layout/app.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@
const setBackgroundColor = async () => {
const systemInfo: SystemInfo = await invoke("system_info")
if (systemInfo.osName !== "Windows") {
document.querySelector("body").style.background = "#0a0a0a"
}
if (systemInfo.osName === "Windows" && systemInfo.osVersion < "10.0.22000") {
document.querySelector("body").style.background = "#0a0a0a"
}
Expand Down

0 comments on commit 6040a85

Please sign in to comment.