2024-06-04 22:11:19 +03:00
|
|
|
{ lib, config, ... }:
|
|
|
|
let
|
|
|
|
widgets = (import ../modules/widgets { inherit lib; });
|
|
|
|
panelToLayout = panel:
|
|
|
|
let
|
|
|
|
inherit (widgets.lib) addWidgetStmts stringIfNotNull;
|
2024-07-12 20:28:26 +03:00
|
|
|
inherit (lib) boolToString;
|
2024-06-04 22:11:19 +03:00
|
|
|
inherit (builtins) toString;
|
|
|
|
|
|
|
|
plasma6OnlyCmd = cmd: ''
|
|
|
|
if (isPlasma6) {
|
|
|
|
${cmd}
|
|
|
|
}
|
|
|
|
'';
|
|
|
|
in
|
|
|
|
''
|
2024-07-12 20:28:26 +03:00
|
|
|
${if (panel.screen == "all") then "for (screenID = 0; screenID < screenCount; screenID++)"
|
|
|
|
else if (builtins.isList panel.screen) then "for (var screenID in [${builtins.concatStringsSep "," (map builtins.toString panel.screen)}])"
|
|
|
|
else ""}
|
2024-06-04 22:11:19 +03:00
|
|
|
{
|
|
|
|
const panel = new Panel();
|
|
|
|
panel.height = ${toString panel.height};
|
|
|
|
panel.floating = ${boolToString panel.floating};
|
|
|
|
${stringIfNotNull panel.alignment ''panel.alignment = "${panel.alignment}";''}
|
|
|
|
${stringIfNotNull panel.hiding ''panel.hiding = "${panel.hiding}";''}
|
|
|
|
${stringIfNotNull panel.location ''panel.location = "${panel.location}";''}
|
|
|
|
${stringIfNotNull panel.lengthMode (plasma6OnlyCmd ''panel.lengthMode = "${panel.lengthMode}";'')}
|
|
|
|
${stringIfNotNull panel.maxLength "panel.maximumLength = ${toString panel.maxLength};"}
|
|
|
|
${stringIfNotNull panel.minLength "panel.minimumLength = ${toString panel.minLength};"}
|
|
|
|
${stringIfNotNull panel.offset "panel.offset = ${toString panel.offset};"}
|
2024-07-12 20:28:26 +03:00
|
|
|
${stringIfNotNull panel.screen ''panel.writeConfig("lastScreen[$i]", ${if ((panel.screen == "all") || (builtins.isList panel.screen)) then "screenID" else toString panel.screen});''}
|
2024-06-04 22:11:19 +03:00
|
|
|
|
|
|
|
${addWidgetStmts "panel" "panelWidgets" panel.widgets}
|
|
|
|
${stringIfNotNull panel.extraSettings panel.extraSettings}
|
|
|
|
}
|
|
|
|
'';
|
|
|
|
in
|
|
|
|
''
|
|
|
|
// Removes all existing panels
|
|
|
|
panels().forEach((panel) => panel.remove());
|
|
|
|
|
|
|
|
const isPlasma6 = applicationVersion.split(".")[0] == 6;
|
|
|
|
|
|
|
|
// Adds the panels
|
|
|
|
${lib.concatMapStringsSep "\n" panelToLayout config.programs.plasma.panels}
|
|
|
|
''
|