File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -4,6 +4,8 @@ mod config;
44mod macos;
55mod utils;
66
7+ use std:: path:: Path ;
8+
79use crate :: { app:: Tile , config:: Config , utils:: to_key_code} ;
810
911use global_hotkey:: {
@@ -20,16 +22,19 @@ fn main() -> iced::Result {
2022 let home = std:: env:: var ( "HOME" ) . unwrap ( ) ;
2123
2224 let file_path = home. clone ( ) + "/.config/rustcast/config.toml" ;
25+ if !Path :: new ( & file_path) . exists ( ) {
26+ std:: fs:: create_dir_all ( home + "/.config/rustcast" ) . unwrap ( ) ;
27+ std:: fs:: write (
28+ & file_path,
29+ toml:: to_string ( & Config :: default ( ) ) . unwrap_or_else ( |x| x. to_string ( ) ) ,
30+ )
31+ . unwrap ( ) ;
32+ }
2333 let config: Config = match std:: fs:: read_to_string ( & file_path) {
24- Ok ( a) => toml:: from_str ( & a) . unwrap ( ) ,
34+ Ok ( a) => toml:: from_str ( & a) . unwrap_or ( Config :: default ( ) ) ,
2535 Err ( _) => Config :: default ( ) ,
2636 } ;
27- std:: fs:: create_dir_all ( home + "/.config/rustcast" ) . unwrap ( ) ;
28- std:: fs:: write (
29- & file_path,
30- toml:: to_string ( & config) . unwrap_or_else ( |x| x. to_string ( ) ) ,
31- )
32- . unwrap ( ) ;
37+
3338 let manager = GlobalHotKeyManager :: new ( ) . unwrap ( ) ;
3439
3540 let show_hide = HotKey :: new (
You can’t perform that action at this time.
0 commit comments