2019-09-04 04:30:44 +02:00
|
|
|
{ cfg, lib, moduleName }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
rec {
|
|
|
|
criteriaStr = criteria:
|
2021-08-22 02:41:06 +02:00
|
|
|
let
|
|
|
|
toCriteria = k: v:
|
|
|
|
if builtins.isBool v then
|
|
|
|
(if v then "${k}" else "")
|
|
|
|
else
|
|
|
|
''${k}="${v}"'';
|
|
|
|
in "[${concatStringsSep " " (mapAttrsToList toCriteria criteria)}]";
|
2019-09-04 04:30:44 +02:00
|
|
|
|
2021-05-17 06:54:53 +02:00
|
|
|
keybindingDefaultWorkspace = filterAttrs (n: v:
|
|
|
|
cfg.config.defaultWorkspace != null && v == cfg.config.defaultWorkspace)
|
|
|
|
cfg.config.keybindings;
|
|
|
|
|
|
|
|
keybindingsRest = filterAttrs (n: v:
|
|
|
|
cfg.config.defaultWorkspace == null || v != cfg.config.defaultWorkspace)
|
|
|
|
cfg.config.keybindings;
|
|
|
|
|
2020-05-30 13:58:05 +02:00
|
|
|
keybindingsStr = { keybindings, bindsymArgs ? "" }:
|
2019-09-04 04:30:44 +02:00
|
|
|
concatStringsSep "\n" (mapAttrsToList (keycomb: action:
|
2020-04-13 15:53:22 +02:00
|
|
|
optionalString (action != null) "bindsym ${
|
2020-05-30 13:58:05 +02:00
|
|
|
lib.optionalString (bindsymArgs != "") "${bindsymArgs} "
|
2020-04-13 15:53:22 +02:00
|
|
|
}${keycomb} ${action}") keybindings);
|
2019-09-04 04:30:44 +02:00
|
|
|
|
|
|
|
keycodebindingsStr = keycodebindings:
|
|
|
|
concatStringsSep "\n" (mapAttrsToList (keycomb: action:
|
|
|
|
optionalString (action != null) "bindcode ${keycomb} ${action}")
|
|
|
|
keycodebindings);
|
|
|
|
|
|
|
|
colorSetStr = c:
|
|
|
|
concatStringsSep " " [
|
|
|
|
c.border
|
|
|
|
c.background
|
|
|
|
c.text
|
|
|
|
c.indicator
|
|
|
|
c.childBorder
|
|
|
|
];
|
|
|
|
barColorSetStr = c: concatStringsSep " " [ c.border c.background c.text ];
|
|
|
|
|
2021-07-15 15:09:54 +02:00
|
|
|
modeStr = bindkeysToCode: name: keybindings: ''
|
2019-09-04 04:30:44 +02:00
|
|
|
mode "${name}" {
|
2021-07-15 15:09:54 +02:00
|
|
|
${keybindingsStr {
|
|
|
|
inherit keybindings;
|
|
|
|
bindsymArgs = lib.optionalString bindkeysToCode "--to-code";
|
|
|
|
}}
|
2019-09-04 04:30:44 +02:00
|
|
|
}
|
|
|
|
'';
|
|
|
|
|
|
|
|
assignStr = workspace: criteria:
|
|
|
|
concatStringsSep "\n"
|
|
|
|
(map (c: "assign ${criteriaStr c} ${workspace}") criteria);
|
|
|
|
|
2021-05-04 05:54:35 +02:00
|
|
|
fontConfigStr = let
|
|
|
|
toFontStr = { names, style ? "", size ? "" }:
|
2021-12-27 09:03:18 +01:00
|
|
|
optionalString (names != [ ]) concatStringsSep " "
|
|
|
|
(remove "" [ "font" "pango:${concatStringsSep ", " names}" style size ]);
|
2021-05-04 05:54:35 +02:00
|
|
|
in fontCfg:
|
|
|
|
if isList fontCfg then
|
|
|
|
toFontStr { names = fontCfg; }
|
|
|
|
else
|
|
|
|
toFontStr {
|
|
|
|
inherit (fontCfg) names style;
|
|
|
|
size = toString fontCfg.size;
|
|
|
|
};
|
|
|
|
|
2019-09-04 04:30:44 +02:00
|
|
|
barStr = { id, fonts, mode, hiddenState, position, workspaceButtons
|
|
|
|
, workspaceNumbers, command, statusCommand, colors, trayOutput, extraConfig
|
2020-07-13 13:31:55 +02:00
|
|
|
, ... }:
|
|
|
|
let colorsNotNull = lib.filterAttrs (n: v: v != null) colors != { };
|
|
|
|
in ''
|
2019-09-04 04:30:44 +02:00
|
|
|
bar {
|
|
|
|
${optionalString (id != null) "id ${id}"}
|
2021-05-04 05:54:35 +02:00
|
|
|
${fontConfigStr fonts}
|
2020-07-13 13:31:55 +02:00
|
|
|
${optionalString (mode != null) "mode ${mode}"}
|
|
|
|
${optionalString (hiddenState != null) "hidden_state ${hiddenState}"}
|
|
|
|
${optionalString (position != null) "position ${position}"}
|
2020-05-11 19:41:44 +02:00
|
|
|
${
|
|
|
|
optionalString (statusCommand != null)
|
|
|
|
"status_command ${statusCommand}"
|
|
|
|
}
|
2019-09-04 04:30:44 +02:00
|
|
|
${moduleName}bar_command ${command}
|
2020-07-13 13:31:55 +02:00
|
|
|
${
|
|
|
|
optionalString (workspaceButtons != null)
|
|
|
|
"workspace_buttons ${if workspaceButtons then "yes" else "no"}"
|
|
|
|
}
|
|
|
|
${
|
|
|
|
optionalString (workspaceNumbers != null)
|
|
|
|
"strip_workspace_numbers ${if !workspaceNumbers then "yes" else "no"}"
|
2019-09-04 04:30:44 +02:00
|
|
|
}
|
2020-07-13 13:31:55 +02:00
|
|
|
${optionalString (trayOutput != null) "tray_output ${trayOutput}"}
|
|
|
|
${optionalString colorsNotNull "colors {"}
|
|
|
|
${
|
|
|
|
optionalString (colors.background != null)
|
|
|
|
"background ${colors.background}"
|
|
|
|
}
|
|
|
|
${
|
|
|
|
optionalString (colors.statusline != null)
|
|
|
|
"statusline ${colors.statusline}"
|
|
|
|
}
|
|
|
|
${
|
|
|
|
optionalString (colors.separator != null)
|
|
|
|
"separator ${colors.separator}"
|
|
|
|
}
|
2021-06-23 04:56:41 +02:00
|
|
|
${
|
|
|
|
optionalString (colors.focusedBackground != null)
|
|
|
|
"focused_background ${colors.focusedBackground}"
|
|
|
|
}
|
|
|
|
${
|
|
|
|
optionalString (colors.focusedStatusline != null)
|
|
|
|
"focused_statusline ${colors.focusedStatusline}"
|
|
|
|
}
|
|
|
|
${
|
|
|
|
optionalString (colors.focusedSeparator != null)
|
|
|
|
"focused_separator ${colors.focusedSeparator}"
|
|
|
|
}
|
2020-07-13 13:31:55 +02:00
|
|
|
${
|
|
|
|
optionalString (colors.focusedWorkspace != null)
|
|
|
|
"focused_workspace ${barColorSetStr colors.focusedWorkspace}"
|
|
|
|
}
|
|
|
|
${
|
|
|
|
optionalString (colors.activeWorkspace != null)
|
|
|
|
"active_workspace ${barColorSetStr colors.activeWorkspace}"
|
|
|
|
}
|
|
|
|
${
|
|
|
|
optionalString (colors.inactiveWorkspace != null)
|
|
|
|
"inactive_workspace ${barColorSetStr colors.inactiveWorkspace}"
|
|
|
|
}
|
|
|
|
${
|
|
|
|
optionalString (colors.urgentWorkspace != null)
|
|
|
|
"urgent_workspace ${barColorSetStr colors.urgentWorkspace}"
|
|
|
|
}
|
|
|
|
${
|
|
|
|
optionalString (colors.bindingMode != null)
|
|
|
|
"binding_mode ${barColorSetStr colors.bindingMode}"
|
|
|
|
}
|
|
|
|
${optionalString colorsNotNull "}"}
|
2019-09-04 04:30:44 +02:00
|
|
|
${extraConfig}
|
|
|
|
}
|
|
|
|
'';
|
|
|
|
|
|
|
|
gapsStr = with cfg.config.gaps; ''
|
|
|
|
${optionalString (inner != null) "gaps inner ${toString inner}"}
|
|
|
|
${optionalString (outer != null) "gaps outer ${toString outer}"}
|
|
|
|
${optionalString (horizontal != null)
|
|
|
|
"gaps horizontal ${toString horizontal}"}
|
|
|
|
${optionalString (vertical != null) "gaps vertical ${toString vertical}"}
|
|
|
|
${optionalString (top != null) "gaps top ${toString top}"}
|
|
|
|
${optionalString (bottom != null) "gaps bottom ${toString bottom}"}
|
|
|
|
${optionalString (left != null) "gaps left ${toString left}"}
|
|
|
|
${optionalString (right != null) "gaps right ${toString right}"}
|
|
|
|
|
|
|
|
${optionalString smartGaps "smart_gaps on"}
|
|
|
|
${optionalString (smartBorders != "off") "smart_borders ${smartBorders}"}
|
|
|
|
'';
|
|
|
|
|
2021-04-28 21:52:31 +02:00
|
|
|
windowBorderString = window: floating:
|
|
|
|
let
|
|
|
|
titlebarString = { titlebar, border, ... }:
|
|
|
|
"${if titlebar then "normal" else "pixel"} ${toString border}";
|
|
|
|
in concatStringsSep "\n" [
|
|
|
|
"default_border ${titlebarString window}"
|
|
|
|
"default_floating_border ${titlebarString floating}"
|
|
|
|
];
|
|
|
|
|
2019-09-04 04:30:44 +02:00
|
|
|
floatingCriteriaStr = criteria:
|
|
|
|
"for_window ${criteriaStr criteria} floating enable";
|
|
|
|
windowCommandsStr = { command, criteria, ... }:
|
|
|
|
"for_window ${criteriaStr criteria} ${command}";
|
2021-06-03 02:03:20 +02:00
|
|
|
workspaceOutputStr = item:
|
|
|
|
''workspace "${item.workspace}" output ${item.output}'';
|
2019-09-04 04:30:44 +02:00
|
|
|
}
|