mirror of
https://github.com/Zenithsiz/zsw.git
synced 2026-02-04 02:08:37 +00:00
Renamed config dirs to dirs.
This commit is contained in:
parent
d430689b52
commit
26290d6630
@ -1,4 +1,4 @@
|
||||
//! Configuration directories
|
||||
//! Project directories
|
||||
|
||||
// Imports
|
||||
use std::{
|
||||
@ -6,11 +6,11 @@ use std::{
|
||||
sync::OnceLock,
|
||||
};
|
||||
|
||||
/// Config directories
|
||||
/// Directories
|
||||
#[derive(Debug)]
|
||||
pub struct ConfigDirs {
|
||||
pub struct Dirs {
|
||||
/// Root config directory
|
||||
root: PathBuf,
|
||||
config_dir: PathBuf,
|
||||
|
||||
/// Displays directory
|
||||
displays: OnceLock<PathBuf>,
|
||||
@ -22,11 +22,11 @@ pub struct ConfigDirs {
|
||||
profiles: OnceLock<PathBuf>,
|
||||
}
|
||||
|
||||
impl ConfigDirs {
|
||||
/// Creates new config dirs from the root path
|
||||
pub fn new(root: PathBuf) -> Self {
|
||||
impl Dirs {
|
||||
/// Creates new directories from a few root paths
|
||||
pub fn new(config_dir: PathBuf) -> Self {
|
||||
Self {
|
||||
root,
|
||||
config_dir,
|
||||
displays: OnceLock::new(),
|
||||
playlists: OnceLock::new(),
|
||||
profiles: OnceLock::new(),
|
||||
@ -36,7 +36,7 @@ impl ConfigDirs {
|
||||
/// Returns the displays directory
|
||||
pub fn displays(&self) -> &Path {
|
||||
self.displays.get_or_init(|| {
|
||||
let path = self.root.join("displays");
|
||||
let path = self.config_dir.join("displays");
|
||||
tracing::info!("Panels path: {path:?}");
|
||||
path
|
||||
})
|
||||
@ -45,7 +45,7 @@ impl ConfigDirs {
|
||||
/// Returns the playlists directory
|
||||
pub fn playlists(&self) -> &Path {
|
||||
self.playlists.get_or_init(|| {
|
||||
let path = self.root.join("playlists");
|
||||
let path = self.config_dir.join("playlists");
|
||||
tracing::info!("Playlists path: {path:?}");
|
||||
path
|
||||
})
|
||||
@ -54,7 +54,7 @@ impl ConfigDirs {
|
||||
/// Returns the profiles directory
|
||||
pub fn profiles(&self) -> &Path {
|
||||
self.profiles.get_or_init(|| {
|
||||
let path = self.root.join("profiles");
|
||||
let path = self.config_dir.join("profiles");
|
||||
tracing::info!("Playlists path: {path:?}");
|
||||
path
|
||||
})
|
||||
@ -27,7 +27,7 @@
|
||||
// Modules
|
||||
mod args;
|
||||
mod config;
|
||||
mod config_dirs;
|
||||
mod dirs;
|
||||
mod display;
|
||||
mod init;
|
||||
mod menu;
|
||||
@ -42,7 +42,7 @@ mod window;
|
||||
use {
|
||||
self::{
|
||||
config::Config,
|
||||
config_dirs::ConfigDirs,
|
||||
dirs::Dirs,
|
||||
display::Displays,
|
||||
menu::Menu,
|
||||
metrics::Metrics,
|
||||
@ -89,13 +89,13 @@ fn main() -> Result<(), AppError> {
|
||||
let config_path = args.config.unwrap_or_else(|| dirs.data_dir().join("config.toml"));
|
||||
let config = Config::get_or_create_default(&config_path);
|
||||
let config = Arc::new(config);
|
||||
let config_dirs = ConfigDirs::new(
|
||||
let dirs = Dirs::new(
|
||||
config_path
|
||||
.parent()
|
||||
.expect("Config file had no parent directory")
|
||||
.to_path_buf(),
|
||||
);
|
||||
let config_dirs = Arc::new(config_dirs);
|
||||
let dirs = Arc::new(dirs);
|
||||
tracing::debug!("Loaded config: {config:?}");
|
||||
|
||||
// Initialize the logger properly now
|
||||
@ -114,7 +114,7 @@ fn main() -> Result<(), AppError> {
|
||||
.context("Unable to build winit event loop")?;
|
||||
|
||||
// Initialize the app
|
||||
let mut app = WinitApp::new(config, config_dirs, event_loop.create_proxy())
|
||||
let mut app = WinitApp::new(config, dirs, event_loop.create_proxy())
|
||||
.block_on()
|
||||
.context("Unable to create winit app")?;
|
||||
|
||||
@ -169,14 +169,14 @@ impl WinitApp {
|
||||
/// Creates a new app
|
||||
pub async fn new(
|
||||
config: Arc<Config>,
|
||||
config_dirs: Arc<ConfigDirs>,
|
||||
dirs: Arc<Dirs>,
|
||||
event_loop_proxy: EventLoopProxy<AppEvent>,
|
||||
) -> Result<Self, AppError> {
|
||||
let wgpu = Wgpu::new().await.context("Unable to initialize wgpu")?;
|
||||
let panels_renderer_shared = PanelsRendererShared::new(&wgpu);
|
||||
|
||||
// Create and stat loading the displays
|
||||
let displays = Displays::new(config_dirs.displays().to_path_buf())
|
||||
let displays = Displays::new(dirs.displays().to_path_buf())
|
||||
.await
|
||||
.context("Unable to create displays")?;
|
||||
let displays = Arc::new(displays);
|
||||
@ -184,7 +184,7 @@ impl WinitApp {
|
||||
zsw_util::spawn_task("Load displays", async move { displays.load_all().await });
|
||||
|
||||
// Create and stat loading the playlists
|
||||
let playlists = Playlists::new(config_dirs.playlists().to_path_buf())
|
||||
let playlists = Playlists::new(dirs.playlists().to_path_buf())
|
||||
.await
|
||||
.context("Unable to create playlists")?;
|
||||
let playlists = Arc::new(playlists);
|
||||
@ -192,7 +192,7 @@ impl WinitApp {
|
||||
zsw_util::spawn_task("Load playlists", async move { playlists.load_all().await });
|
||||
|
||||
// Create and stat loading the profiles
|
||||
let profiles = Profiles::new(config_dirs.profiles().to_path_buf())
|
||||
let profiles = Profiles::new(dirs.profiles().to_path_buf())
|
||||
.await
|
||||
.context("Unable to create profiles")?;
|
||||
let profiles = Arc::new(profiles);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user