11mod common;
2+ pub mod default;
23mod r#impl;
34mod layout;
45mod truncate;
@@ -232,14 +233,11 @@ impl Default for BarPosition {
232233
233234#[ derive( Debug , Default , Deserialize , Copy , Clone , PartialEq , Eq ) ]
234235#[ cfg_attr( feature = "schema" , derive( JsonSchema ) ) ]
236+ #[ serde( default ) ]
235237pub struct MarginConfig {
236- #[ serde( default ) ]
237238 pub bottom : i32 ,
238- #[ serde( default ) ]
239239 pub left : i32 ,
240- #[ serde( default ) ]
241240 pub right : i32 ,
242- #[ serde( default ) ]
243241 pub top : i32 ,
244242}
245243
@@ -251,6 +249,7 @@ pub struct MarginConfig {
251249///
252250#[ derive( Debug , Deserialize , Clone ) ]
253251#[ cfg_attr( feature = "schema" , derive( JsonSchema ) ) ]
252+ #[ serde( default ) ]
254253pub struct BarConfig {
255254 /// A unique identifier for the bar, used for controlling it over IPC.
256255 /// If not set, uses a generated integer suffix.
@@ -263,14 +262,12 @@ pub struct BarConfig {
263262 /// **Valid options**: `top`, `bottom`, `left`, `right`
264263 /// <br>
265264 /// **Default**: `bottom`
266- #[ serde( default ) ]
267265 pub position : BarPosition ,
268266
269267 /// Whether to anchor the bar to the edges of the screen.
270268 /// Setting to false centers the bar.
271269 ///
272270 /// **Default**: `true`
273- #[ serde( default = "default_true" ) ]
274271 pub anchor_to_edges : bool ,
275272
276273 /// The bar's height in pixels.
@@ -280,7 +277,6 @@ pub struct BarConfig {
280277 /// it will automatically expand to fit.
281278 ///
282279 /// **Default**: `42`
283- #[ serde( default = "default_bar_height" ) ]
284280 pub height : i32 ,
285281
286282 /// The margin to use on each side of the bar, in pixels.
@@ -300,7 +296,6 @@ pub struct BarConfig {
300296 /// margin.right = 10
301297 /// }
302298 /// ```
303- #[ serde( default ) ]
304299 pub margin : MarginConfig ,
305300
306301 /// The layer-shell layer to place the bar on.
@@ -317,10 +312,7 @@ pub struct BarConfig {
317312 /// **Valid options**: `background`, `bottom`, `top`, `overlay`
318313 /// <br>
319314 /// **Default**: `top`
320- #[ serde(
321- default = "default_layer" ,
322- deserialize_with = "r#impl::deserialize_layer"
323- ) ]
315+ #[ serde( deserialize_with = "r#impl::deserialize_layer" ) ]
324316 #[ cfg_attr( feature = "schema" , schemars( schema_with = "r#impl::schema_layer" ) ) ]
325317 pub layer : gtk_layer_shell:: Layer ,
326318
@@ -330,14 +322,12 @@ pub struct BarConfig {
330322 /// as the bar, causing them to shift.
331323 ///
332324 /// **Default**: `true` unless `start_hidden` is set.
333- #[ serde( default ) ]
334325 pub exclusive_zone : Option < bool > ,
335326
336327 /// The size of the gap in pixels
337328 /// between the bar and the popup window.
338329 ///
339330 /// **Default**: `5`
340- #[ serde( default = "default_popup_gap" ) ]
341331 pub popup_gap : i32 ,
342332
343333 /// Whether to enable autohide behaviour on the popup.
@@ -346,20 +336,17 @@ pub struct BarConfig {
346336 /// On some compositors, this may also aggressively steal mouse/keyboard focus.
347337 ///
348338 /// **Default**: `false`
349- #[ serde( default ) ]
350339 pub popup_autohide : bool ,
351340
352341 /// Whether the bar should be hidden when Ironbar starts.
353342 ///
354343 /// **Default**: `false`, unless `autohide` is set.
355- #[ serde( default ) ]
356344 pub start_hidden : Option < bool > ,
357345
358346 /// The duration in milliseconds before the bar is hidden after the cursor leaves.
359347 /// Leave unset to disable auto-hide behaviour.
360348 ///
361349 /// **Default**: `null`
362- #[ serde( default ) ]
363350 pub autohide : Option < u64 > ,
364351
365352 /// An array of modules to append to the start of the bar.
@@ -404,9 +391,9 @@ impl Default for BarConfig {
404391 position : BarPosition :: default ( ) ,
405392 margin : MarginConfig :: default ( ) ,
406393 name : None ,
407- layer : default_layer ( ) ,
394+ layer : gtk_layer_shell :: Layer :: Top ,
408395 exclusive_zone : None ,
409- height : default_bar_height ( ) ,
396+ height : 42 ,
410397 start_hidden : None ,
411398 autohide : None ,
412399 #[ cfg( feature = "label" ) ]
@@ -417,15 +404,16 @@ impl Default for BarConfig {
417404 start : None ,
418405 center,
419406 end,
420- anchor_to_edges : default_true ( ) ,
421- popup_gap : default_popup_gap ( ) ,
407+ anchor_to_edges : true ,
408+ popup_gap : 5 ,
422409 popup_autohide : false ,
423410 }
424411 }
425412}
426413
427414#[ derive( Debug , Deserialize , Clone , Default ) ]
428415#[ cfg_attr( feature = "schema" , derive( JsonSchema ) ) ]
416+ #[ serde( default ) ]
429417pub struct Config {
430418 /// A map of [ironvar](ironvar) keys and values
431419 /// to initialize Ironbar with on startup.
@@ -479,30 +467,5 @@ pub struct Config {
479467 /// overriding the app's default icon.
480468 ///
481469 /// **Default**: `{}`
482- #[ serde( default ) ]
483470 pub icon_overrides : HashMap < String , String > ,
484471}
485-
486- const fn default_layer ( ) -> gtk_layer_shell:: Layer {
487- gtk_layer_shell:: Layer :: Top
488- }
489-
490- const fn default_bar_height ( ) -> i32 {
491- 42
492- }
493-
494- const fn default_popup_gap ( ) -> i32 {
495- 5
496- }
497-
498- pub const fn default_false ( ) -> bool {
499- false
500- }
501-
502- pub const fn default_true ( ) -> bool {
503- true
504- }
505-
506- pub fn default_launch_command ( ) -> String {
507- String :: from ( "gtk-launch {app_name}" )
508- }
0 commit comments