aboutsummaryrefslogtreecommitdiff
path: root/alacritty
diff options
context:
space:
mode:
Diffstat (limited to 'alacritty')
-rw-r--r--alacritty/Cargo.toml2
-rw-r--r--alacritty/src/config/monitor.rs32
2 files changed, 16 insertions, 18 deletions
diff --git a/alacritty/Cargo.toml b/alacritty/Cargo.toml
index c414e766..307b8c8c 100644
--- a/alacritty/Cargo.toml
+++ b/alacritty/Cargo.toml
@@ -31,7 +31,7 @@ serde_yaml = "0.8"
serde_json = "1"
glutin = { version = "0.30.0", default-features = false, features = ["egl", "wgl"] }
winit = { version = "0.27.4", default-features = false, features = ["serde"] }
-notify = "4"
+notify-debouncer-mini = { version = "0.2.1", default-features = false }
parking_lot = "0.12.0"
crossfont = { version = "0.5.0", features = ["force_system_fontconfig"] }
copypasta = { version = "0.8.1", default-features = false }
diff --git a/alacritty/src/config/monitor.rs b/alacritty/src/config/monitor.rs
index f6d52e2f..622a993b 100644
--- a/alacritty/src/config/monitor.rs
+++ b/alacritty/src/config/monitor.rs
@@ -3,7 +3,8 @@ use std::sync::mpsc;
use std::time::Duration;
use log::{debug, error};
-use notify::{watcher, DebouncedEvent, RecursiveMode, Watcher};
+use notify_debouncer_mini::new_debouncer;
+use notify_debouncer_mini::notify::RecursiveMode;
use winit::event_loop::EventLoopProxy;
use alacritty_terminal::thread;
@@ -40,8 +41,8 @@ pub fn watch(mut paths: Vec<PathBuf>, event_proxy: EventLoopProxy<Event>) {
// The Duration argument is a debouncing period.
let (tx, rx) = mpsc::channel();
- let mut watcher = match watcher(tx, DEBOUNCE_DELAY) {
- Ok(watcher) => watcher,
+ let mut debouncer = match new_debouncer(DEBOUNCE_DELAY, None, tx) {
+ Ok(debouncer) => debouncer,
Err(err) => {
error!("Unable to watch config file: {}", err);
return;
@@ -61,6 +62,7 @@ pub fn watch(mut paths: Vec<PathBuf>, event_proxy: EventLoopProxy<Event>) {
parents.sort_unstable();
parents.dedup();
+ let watcher = debouncer.watcher();
// Watch all configuration file directories.
for parent in &parents {
if let Err(err) = watcher.watch(parent, RecursiveMode::NonRecursive) {
@@ -69,26 +71,22 @@ pub fn watch(mut paths: Vec<PathBuf>, event_proxy: EventLoopProxy<Event>) {
}
loop {
- let event = match rx.recv() {
- Ok(event) => event,
+ let events = match rx.recv() {
+ Ok(Ok(events)) => events,
+ Ok(Err(err)) => {
+ debug!("Config watcher errors: {:?}", err);
+ continue;
+ },
Err(err) => {
debug!("Config watcher channel dropped unexpectedly: {}", err);
break;
},
};
- match event {
- DebouncedEvent::Rename(_, path)
- | DebouncedEvent::Write(path)
- | DebouncedEvent::Create(path)
- | DebouncedEvent::Chmod(path)
- if paths.contains(&path) =>
- {
- // Always reload the primary configuration file.
- let event = Event::new(EventType::ConfigReload(paths[0].clone()), None);
- let _ = event_proxy.send_event(event);
- },
- _ => (),
+ if events.iter().any(|e| paths.contains(&e.path)) {
+ // Always reload the primary configuration file.
+ let event = Event::new(EventType::ConfigReload(paths[0].clone()), None);
+ let _ = event_proxy.send_event(event);
}
}
});