diff --git a/modules/lib/maintainers.nix b/modules/lib/maintainers.nix index 8f4010395..11f79db1a 100644 --- a/modules/lib/maintainers.nix +++ b/modules/lib/maintainers.nix @@ -829,6 +829,12 @@ githubId = 68489118; name = "tomodachi94"; }; + vortriz = { + name = "Rishi Vora"; + email = "vorarishi22+nix@gmail.com"; + github = "Vortriz"; + githubId = 97402159; + }; wcarlsen = { name = "Willi Carlsen"; email = "carlsenwilli+nix@gmail.com"; diff --git a/modules/misc/news/2025/06/2025-06-09_20-42-11.nix b/modules/misc/news/2025/06/2025-06-09_20-42-11.nix new file mode 100644 index 000000000..906bf9732 --- /dev/null +++ b/modules/misc/news/2025/06/2025-06-09_20-42-11.nix @@ -0,0 +1,11 @@ +{ pkgs, ... }: +{ + time = "2025-06-09T15:12:11+00:00"; + condition = pkgs.stdenv.hostPlatform.isLinux; + message = '' + A new module is available: 'programs.niriswitcher'. + + niriswitcher is an application switcher for niri, with support for + workspaces and automatic light and dark mode. + ''; +} diff --git a/modules/modules.nix b/modules/modules.nix index 436726d1a..de626be2f 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -212,6 +212,7 @@ let ./programs/newsboat.nix ./programs/nh.nix ./programs/nheko.nix + ./programs/niriswitcher.nix ./programs/nix-index.nix ./programs/nix-init.nix ./programs/nix-your-shell.nix diff --git a/modules/programs/niriswitcher.nix b/modules/programs/niriswitcher.nix new file mode 100644 index 000000000..1b0c6e4c2 --- /dev/null +++ b/modules/programs/niriswitcher.nix @@ -0,0 +1,91 @@ +{ + config, + lib, + pkgs, + ... +}: +let + cfg = config.programs.niriswitcher; + + settingsFormat = pkgs.formats.toml { }; +in +{ + meta.maintainers = [ lib.hm.maintainers.vortriz ]; + + options.programs.niriswitcher = { + enable = lib.mkEnableOption "niriswitcher, an application switcher for niri"; + + package = lib.mkPackageOption pkgs "niriswitcher" { nullable = true; }; + + settings = lib.mkOption { + type = lib.types.nullOr settingsFormat.type; + default = null; + example = lib.literalExpression '' + { + keys = { + modifier = "Super"; + switch = { + next = "Tab"; + prev = "Shift+Tab"; + }; + }; + center_on_focus = true; + appearance = { + system_theme = "dark"; + icon_size = 64; + }; + } + ''; + description = '' + niriswitcher configuration. + For available settings see . + ''; + }; + + style = lib.mkOption { + type = with lib.types; nullOr (either path lines); + default = null; + example = '' + .application-name { + opacity: 1; + color: rgba(255, 255, 255, 0.6); + } + .application.selected .application-name { + color: rgba(255, 255, 255, 1); + } + ''; + description = '' + CSS style of the switcher. + + for the documentation. + + If the value is set to a path literal, then the path will be used as the CSS file. + ''; + }; + }; + + config = lib.mkIf cfg.enable { + assertions = [ + { + assertion = pkgs.stdenv.hostPlatform.isLinux; + message = "niriswitcher is only available on Linux."; + } + ]; + + home.packages = lib.mkIf (cfg.package != null) [ cfg.package ]; + + xdg.configFile = { + "niriswitcher/config.toml" = lib.mkIf (cfg.settings != null) { + source = settingsFormat.generate "config.toml" cfg.settings; + }; + + "niriswitcher/style.css" = lib.mkIf (cfg.style != null) { + source = + if builtins.isPath cfg.style || lib.isStorePath cfg.style then + cfg.style + else + pkgs.writeText "niriswitcher/style.css" cfg.style; + }; + }; + }; +} diff --git a/tests/default.nix b/tests/default.nix index ffb452942..2ef53b55c 100644 --- a/tests/default.nix +++ b/tests/default.nix @@ -405,6 +405,7 @@ import nmtSrc { ./modules/programs/mpvpaper ./modules/programs/ncmpcpp-linux ./modules/programs/nh + ./modules/programs/niriswitcher ./modules/programs/onagre ./modules/programs/onedrive ./modules/programs/pqiv diff --git a/tests/modules/programs/niriswitcher/default.nix b/tests/modules/programs/niriswitcher/default.nix new file mode 100644 index 000000000..4f1def362 --- /dev/null +++ b/tests/modules/programs/niriswitcher/default.nix @@ -0,0 +1 @@ +{ niriswitcher-program = ./niriswitcher.nix; } diff --git a/tests/modules/programs/niriswitcher/expected.toml b/tests/modules/programs/niriswitcher/expected.toml new file mode 100644 index 000000000..75d28ecd9 --- /dev/null +++ b/tests/modules/programs/niriswitcher/expected.toml @@ -0,0 +1,11 @@ +center_on_focus = true +[appearance] +icon_size = 64 +system_theme = "dark" + +[keys] +modifier = "Super" + +[keys.switch] +next = "Tab" +prev = "Shift+Tab" diff --git a/tests/modules/programs/niriswitcher/niriswitcher.nix b/tests/modules/programs/niriswitcher/niriswitcher.nix new file mode 100644 index 000000000..3ebd60b5e --- /dev/null +++ b/tests/modules/programs/niriswitcher/niriswitcher.nix @@ -0,0 +1,30 @@ +{ + programs.niriswitcher = { + enable = true; + + settings = { + center_on_focus = true; + keys = { + modifier = "Super"; + switch = { + next = "Tab"; + prev = "Shift+Tab"; + }; + }; + appearance = { + system_theme = "dark"; + icon_size = 64; + }; + }; + + style = ./style.css; + }; + + nmt.script = '' + assertFileExists home-files/.config/niriswitcher/config.toml + assertFileContent home-files/.config/niriswitcher/config.toml ${./expected.toml} + + assertFileExists home-files/.config/niriswitcher/style.css + assertFileContent home-files/.config/niriswitcher/style.css ${./style.css} + ''; +} diff --git a/tests/modules/programs/niriswitcher/style.css b/tests/modules/programs/niriswitcher/style.css new file mode 100644 index 000000000..cf5d12e67 --- /dev/null +++ b/tests/modules/programs/niriswitcher/style.css @@ -0,0 +1,7 @@ +.application-name { + opacity: 1; + color: rgba(255, 255, 255, 0.6); +} +.application.selected .application-name { + color: rgba(255, 255, 255, 1); +}