Port changes from -x repo (#3)
* Port config support from -x repo * Port changes from -x repo
This commit is contained in:
41
src/state.rs
41
src/state.rs
@@ -1,10 +1,12 @@
|
||||
use std::{env::VarError, path::Path, sync::Arc};
|
||||
use std::{path::PathBuf, sync::Arc};
|
||||
|
||||
use glam::{Quat, Vec3};
|
||||
use vulkano::{command_buffer::CommandBufferUsage, format::Format, image::view::ImageView};
|
||||
|
||||
use crate::{
|
||||
backend::{common::TaskContainer, input::InputState},
|
||||
config::GeneralConfig,
|
||||
config_io,
|
||||
graphics::WlxGraphics,
|
||||
gui::font::FontCache,
|
||||
hid::HidProvider,
|
||||
@@ -74,16 +76,10 @@ impl AppState {
|
||||
}
|
||||
|
||||
pub struct AppSession {
|
||||
pub config_path: String,
|
||||
pub config_root_path: PathBuf,
|
||||
pub config: GeneralConfig,
|
||||
|
||||
pub show_screens: Vec<String>,
|
||||
pub show_keyboard: bool,
|
||||
pub keyboard_volume: f32,
|
||||
|
||||
pub screen_flip_h: bool,
|
||||
pub screen_flip_v: bool,
|
||||
pub screen_invert_color: bool,
|
||||
pub screen_max_res: [u32; 2],
|
||||
|
||||
pub watch_hand: usize,
|
||||
pub watch_pos: Vec3,
|
||||
@@ -97,34 +93,18 @@ pub struct AppSession {
|
||||
pub color_shift: Vec3,
|
||||
pub color_alt: Vec3,
|
||||
pub color_grab: Vec3,
|
||||
|
||||
pub click_freeze_time_ms: u64,
|
||||
}
|
||||
|
||||
impl AppSession {
|
||||
pub fn load() -> Self {
|
||||
let config_path = std::env::var("XDG_CONFIG_HOME")
|
||||
.or_else(|_| std::env::var("HOME").map(|home| format!("{}/.config", home)))
|
||||
.or_else(|_| {
|
||||
log::warn!("Err: $XDG_CONFIG_HOME and $HOME are not set, using /tmp/wlxoverlay");
|
||||
Ok::<String, VarError>("/tmp".to_string())
|
||||
})
|
||||
.map(|config| Path::new(&config).join("wlxoverlay"))
|
||||
.ok()
|
||||
.and_then(|path| path.to_str().map(|path| path.to_string()))
|
||||
.unwrap();
|
||||
|
||||
let _ = std::fs::create_dir(&config_path);
|
||||
let config_root_path = config_io::ensure_config_root();
|
||||
println!("Config root path: {}", config_root_path.to_string_lossy());
|
||||
let config = GeneralConfig::load_from_disk();
|
||||
|
||||
AppSession {
|
||||
config_path,
|
||||
config_root_path,
|
||||
config,
|
||||
show_screens: vec!["DP-3".to_string()],
|
||||
keyboard_volume: 0.5,
|
||||
show_keyboard: false,
|
||||
screen_flip_h: false,
|
||||
screen_flip_v: false,
|
||||
screen_invert_color: false,
|
||||
screen_max_res: [2560, 1440],
|
||||
capture_method: "auto".to_string(),
|
||||
primary_hand: 1,
|
||||
watch_hand: 0,
|
||||
@@ -150,7 +130,6 @@ impl AppSession {
|
||||
y: 0.,
|
||||
z: 0.,
|
||||
},
|
||||
click_freeze_time_ms: 300,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user