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
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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 ] [

View file

@ -94,6 +94,6 @@ bar {
inactive_workspace #333333 #222222 #888888 inactive_workspace #333333 #222222 #888888
urgent_workspace #2f343a #900000 #ffffff urgent_workspace #2f343a #900000 #ffffff
binding_mode #2f343a #900000 #ffffff binding_mode #2f343a #900000 #ffffff
} }
} }

View file

@ -91,6 +91,6 @@ bar {
inactive_workspace #333333 #222222 #888888 inactive_workspace #333333 #222222 #888888
urgent_workspace #2f343a #900000 #ffffff urgent_workspace #2f343a #900000 #ffffff
binding_mode #2f343a #900000 #ffffff binding_mode #2f343a #900000 #ffffff
} }
} }

View file

@ -91,6 +91,6 @@ bar {
inactive_workspace #333333 #222222 #888888 inactive_workspace #333333 #222222 #888888
urgent_workspace #2f343a #900000 #ffffff urgent_workspace #2f343a #900000 #ffffff
binding_mode #2f343a #900000 #ffffff binding_mode #2f343a #900000 #ffffff
} }
} }

View file

@ -92,6 +92,6 @@ bar {
inactive_workspace #333333 #222222 #888888 inactive_workspace #333333 #222222 #888888
urgent_workspace #2f343a #900000 #ffffff urgent_workspace #2f343a #900000 #ffffff
binding_mode #2f343a #900000 #ffffff binding_mode #2f343a #900000 #ffffff
} }
} }

View file

@ -90,6 +90,6 @@ bar {
inactive_workspace #333333 #222222 #888888 inactive_workspace #333333 #222222 #888888
urgent_workspace #2f343a #900000 #ffffff urgent_workspace #2f343a #900000 #ffffff
binding_mode #2f343a #900000 #ffffff binding_mode #2f343a #900000 #ffffff
} }
} }

View file

@ -91,7 +91,7 @@ bar {
inactive_workspace #333333 #222222 #888888 inactive_workspace #333333 #222222 #888888
urgent_workspace #2f343a #900000 #ffffff urgent_workspace #2f343a #900000 #ffffff
binding_mode #2f343a #900000 #ffffff binding_mode #2f343a #900000 #ffffff
} }
} }
workspace "1" output eDP workspace "1" output eDP

View file

@ -103,7 +103,7 @@ bar {
inactive_workspace #333333 #222222 #888888 inactive_workspace #333333 #222222 #888888
urgent_workspace #2f343a #900000 #ffffff urgent_workspace #2f343a #900000 #ffffff
binding_mode #2f343a #900000 #ffffff binding_mode #2f343a #900000 #ffffff
} }
} }
exec "/nix/store/00000000000000000000000000000000-dbus/bin/dbus-update-activation-environment --systemd DISPLAY WAYLAND_DISPLAY SWAYSOCK XDG_CURRENT_DESKTOP XDG_SESSION_TYPE NIXOS_OZONE_WL; systemctl --user start sway-session.target" exec "/nix/store/00000000000000000000000000000000-dbus/bin/dbus-update-activation-environment --systemd DISPLAY WAYLAND_DISPLAY SWAYSOCK XDG_CURRENT_DESKTOP XDG_SESSION_TYPE NIXOS_OZONE_WL; systemctl --user start sway-session.target"

View file

@ -102,7 +102,7 @@ bar {
inactive_workspace #333333 #222222 #888888 inactive_workspace #333333 #222222 #888888
urgent_workspace #2f343a #900000 #ffffff urgent_workspace #2f343a #900000 #ffffff
binding_mode #2f343a #900000 #ffffff binding_mode #2f343a #900000 #ffffff
} }
} }
exec "/nix/store/00000000000000000000000000000000-dbus/bin/dbus-update-activation-environment --systemd DISPLAY WAYLAND_DISPLAY SWAYSOCK XDG_CURRENT_DESKTOP XDG_SESSION_TYPE NIXOS_OZONE_WL; systemctl --user start sway-session.target" exec "/nix/store/00000000000000000000000000000000-dbus/bin/dbus-update-activation-environment --systemd DISPLAY WAYLAND_DISPLAY SWAYSOCK XDG_CURRENT_DESKTOP XDG_SESSION_TYPE NIXOS_OZONE_WL; systemctl --user start sway-session.target"

View file

