aboutsummaryrefslogtreecommitdiff
path: root/niri-config
diff options
context:
space:
mode:
authorIvan Molodetskikh <yalterz@gmail.com>2024-01-18 11:02:15 +0400
committerIvan Molodetskikh <yalterz@gmail.com>2024-01-18 11:13:36 +0400
commit0f85c7954888b436359af1f76e3eb800817c085e (patch)
treec09a0b6ea50fb867889dd9c5a6f616003bea126b /niri-config
parent6beef26662e4aab28bc7928ad5f3e2878a2199bd (diff)
downloadniri-0f85c7954888b436359af1f76e3eb800817c085e.tar.gz
niri-0f85c7954888b436359af1f76e3eb800817c085e.tar.bz2
niri-0f85c7954888b436359af1f76e3eb800817c085e.zip
Watch config path even if it didn't exist at startup
Diffstat (limited to 'niri-config')
-rw-r--r--niri-config/Cargo.toml1
-rw-r--r--niri-config/src/lib.rs22
2 files changed, 5 insertions, 18 deletions
diff --git a/niri-config/Cargo.toml b/niri-config/Cargo.toml
index 1d6acab9..3f3c61a4 100644
--- a/niri-config/Cargo.toml
+++ b/niri-config/Cargo.toml
@@ -9,7 +9,6 @@ repository.workspace = true
[dependencies]
bitflags.workspace = true
-directories.workspace = true
knuffel = "3.2.0"
miette = "5.10.0"
smithay.workspace = true
diff --git a/niri-config/src/lib.rs b/niri-config/src/lib.rs
index b9742df8..f61180f0 100644
--- a/niri-config/src/lib.rs
+++ b/niri-config/src/lib.rs
@@ -1,11 +1,10 @@
#[macro_use]
extern crate tracing;
-use std::path::PathBuf;
+use std::path::{Path, PathBuf};
use std::str::FromStr;
use bitflags::bitflags;
-use directories::ProjectDirs;
use miette::{miette, Context, IntoDiagnostic, NarratableReportHandler};
use smithay::input::keyboard::keysyms::KEY_NoSymbol;
use smithay::input::keyboard::xkb::{keysym_from_name, KEYSYM_CASE_INSENSITIVE};
@@ -479,30 +478,19 @@ impl Default for DebugConfig {
}
impl Config {
- pub fn load(path: Option<PathBuf>) -> miette::Result<(Self, PathBuf)> {
+ pub fn load(path: &Path) -> miette::Result<Self> {
let _span = tracy_client::span!("Config::load");
Self::load_internal(path).context("error loading config")
}
- fn load_internal(path: Option<PathBuf>) -> miette::Result<(Self, PathBuf)> {
- let path = if let Some(path) = path {
- path
- } else {
- let mut path = ProjectDirs::from("", "", "niri")
- .ok_or_else(|| miette!("error retrieving home directory"))?
- .config_dir()
- .to_owned();
- path.push("config.kdl");
- path
- };
-
- let contents = std::fs::read_to_string(&path)
+ fn load_internal(path: &Path) -> miette::Result<Self> {
+ let contents = std::fs::read_to_string(path)
.into_diagnostic()
.with_context(|| format!("error reading {path:?}"))?;
let config = Self::parse("config.kdl", &contents).context("error parsing")?;
debug!("loaded config from {path:?}");
- Ok((config, path))
+ Ok(config)
}
pub fn parse(filename: &str, text: &str) -> Result<Self, knuffel::Error> {