@@ -253,10 +253,9 @@ fn migrate_config_file(
253253 Ok ( ( ) )
254254}
255255
256- pub fn create_default_config ( cfg_path : & PathBuf ) -> Result < & ' static str , Box < dyn Error + ' static > > {
256+ pub fn create_default_config ( cfg_path : & PathBuf ) -> Result < String , Box < dyn Error + ' static > > {
257257 // TODO: maybe we should dump the config from the default values of the struct?
258- let default_config = r#"
259- version = "1.1.14"
258+ let default_config = format ! ( r#"version = "{VERSION}"
260259
261260# [format]
262261# Deduplicate icons if enable.
@@ -268,36 +267,36 @@ version = "1.1.14"
268267# max_clients = 30 # you should not need this
269268
270269# available formatter:
271- # {counter_sup} - superscripted count of clients on the workspace, and simple {counter}, {delim}
272- # {icon}, {client}
270+ # {{ counter_sup}} - superscripted count of clients on the workspace, and simple {{ counter}} , {{ delim} }
271+ # {{ icon}} , {{ client} }
273272# workspace formatter
274- # workspace = "{id}:{ delim}{ clients}" # {id}, {delim} and {clients} are supported
275- # workspace_empty = "{id}" # {id}, {delim} and {clients} are supported
273+ # workspace = "{{ id}}:{{ delim}}{{ clients}} " # {{ id}} , {{ delim}} and {{ clients} } are supported
274+ # workspace_empty = "{{ id}} " # {{ id}} , {{ delim}} and {{ clients} } are supported
276275# client formatter
277- # client = "{icon}"
278- # client_active = "*{icon}*"
276+ # client = "{{ icon} }"
277+ # client_active = "*{{ icon} }*"
279278
280279# deduplicate client formatter
281- # client_fullscreen = "[{icon}]"
282- # client_dup = "{client}{ counter_sup}"
283- # client_dup_fullscreen = "[{icon}]{ delim}{ icon}{ counter_unfocused}"
284- # client_dup_active = "*{icon}*{ delim}{ icon}{ counter_unfocused}"
280+ # client_fullscreen = "[{{ icon} }]"
281+ # client_dup = "{{ client}}{{ counter_sup} }"
282+ # client_dup_fullscreen = "[{{ icon}}]{{ delim}}{{ icon}}{{ counter_unfocused} }"
283+ # client_dup_active = "*{{ icon}}*{{ delim}}{{ icon}}{{ counter_unfocused} }"
285284
286285[class]
287286# Add your icons mapping
288287# use double quote the key and the value
289288# take class name from 'hyprctl clients'
290- "DEFAULT" = " {class}: {title}"
289+ "DEFAULT" = " {{ class}} : {{ title} }"
291290"(?i)Kitty" = "term"
292291"[Ff]irefox" = "browser"
293292"(?i)waydroid.*" = "droid"
294293
295294[class_active]
296- DEFAULT = "*{icon}*"
297- "(?i)ExampleOneTerm" = "<span foreground='red'>{icon}</span>"
295+ DEFAULT = "*{{ icon} }*"
296+ "(?i)ExampleOneTerm" = "<span foreground='red'>{{ icon} }</span>"
298297
299298# [initial_class]
300- # "DEFAULT" = " {class}: {title}"
299+ # "DEFAULT" = " {{ class}} : {{ title} }"
301300# "(?i)Kitty" = "term"
302301
303302# [initial_class_active]
@@ -306,10 +305,10 @@ DEFAULT = "*{icon}*"
306305[title_in_class."(?i)kitty"]
307306"(?i)neomutt" = "neomutt"
308307# regex captures support is supported
309- # "emerge: (.+?/.+?)-.*" = "{match1}"
308+ # "emerge: (.+?/.+?)-.*" = "{{ match1} }"
310309
311310[title_in_class_active."(?i)firefox"]
312- "(?i)twitch" = "<span color='purple'>{icon}</span>"
311+ "(?i)twitch" = "<span color='purple'>{{ icon} }</span>"
313312
314313# [title_in_initial_class."(?i)kitty"]
315314# "(?i)neomutt" = "neomutt"
@@ -350,16 +349,14 @@ aProgram = "^$" # will match null title for aProgram
3503499 = "nine"
35135010 = "ten"
352351
353- "#
354- . trim ( ) ;
352+ "# ) ;
355353
356354 let mut config_file = File :: create ( cfg_path) ?;
357- write ! ( & mut config_file, "{default_config}" ) ?;
355+ write ! ( & mut config_file, "{}" , default_config . trim ( ) ) ?;
358356 println ! ( "Default config created in {cfg_path:?}" ) ;
359357
360- Ok ( default_config)
358+ Ok ( default_config. trim ( ) . to_string ( ) )
361359}
362-
363360/// Creates a Regex from a given pattern and logs an error if the pattern is invalid.
364361///
365362/// # Arguments
0 commit comments