diff --git a/modules/modules.nix b/modules/modules.nix index cbafdd75b..1322e8a7d 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -265,6 +265,7 @@ let ./programs/starship.nix ./programs/streamlink.nix ./programs/superfile.nix + ./programs/sway-easyfocus.nix ./programs/swayimg.nix ./programs/swaylock.nix ./programs/swayr.nix diff --git a/modules/programs/sway-easyfocus.nix b/modules/programs/sway-easyfocus.nix new file mode 100644 index 000000000..236c5e4a7 --- /dev/null +++ b/modules/programs/sway-easyfocus.nix @@ -0,0 +1,51 @@ +{ + lib, + pkgs, + config, + ... +}: +let + inherit (lib) + mkIf + mkEnableOption + mkPackageOption + mkOption + ; + + cfg = config.programs.sway-easyfocus; + formatter = pkgs.formats.yaml { }; +in +{ + meta.maintainers = with lib.hm.maintainers; [ aguirre-matteo ]; + + options.programs.sway-easyfocus = { + enable = mkEnableOption "sway-easyfocus"; + package = mkPackageOption pkgs "sway-easyfocus" { nullable = true; }; + settings = mkOption { + type = formatter.type; + default = { }; + example = { + chars = "fjghdkslaemuvitywoqpcbnxz"; + window_background_color = "d1f21"; + window_background_opacity = 0.2; + focused_background_color = "285577"; + focused_background_opacity = 1.0; + focused_text_color = "ffffff"; + font_family = "monospace"; + font_weight = "bold"; + font_size = "medium"; + }; + description = '' + Configuration settings for sway-easyfocus. All available options can be found here: + . + ''; + }; + }; + + config = mkIf cfg.enable { + home.packages = mkIf (cfg.package != null) [ cfg.package ]; + xdg.configFile."sway-easyfocus/config.yaml" = mkIf (cfg.settings != { }) { + source = formatter.generate "sway-easyfocus-config.yaml" cfg.settings; + }; + }; +} diff --git a/tests/default.nix b/tests/default.nix index bcb2749cf..fc90f236a 100644 --- a/tests/default.nix +++ b/tests/default.nix @@ -392,6 +392,7 @@ import nmtSrc { ./modules/programs/rbw ./modules/programs/rofi ./modules/programs/rofi-pass + ./modules/programs/sway-easyfocus ./modules/programs/swayimg ./modules/programs/swaylock ./modules/programs/swayr diff --git a/tests/modules/programs/sway-easyfocus/config.yaml b/tests/modules/programs/sway-easyfocus/config.yaml new file mode 100644 index 000000000..67c78febe --- /dev/null +++ b/tests/modules/programs/sway-easyfocus/config.yaml @@ -0,0 +1,9 @@ +chars: fjghdkslaemuvitywoqpcbnxz +focused_background_color: '285577' +focused_background_opacity: 1.0 +focused_text_color: ffffff +font_family: monospace +font_size: medium +font_weight: bold +window_background_color: d1f21 +window_background_opacity: 0.2 diff --git a/tests/modules/programs/sway-easyfocus/default.nix b/tests/modules/programs/sway-easyfocus/default.nix new file mode 100644 index 000000000..3474e8a03 --- /dev/null +++ b/tests/modules/programs/sway-easyfocus/default.nix @@ -0,0 +1 @@ +{ sway-easyfocus-example-config = ./example-config.nix; } diff --git a/tests/modules/programs/sway-easyfocus/example-config.nix b/tests/modules/programs/sway-easyfocus/example-config.nix new file mode 100644 index 000000000..9e29c8b4c --- /dev/null +++ b/tests/modules/programs/sway-easyfocus/example-config.nix @@ -0,0 +1,22 @@ +{ + programs.sway-easyfocus = { + enable = true; + settings = { + chars = "fjghdkslaemuvitywoqpcbnxz"; + window_background_color = "d1f21"; + window_background_opacity = 0.2; + focused_background_color = "285577"; + focused_background_opacity = 1.0; + focused_text_color = "ffffff"; + font_family = "monospace"; + font_weight = "bold"; + font_size = "medium"; + }; + }; + + nmt.script = '' + assertFileExists home-files/.config/sway-easyfocus/config.yaml + assertFileContent home-files/.config/sway-easyfocus/config.yaml \ + ${./config.yaml} + ''; +}