i3-sway: fix indentation of bar blocks (#3978)

The `indent` function unindents the first and last line by default, so
the `"bar {"` `"}"` wrapper should go inside the list.
This commit is contained in:
Naïm Favier 2023-05-11 14:04:29 +02:00 committed by GitHub
parent d991776527
commit 2f6a917ade
Failed to generate hash of commit
14 changed files with 61 additions and 72 deletions

View file

@ -72,31 +72,26 @@ rec {
, workspaceNumbers, command, statusCommand, colors, trayOutput, trayPadding , workspaceNumbers, command, statusCommand, colors, trayOutput, trayPadding
, extraConfig, ... }: , extraConfig, ... }:
let colorsNotNull = lib.filterAttrs (n: v: v != null) colors != { }; let colorsNotNull = lib.filterAttrs (n: v: v != null) colors != { };
in '' in concatMapStrings (x: x + "\n") (indent (lists.subtractLists [ "" null ]
bar {
${
concatStringsSep "\n" (indent (lists.subtractLists [ "" null ]
(flatten [ (flatten [
"bar {"
(optionalString (id != null) "id ${id}") (optionalString (id != null) "id ${id}")
(fontConfigStr fonts) (fontConfigStr fonts)
(optionalString (mode != null) "mode ${mode}") (optionalString (mode != null) "mode ${mode}")
(optionalString (hiddenState != null) (optionalString (hiddenState != null) "hidden_state ${hiddenState}")
"hidden_state ${hiddenState}")
(optionalString (position != null) "position ${position}") (optionalString (position != null) "position ${position}")
(optionalString (statusCommand != null) (optionalString (statusCommand != null)
"status_command ${statusCommand}") "status_command ${statusCommand}")
"${moduleName}bar_command ${command}" "${moduleName}bar_command ${command}"
(optionalString (workspaceButtons != null) (optionalString (workspaceButtons != null)
"workspace_buttons ${lib.hm.booleans.yesNo workspaceButtons}") "workspace_buttons ${lib.hm.booleans.yesNo workspaceButtons}")
(optionalString (workspaceNumbers != null) (optionalString (workspaceNumbers != null) "strip_workspace_numbers ${
"strip_workspace_numbers ${
lib.hm.booleans.yesNo (!workspaceNumbers) lib.hm.booleans.yesNo (!workspaceNumbers)
}") }")
(optionalString (trayOutput != null) "tray_output ${trayOutput}") (optionalString (trayOutput != null) "tray_output ${trayOutput}")
(optionalString (trayPadding != null) (optionalString (trayPadding != null)
"tray_padding ${toString trayPadding}") "tray_padding ${toString trayPadding}")
(optionals colorsNotNull (indent (optionals colorsNotNull (indent (lists.subtractLists [ "" null ] [
(lists.subtractLists [ "" null ] [
"colors {" "colors {"
(optionalString (colors.background != null) (optionalString (colors.background != null)
"background ${colors.background}") "background ${colors.background}")
@ -111,15 +106,11 @@ rec {
(optionalString (colors.focusedSeparator != null) (optionalString (colors.focusedSeparator != null)
"focused_separator ${colors.focusedSeparator}") "focused_separator ${colors.focusedSeparator}")
(optionalString (colors.focusedWorkspace != null) (optionalString (colors.focusedWorkspace != null)
"focused_workspace ${ "focused_workspace ${barColorSetStr colors.focusedWorkspace}")
barColorSetStr colors.focusedWorkspace
}")
(optionalString (colors.activeWorkspace != null) (optionalString (colors.activeWorkspace != null)
"active_workspace ${barColorSetStr colors.activeWorkspace}") "active_workspace ${barColorSetStr colors.activeWorkspace}")
(optionalString (colors.inactiveWorkspace != null) (optionalString (colors.inactiveWorkspace != null)
"inactive_workspace ${ "inactive_workspace ${barColorSetStr colors.inactiveWorkspace}")
barColorSetStr colors.inactiveWorkspace
}")
(optionalString (colors.urgentWorkspace != null) (optionalString (colors.urgentWorkspace != null)
"urgent_workspace ${barColorSetStr colors.urgentWorkspace}") "urgent_workspace ${barColorSetStr colors.urgentWorkspace}")
(optionalString (colors.bindingMode != null) (optionalString (colors.bindingMode != null)
@ -127,10 +118,8 @@ rec {
"}" "}"
]) { })) ]) { }))
extraConfig extraConfig
])) { }) "}"
} ])) { });
}
'';
gapsStr = with cfg.config.gaps; gapsStr = with cfg.config.gaps;
concatStringsSep "\n" (lists.subtractLists [ "" null ] [ concatStringsSep "\n" (lists.subtractLists [ "" null ] [