1
0
mirror of https://github.com/nix-community/home-manager synced 2024-06-03 05:23:32 +02:00

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,65 +72,54 @@ 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 { (flatten [
${ "bar {"
concatStringsSep "\n" (indent (lists.subtractLists [ "" null ] (optionalString (id != null) "id ${id}")
(flatten [ (fontConfigStr fonts)
(optionalString (id != null) "id ${id}") (optionalString (mode != null) "mode ${mode}")
(fontConfigStr fonts) (optionalString (hiddenState != null) "hidden_state ${hiddenState}")
(optionalString (mode != null) "mode ${mode}") (optionalString (position != null) "position ${position}")
(optionalString (hiddenState != null) (optionalString (statusCommand != null)
"hidden_state ${hiddenState}") "status_command ${statusCommand}")
(optionalString (position != null) "position ${position}") "${moduleName}bar_command ${command}"
(optionalString (statusCommand != null) (optionalString (workspaceButtons != null)
"status_command ${statusCommand}") "workspace_buttons ${lib.hm.booleans.yesNo workspaceButtons}")
"${moduleName}bar_command ${command}" (optionalString (workspaceNumbers != null) "strip_workspace_numbers ${
(optionalString (workspaceButtons != null) lib.hm.booleans.yesNo (!workspaceNumbers)
"workspace_buttons ${lib.hm.booleans.yesNo workspaceButtons}") }")
(optionalString (workspaceNumbers != null) (optionalString (trayOutput != null) "tray_output ${trayOutput}")
"strip_workspace_numbers ${ (optionalString (trayPadding != null)
lib.hm.booleans.yesNo (!workspaceNumbers) "tray_padding ${toString trayPadding}")
}") (optionals colorsNotNull (indent (lists.subtractLists [ "" null ] [
(optionalString (trayOutput != null) "tray_output ${trayOutput}") "colors {"
(optionalString (trayPadding != null) (optionalString (colors.background != null)
"tray_padding ${toString trayPadding}") "background ${colors.background}")
(optionals colorsNotNull (indent (optionalString (colors.statusline != null)
(lists.subtractLists [ "" null ] [ "statusline ${colors.statusline}")
"colors {" (optionalString (colors.separator != null)
(optionalString (colors.background != null) "separator ${colors.separator}")
"background ${colors.background}") (optionalString (colors.focusedBackground != null)
(optionalString (colors.statusline != null) "focused_background ${colors.focusedBackground}")
"statusline ${colors.statusline}") (optionalString (colors.focusedStatusline != null)
(optionalString (colors.separator != null) "focused_statusline ${colors.focusedStatusline}")
"separator ${colors.separator}") (optionalString (colors.focusedSeparator != null)
(optionalString (colors.focusedBackground != null) "focused_separator ${colors.focusedSeparator}")
"focused_background ${colors.focusedBackground}") (optionalString (colors.focusedWorkspace != null)
(optionalString (colors.focusedStatusline != null) "focused_workspace ${barColorSetStr colors.focusedWorkspace}")
"focused_statusline ${colors.focusedStatusline}") (optionalString (colors.activeWorkspace != null)
(optionalString (colors.focusedSeparator != null) "active_workspace ${barColorSetStr colors.activeWorkspace}")
"focused_separator ${colors.focusedSeparator}") (optionalString (colors.inactiveWorkspace != null)
(optionalString (colors.focusedWorkspace != null) "inactive_workspace ${barColorSetStr colors.inactiveWorkspace}")
"focused_workspace ${ (optionalString (colors.urgentWorkspace != null)
barColorSetStr colors.focusedWorkspace "urgent_workspace ${barColorSetStr colors.urgentWorkspace}")
}") (optionalString (colors.bindingMode != null)
(optionalString (colors.activeWorkspace != null) "binding_mode ${barColorSetStr colors.bindingMode}")
"active_workspace ${barColorSetStr colors.activeWorkspace}") "}"
(optionalString (colors.inactiveWorkspace != null) ]) { }))
"inactive_workspace ${ extraConfig
barColorSetStr colors.inactiveWorkspace "}"
}") ])) { });
(optionalString (colors.urgentWorkspace != null)
"urgent_workspace ${barColorSetStr colors.urgentWorkspace}")
(optionalString (colors.bindingMode != null)
"binding_mode ${barColorSetStr colors.bindingMode}")
"}"
]) { }))
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