22pub mod elm;
33pub mod update;
44
5+ use crate :: app:: apps:: App ;
56use crate :: app:: { ArrowKey , Message , Move , Page } ;
67use crate :: clipboard:: ClipBoardContentType ;
78use crate :: config:: Config ;
89use crate :: debounce:: Debouncer ;
9- use crate :: { app:: apps:: App , platform:: default_app_paths} ;
1010
1111use arboard:: Clipboard ;
1212use global_hotkey:: hotkey:: HotKey ;
@@ -31,8 +31,6 @@ use tray_icon::TrayIcon;
3131
3232use std:: collections:: HashMap ;
3333use std:: fmt:: Debug ;
34- use std:: fs;
35- use std:: path:: Path ;
3634use std:: str:: FromStr ;
3735use std:: time:: Duration ;
3836
@@ -181,7 +179,6 @@ impl Tile {
181179 keyboard,
182180 Subscription :: run ( handle_recipient) ,
183181 Subscription :: run ( check_version) ,
184- // Subscription::run(handle_hot_reloading),
185182 Subscription :: run ( handle_clipboard_history) ,
186183 Subscription :: run ( handle_file_search) ,
187184 window:: close_events ( ) . map ( Message :: HideWindow ) ,
@@ -281,57 +278,6 @@ impl Tile {
281278 }
282279}
283280
284- #[ allow( unused) ]
285- /// This is the subscription function that handles hot reloading of the config
286- fn handle_hot_reloading ( ) -> impl futures:: Stream < Item = Message > {
287- stream:: channel ( 100 , async |mut output| {
288- let config_path =
289- & ( std:: env:: var ( "HOME" ) . unwrap_or ( "" . to_owned ( ) ) + "/.config/rustcast/config.toml" ) ;
290- let mut last_modified = fs:: metadata ( config_path) . unwrap ( ) . modified ( ) . unwrap ( ) ;
291-
292- let paths = default_app_paths ( ) ;
293- let mut total_files: usize = paths
294- . par_iter ( )
295- . map ( |dir| count_dirs_in_dir ( Path :: new ( dir) ) )
296- . sum ( ) ;
297-
298- loop {
299- let last_modified_check = fs:: metadata ( config_path) . unwrap ( ) . modified ( ) . unwrap ( ) ;
300-
301- let current_total_files: usize = paths
302- . par_iter ( )
303- . map ( |dir| count_dirs_in_dir ( Path :: new ( dir) ) )
304- . sum ( ) ;
305-
306- if last_modified_check != last_modified {
307- last_modified = last_modified_check;
308- info ! ( "Config file was modified" ) ;
309- let _ = output. send ( Message :: ReloadConfig ) . await ;
310- } else if total_files != current_total_files {
311- total_files = current_total_files;
312- info ! ( "App count was changed" ) ;
313- let _ = output. send ( Message :: ReloadConfig ) . await ;
314- }
315-
316- tokio:: time:: sleep ( Duration :: from_millis ( 1000 ) ) . await ;
317- }
318- } )
319- }
320-
321- /// Helper fn for counting directories (since macos `.app`'s are directories) inside a directory
322- fn count_dirs_in_dir ( dir : impl AsRef < Path > ) -> usize {
323- // Read the directory; if it fails, treat as empty
324- let entries = match fs:: read_dir ( dir) {
325- Ok ( e) => e,
326- Err ( _) => return 0 ,
327- } ;
328-
329- entries
330- . filter_map ( |entry| entry. ok ( ) )
331- . filter ( |entry| entry. file_type ( ) . map ( |t| t. is_dir ( ) ) . unwrap_or ( false ) )
332- . count ( )
333- }
334-
335281/// This is the subscription function that handles hotkeys, e.g. for hiding / showing the window
336282fn handle_hotkeys ( ) -> impl futures:: Stream < Item = Message > {
337283 stream:: channel ( 100 , async |mut output| {
0 commit comments