From 3d65009effd77cb0d6e7520b68b039836a7606cf Mon Sep 17 00:00:00 2001 From: Matthieu Coudron <886074+teto@users.noreply.github.com> Date: Sun, 9 Jun 2024 13:14:04 +0200 Subject: [PATCH] waybar: remove modules-* from defaults Some prefer to handle modules-* imperatively for more flexibility, e.g., via waybar "includes" (https://github.com/Alexays/Waybar/wiki/Configuration). Current HM defaults modules-* to `[]` instead of null for most other settings, so they get written to ~/.config/waybar/config even though no explicit configuration has been made. And they take precedence over the imperative ones because of how waybar's includes work: ==== Paths to additional configuration files. Each file can contain a single object with any of the bar configuration options. In case of duplicate options, the first defined value takes precedence, i.e. including file -> first included file -> etc. Nested includes are permitted, but make sure to avoid circular imports. For a multi-bar config, the include directive affects only current bar configuration object. ==== --- modules/programs/waybar.nix | 12 ++++++------ .../programs/waybar/deprecated-modules-option.nix | 2 -- .../programs/waybar/settings-complex-expected.json | 1 - 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/modules/programs/waybar.nix b/modules/programs/waybar.nix index 9925effc..72d24732 100644 --- a/modules/programs/waybar.nix +++ b/modules/programs/waybar.nix @@ -69,8 +69,8 @@ let }; modules-left = mkOption { - type = listOf str; - default = [ ]; + type = nullOr (listOf str); + default = null; description = "Modules that will be displayed on the left."; example = literalExpression '' [ "sway/workspaces" "sway/mode" "wlr/taskbar" ] @@ -78,8 +78,8 @@ let }; modules-center = mkOption { - type = listOf str; - default = [ ]; + type = nullOr (listOf str); + default = null; description = "Modules that will be displayed in the center."; example = literalExpression '' [ "sway/window" ] @@ -87,8 +87,8 @@ let }; modules-right = mkOption { - type = listOf str; - default = [ ]; + type = nullOr (listOf str); + default = null; description = "Modules that will be displayed on the right."; example = literalExpression '' [ "mpd" "custom/mymodule#with-css-id" "temperature" ] diff --git a/tests/modules/programs/waybar/deprecated-modules-option.nix b/tests/modules/programs/waybar/deprecated-modules-option.nix index b4d730af..09f163b0 100644 --- a/tests/modules/programs/waybar/deprecated-modules-option.nix +++ b/tests/modules/programs/waybar/deprecated-modules-option.nix @@ -31,8 +31,6 @@ with lib; "modules-center": [ "test" ], - "modules-left": [], - "modules-right": [], "test": {} } ] diff --git a/tests/modules/programs/waybar/settings-complex-expected.json b/tests/modules/programs/waybar/settings-complex-expected.json index 87e4f690..e7ec8b4a 100644 --- a/tests/modules/programs/waybar/settings-complex-expected.json +++ b/tests/modules/programs/waybar/settings-complex-expected.json @@ -51,7 +51,6 @@ "modules-left": [ "sway/mode" ], - "modules-right": [], "output": [ "!DP-1" ],