File tree Expand file tree Collapse file tree 2 files changed +23
-12
lines changed Expand file tree Collapse file tree 2 files changed +23
-12
lines changed Original file line number Diff line number Diff line change
1
+ use std:: ffi:: OsStr ;
1
2
use daemonize:: Daemonize ;
2
3
use inotify:: { Inotify , WatchMask } ;
3
4
use nix:: libc:: { pid_t, time_t} ;
@@ -73,7 +74,11 @@ fn findex_daemon(current_time: time_t) {
73
74
let mut buf = [ 0 ; 1024 ] ;
74
75
match inotify. read_events ( & mut buf) {
75
76
Ok ( mut events) => {
76
- if events. next ( ) . is_some ( ) {
77
+ if let Some ( event) = events. next ( ) {
78
+ if event. name == Some ( OsStr :: new ( "toggle_file" ) ) && events. next ( ) . is_none ( ) {
79
+ continue ;
80
+ }
81
+
77
82
println ! ( "[INFO] configs changed, restarting findex" ) ;
78
83
if findex_process. poll ( ) . is_none ( ) {
79
84
findex_process. kill ( ) . unwrap ( ) ;
Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ pub struct GUI {
24
24
pub window : Window ,
25
25
search_box : Entry ,
26
26
result_list : ListBox ,
27
- keybinder : KeyBinder < KeypressHandlerPayload > ,
27
+ keybinder : Option < KeyBinder < KeypressHandlerPayload > > ,
28
28
}
29
29
30
30
impl GUI {
@@ -110,25 +110,31 @@ impl GUI {
110
110
}
111
111
} ) ;
112
112
113
- let keybinder = match KeyBinder :: new ( true ) {
114
- Ok ( instance) => instance,
115
- Err ( _e) => {
116
- eprintln ! ( "[ERROR] Keybinder is not supported" ) ;
117
- std:: process:: exit ( 1 ) ;
118
- }
119
- } ;
113
+ let keybinder;
114
+ if std:: env:: var ( "WAYLAND_DISPLAY" ) . is_err ( ) {
115
+ keybinder = match KeyBinder :: new ( true ) {
116
+ Ok ( instance) => Some ( instance) ,
117
+ Err ( _e) => {
118
+ eprintln ! ( "[ERROR] Keybinder is not supported" ) ;
119
+ std:: process:: exit ( 1 ) ;
120
+ }
121
+ } ;
122
+ } else {
123
+ keybinder = None ;
124
+ }
125
+
120
126
Self {
127
+ keybinder,
121
128
window,
122
- search_box,
123
129
result_list,
124
- keybinder ,
130
+ search_box ,
125
131
}
126
132
}
127
133
128
134
pub fn wait_for_toggle ( & mut self ) {
129
135
if std:: env:: var ( "WAYLAND_DISPLAY" ) . is_err ( ) {
130
136
assert ! (
131
- self . keybinder. bind(
137
+ self . keybinder. as_mut ( ) . unwrap ( ) . bind(
132
138
& FINDEX_CONFIG . toggle_key,
133
139
|_, payload| {
134
140
Self :: show_window( & payload. window, & payload. search_box, & payload. result_list) ;
You can’t perform that action at this time.
0 commit comments