From 5c97fe8af2a2e561f14195ed357d8c451fdbff4c Mon Sep 17 00:00:00 2001 From: Heitor Augusto Date: Sun, 25 Aug 2024 00:27:19 -0300 Subject: [PATCH] Add panelspacer widget-specific options (#341) --- modules/widgets/default.nix | 1 + modules/widgets/panel-spacer.nix | 66 ++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 modules/widgets/panel-spacer.nix diff --git a/modules/widgets/default.nix b/modules/widgets/default.nix index 68b46f6b..5d49a642 100644 --- a/modules/widgets/default.nix +++ b/modules/widgets/default.nix @@ -14,6 +14,7 @@ let ./kicker.nix ./kickerdash.nix ./kickoff.nix + ./panel-spacer.nix ./plasma-panel-colorizer.nix ./plasmusic-toolbar.nix ./system-monitor.nix diff --git a/modules/widgets/panel-spacer.nix b/modules/widgets/panel-spacer.nix new file mode 100644 index 00000000..8d08e424 --- /dev/null +++ b/modules/widgets/panel-spacer.nix @@ -0,0 +1,66 @@ +{ lib, ... }: +let + inherit (import ./lib.nix { inherit lib; }) configValueType; + inherit (import ./default.nix { inherit lib; }) positionType sizeType; + + mkBoolOption = description: lib.mkOption { + type = with lib.types; nullOr bool; + default = null; + example = true; + inherit description; + }; +in +{ + panelSpacer = { + opts = { + position = lib.mkOption { + type = positionType; + example = { horizontal = 100; vertical = 300; }; + description = "The position of the widget. (Only for desktop widget)"; + }; + size = lib.mkOption { + type = sizeType; + example = { width = 500; height = 50; }; + description = "The size of the widget. (Only for desktop widget)"; + }; + expanding = mkBoolOption "Whether the spacer should expand to fill the available space."; + length = lib.mkOption { + type = lib.types.nullOr lib.types.int; + default = null; + example = 50; + description = '' + The length of the spacer. + If expanding is set to true, this value is ignored. + ''; + }; + settings = lib.mkOption { + type = configValueType; + default = null; + example = { + General = { + expanding = true; + }; + }; + description = '' + Extra configuration for the widget + ''; + apply = settings: if settings == null then {} else settings; + }; + }; + + convert = + { position + , size + , expanding + , length + , settings + }: { + name = "org.kde.plasma.panelspacer"; + config = lib.recursiveUpdate { + General = lib.filterAttrs (_: v: v != null) { + inherit expanding length; + }; + } settings; + }; + }; +}