diff --git a/modules/programs/rofi.nix b/modules/programs/rofi.nix index c459af208..3ff572af9 100644 --- a/modules/programs/rofi.nix +++ b/modules/programs/rofi.nix @@ -132,6 +132,7 @@ let else cfg.theme; + modes = map (mode: if isString mode then mode else "${mode.name}:${mode.path}") cfg.modes; in { options.programs.rofi = { @@ -254,11 +255,36 @@ in description = "Path where to put generated configuration file."; }; + modes = mkOption { + default = [ ]; + example = literalExpression '' + [ + "drun" + "emoji" + "ssh" + { + name = "whatnot"; + path = lib.getExe pkgs.rofi-whatnot; + } + ] + ''; + type = + with types; + listOf ( + either str (submodule { + options = { + name = mkOption { type = str; }; + path = mkOption { type = str; }; + }; + }) + ); + description = "Modes to enable. For custom modes see `man 5 rofi-script`."; + }; + extraConfig = mkOption { default = { }; example = literalExpression '' { - modi = "drun,emoji,ssh"; kb-primary-paste = "Control+V,Shift+Insert"; kb-secondary-paste = "Control+v,Insert"; } @@ -313,6 +339,7 @@ in toRasi { configuration = ( { + inherit modes; font = cfg.font; terminal = cfg.terminal; cycle = cfg.cycle; diff --git a/tests/modules/programs/rofi/custom-theme-config.rasi b/tests/modules/programs/rofi/custom-theme-config.rasi index 6b4d5b8a0..5abba0ba1 100644 --- a/tests/modules/programs/rofi/custom-theme-config.rasi +++ b/tests/modules/programs/rofi/custom-theme-config.rasi @@ -1,5 +1,6 @@ configuration { location: 0; +modes: [ ]; xoffset: 0; yoffset: 0; } diff --git a/tests/modules/programs/rofi/valid-config-expected.rasi b/tests/modules/programs/rofi/valid-config-expected.rasi index d9d4aa0be..b2c6b80a5 100644 --- a/tests/modules/programs/rofi/valid-config-expected.rasi +++ b/tests/modules/programs/rofi/valid-config-expected.rasi @@ -4,7 +4,7 @@ font: "Droid Sans Mono 14"; kb-primary-paste: "Control+V,Shift+Insert"; kb-secondary-paste: "Control+v,Insert"; location: 0; -modi: "drun,emoji,ssh"; +modes: [ "drun","emoji","ssh","foo:bar" ]; terminal: "/some/path"; xoffset: 0; yoffset: 0; diff --git a/tests/modules/programs/rofi/valid-config.nix b/tests/modules/programs/rofi/valid-config.nix index 538d1c422..a078b3e39 100644 --- a/tests/modules/programs/rofi/valid-config.nix +++ b/tests/modules/programs/rofi/valid-config.nix @@ -9,8 +9,16 @@ border = "border"; separator = "separator"; }; + modes = [ + "drun" + "emoji" + "ssh" + { + name = "foo"; + path = "bar"; + } + ]; extraConfig = { - modi = "drun,emoji,ssh"; kb-primary-paste = "Control+V,Shift+Insert"; kb-secondary-paste = "Control+v,Insert"; };