File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -359,8 +359,36 @@ pub fn run() {
359359 }
360360 }
361361
362- handle_first_run ( ) ;
363- listen_for_lockfile ( ) ;
362+ let first_run = is_first_run ( ) ;
363+ if * first_run {
364+ thread:: spawn ( || {
365+ // TODO: debug and remove the sleep
366+ thread:: sleep ( Duration :: from_secs ( 1 ) ) ;
367+ let app = & * get_app_handle ( ) . lock ( ) . expect ( "failed to get app handle" ) ;
368+ app. notification ( )
369+ . builder ( )
370+ . title ( "Aw-Tauri" )
371+ . body ( "Aw-Tauri is running in the background" )
372+ . show ( )
373+ . unwrap ( ) ;
374+ } ) ;
375+ }
376+ thread:: spawn ( || {
377+ let config_path = get_config_path ( ) ;
378+ let watcher =
379+ SpecificFileWatcher :: new ( config_path. parent ( ) . unwrap ( ) , "single_instance.lock" )
380+ . expect ( "Failed to create file watcher" ) ;
381+ loop {
382+ if watcher. wait_for_file ( ) . is_ok ( ) {
383+ remove_file ( config_path. parent ( ) . unwrap ( ) . join ( "single_instance.lock" ) )
384+ . expect ( "Failed to remove lock file" ) ;
385+ let app = & * get_app_handle ( ) . lock ( ) . expect ( "failed to get app handle" ) ;
386+ if let Some ( window) = app. webview_windows ( ) . get ( "main" ) {
387+ window. show ( ) . unwrap ( ) ;
388+ }
389+ }
390+ }
391+ } ) ;
364392 Ok ( ( ) )
365393 } )
366394 . on_window_event ( |window, event| {
You can’t perform that action at this time.
0 commit comments