Skip to content

Commit e3a5a86

Browse files
Prevent config re-read loop
1 parent 6689b2c commit e3a5a86

2 files changed

Lines changed: 9 additions & 4 deletions

File tree

share/tiny-dfr/config.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ MediaLayerDefault = false
1111
ShowButtonOutlines = true
1212

1313
# Set this to true to slowly shift the entire screen contents.
14-
# In theory this helps with screen longevity, but macos does not bother doint it
14+
# In theory this helps with screen longevity, but macos does not bother doing it
1515
# Disabling ShowButtonOutlines will make this effect less noticeable to the eye
1616
EnablePixelShift = false
1717

src/main.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ use nix::{
2828
poll::{poll, PollFd, PollFlags},
2929
sys::{
3030
signal::{Signal, SigSet},
31-
inotify::{AddWatchFlags, InitFlags, Inotify}
31+
inotify::{AddWatchFlags, InitFlags, Inotify, WatchDescriptor}
3232
},
3333
errno::Errno
3434
};
@@ -370,6 +370,11 @@ fn main() {
370370
sigset.wait().unwrap();
371371
}
372372

373+
fn arm_inotify(inotify_fd: &Inotify) -> WatchDescriptor {
374+
let flags = AddWatchFlags::IN_MOVED_TO | AddWatchFlags::IN_CLOSE | AddWatchFlags::IN_ONESHOT;
375+
inotify_fd.add_watch(USER_CFG_PATH, flags).unwrap()
376+
}
377+
373378
fn real_main(drm: &mut DrmBackend) {
374379
let mut uinput = UInputHandle::new(OpenOptions::new().write(true).open("/dev/uinput").unwrap());
375380
let mut backlight = BacklightManager::new();
@@ -404,8 +409,7 @@ fn real_main(drm: &mut DrmBackend) {
404409
}
405410
}
406411
let inotify_fd = Inotify::init(InitFlags::IN_NONBLOCK).unwrap();
407-
let flags = AddWatchFlags::IN_MOVED_TO | AddWatchFlags::IN_CLOSE;
408-
let cfg_watch_desc = inotify_fd.add_watch(USER_CFG_PATH, flags).unwrap();
412+
let mut cfg_watch_desc = arm_inotify(&inotify_fd);
409413
let pollfd_notify = PollFd::new(&inotify_fd, PollFlags::POLLIN);
410414
let mut dev_name_c = [0 as c_char; 80];
411415
let dev_name = "Dynamic Function Row Virtual Input Device".as_bytes();
@@ -439,6 +443,7 @@ fn real_main(drm: &mut DrmBackend) {
439443
(cfg, layers) = load_config();
440444
active_layer = 0;
441445
needs_complete_redraw = true;
446+
cfg_watch_desc = arm_inotify(&inotify_fd);
442447
}
443448

444449
let mut next_timeout_ms = TIMEOUT_MS;

0 commit comments

Comments
 (0)