@@ -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+
373378fn 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