diff options
| author | Ivan Molodetskikh <yalterz@gmail.com> | 2023-09-05 12:58:51 +0400 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2023-09-05 12:58:59 +0400 |
| commit | 5225bc9e558cd87ed54271e47dcddaac2d5bcf62 (patch) | |
| tree | 554fa51a59abc2abad1aefac6d1cf2d5e246b5ec /src/main.rs | |
| parent | bdc86032e44a5c84b4552cd1ad2bbbca07955e23 (diff) | |
| download | niri-5225bc9e558cd87ed54271e47dcddaac2d5bcf62.tar.gz niri-5225bc9e558cd87ed54271e47dcddaac2d5bcf62.tar.bz2 niri-5225bc9e558cd87ed54271e47dcddaac2d5bcf62.zip | |
Add configuration file
Diffstat (limited to 'src/main.rs')
| -rw-r--r-- | src/main.rs | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/src/main.rs b/src/main.rs index 9af30d43..f71a959a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,6 +3,7 @@ extern crate tracing; mod animation; mod backend; +mod config; mod dbus; mod frame_clock; mod handlers; @@ -13,8 +14,11 @@ mod utils; use std::env; use std::ffi::OsString; +use std::path::PathBuf; use clap::Parser; +use config::Config; +use miette::Context; use niri::{Niri, State}; use smithay::reexports::calloop::EventLoop; use smithay::reexports::wayland_server::Display; @@ -23,6 +27,9 @@ use tracing_subscriber::EnvFilter; #[derive(Parser)] #[command(author, version, about, long_about = None)] struct Cli { + /// Path to config file (default: `$XDG_CONFIG_HOME/niri/config.kdl`). + #[arg(short, long)] + config: Option<PathBuf>, /// Command to run upon compositor startup. #[arg(last = true)] command: Vec<OsString>, @@ -47,9 +54,22 @@ fn main() { let _client = tracy_client::Client::start(); + let config = match Config::load(cli.config).context("error loading config") { + Ok(config) => config, + Err(err) => { + warn!("{err:?}"); + Config::default() + } + }; + let mut event_loop = EventLoop::try_new().unwrap(); let mut display = Display::new().unwrap(); - let state = State::new(event_loop.handle(), event_loop.get_signal(), &mut display); + let state = State::new( + config, + event_loop.handle(), + event_loop.get_signal(), + &mut display, + ); let mut data = LoopData { display, state }; if let Some((command, args)) = cli.command.split_first() { |
