File tree 2 files changed +19
-11
lines changed
2 files changed +19
-11
lines changed Original file line number Diff line number Diff line change 2
2
3
3
## Features
4
4
5
+ - config.toml is now additionally supported.
6
+
5
7
## Changes
6
8
7
9
## Fixes
Original file line number Diff line number Diff line change @@ -8,7 +8,10 @@ use serde::Deserialize;
8
8
use crate :: style:: { Margin , Padding , Radius } ;
9
9
use crate :: Color ;
10
10
11
- const DEFAULT_CONFIG_NAME : & str = concat ! ( crate :: prog_name!( ) , ".config" ) ;
11
+ const DEFAULT_CONFIG_NAMES : [ & str ; 2 ] = [
12
+ concat ! ( crate :: prog_name!( ) , ".toml" ) ,
13
+ concat ! ( crate :: prog_name!( ) , ".config" ) ,
14
+ ] ;
12
15
13
16
const DEFAULT_ICON_SIZE : u16 = 16 ;
14
17
const DEFAULT_FONT_SIZE : u16 = 24 ;
@@ -112,17 +115,20 @@ struct Icon {
112
115
}
113
116
114
117
fn default_config_path ( ) -> Result < Option < PathBuf > > {
115
- let file = xdg:: BaseDirectories :: with_prefix ( crate :: prog_name!( ) )
116
- . context ( "failed to get xdg dirs" ) ?
117
- . get_config_file ( DEFAULT_CONFIG_NAME ) ;
118
- if file
119
- . try_exists ( )
120
- . with_context ( || format ! ( "reading default config at {}" , file. display( ) ) ) ?
121
- {
122
- Ok ( Some ( file) )
123
- } else {
124
- Ok ( None )
118
+ let xdg_dirs =
119
+ xdg:: BaseDirectories :: with_prefix ( crate :: prog_name!( ) ) . context ( "failed to get xdg dirs" ) ?;
120
+
121
+ for & filename in & DEFAULT_CONFIG_NAMES {
122
+ let file = xdg_dirs. get_config_file ( filename) ;
123
+ if file
124
+ . try_exists ( )
125
+ . with_context ( || format ! ( "reading default config at {}" , file. display( ) ) ) ?
126
+ {
127
+ return Ok ( Some ( file) ) ;
128
+ }
125
129
}
130
+
131
+ Ok ( None )
126
132
}
127
133
128
134
impl Config {
You can’t perform that action at this time.
0 commit comments