@ -100,7 +100,7 @@ bar {
inactive_workspace #333333 #222222 #888888 inactive_workspace #333333 #222222 #888888
urgent_workspace #2f343a #900000 #ffffff urgent_workspace #2f343a #900000 #ffffff
binding_mode #2f343a #900000 #ffffff binding_mode #2f343a #900000 #ffffff
} }
} }
exec "/nix/store/00000000000000000000000000000000-dbus/bin/dbus-update-activation-environment --systemd DISPLAY WAYLAND_DISPLAY SWAYSOCK XDG_CURRENT_DESKTOP XDG_SESSION_TYPE NIXOS_OZONE_WL; systemctl --user start sway-session.target" exec "/nix/store/00000000000000000000000000000000-dbus/bin/dbus-update-activation-environment --systemd DISPLAY WAYLAND_DISPLAY SWAYSOCK XDG_CURRENT_DESKTOP XDG_SESSION_TYPE NIXOS_OZONE_WL; systemctl --user start sway-session.target"

View file

@ -112,7 +112,7 @@ bar {
inactive_workspace #333333 #222222 #888888 inactive_workspace #333333 #222222 #888888
urgent_workspace #2f343a #900000 #ffffff urgent_workspace #2f343a #900000 #ffffff
binding_mode #2f343a #900000 #ffffff binding_mode #2f343a #900000 #ffffff
} }
} }
exec "/nix/store/00000000000000000000000000000000-dbus/bin/dbus-update-activation-environment --systemd DISPLAY WAYLAND_DISPLAY SWAYSOCK XDG_CURRENT_DESKTOP XDG_SESSION_TYPE NIXOS_OZONE_WL; systemctl --user start sway-session.target" exec "/nix/store/00000000000000000000000000000000-dbus/bin/dbus-update-activation-environment --systemd DISPLAY WAYLAND_DISPLAY SWAYSOCK XDG_CURRENT_DESKTOP XDG_SESSION_TYPE NIXOS_OZONE_WL; systemctl --user start sway-session.target"

View file

@ -100,7 +100,7 @@ bar {
inactive_workspace #333333 #222222 #888888 inactive_workspace #333333 #222222 #888888
urgent_workspace #2f343a #900000 #ffffff urgent_workspace #2f343a #900000 #ffffff
binding_mode #2f343a #900000 #ffffff binding_mode #2f343a #900000 #ffffff
} }
} }
exec "/nix/store/00000000000000000000000000000000-dbus/bin/dbus-update-activation-environment --systemd DISPLAY WAYLAND_DISPLAY SWAYSOCK XDG_CURRENT_DESKTOP XDG_SESSION_TYPE NIXOS_OZONE_WL; systemctl --user start sway-session.target" exec "/nix/store/00000000000000000000000000000000-dbus/bin/dbus-update-activation-environment --systemd DISPLAY WAYLAND_DISPLAY SWAYSOCK XDG_CURRENT_DESKTOP XDG_SESSION_TYPE NIXOS_OZONE_WL; systemctl --user start sway-session.target"

View file

@ -99,7 +99,7 @@ bar {
inactive_workspace #333333 #222222 #888888 inactive_workspace #333333 #222222 #888888
urgent_workspace #2f343a #900000 #ffffff urgent_workspace #2f343a #900000 #ffffff
binding_mode #2f343a #900000 #ffffff binding_mode #2f343a #900000 #ffffff
} }
} }
exec "/nix/store/00000000000000000000000000000000-dbus/bin/dbus-update-activation-environment --systemd DISPLAY WAYLAND_DISPLAY SWAYSOCK XDG_CURRENT_DESKTOP XDG_SESSION_TYPE NIXOS_OZONE_WL; systemctl --user start sway-session.target" exec "/nix/store/00000000000000000000000000000000-dbus/bin/dbus-update-activation-environment --systemd DISPLAY WAYLAND_DISPLAY SWAYSOCK XDG_CURRENT_DESKTOP XDG_SESSION_TYPE NIXOS_OZONE_WL; systemctl --user start sway-session.target"

View file

@ -100,7 +100,7 @@ bar {
inactive_workspace #333333 #222222 #888888 inactive_workspace #333333 #222222 #888888
urgent_workspace #2f343a #900000 #ffffff urgent_workspace #2f343a #900000 #ffffff
binding_mode #2f343a #900000 #ffffff binding_mode #2f343a #900000 #ffffff
} }
} }
workspace "1" output eDP workspace "1" output eDP