From d1ec6eec44e2f7787ec670676933bbcc3d07d361 Mon Sep 17 00:00:00 2001 From: Arpit Chakladar Date: Sat, 26 Sep 2026 22:01:03 +0530 Subject: feat: added actions for different modules --- modules/desktop/rofi/default.nix | 50 ++++++++++++++++++++-------------------- 1 file changed, 25 insertions(+), 25 deletions(-) (limited to 'modules/desktop/rofi/default.nix') diff --git a/modules/desktop/rofi/default.nix b/modules/desktop/rofi/default.nix index 0c0e6df..2eab3f2 100644 --- a/modules/desktop/rofi/default.nix +++ b/modules/desktop/rofi/default.nix @@ -8,30 +8,6 @@ let cfg = config.desktop.rofi; base16Colors = import ../../colors/base16 { inherit config lib pkgs; }; - - actionOptionsString = lib.concatMapStringsSep "\\n" ( - action: action.name + lib.optionalString (action.icon != null) "\\0icon\\x1f${action.icon}" - ) cfg.action.actions; - - actionCasesString = lib.concatStringsSep "\n" ( - map (action: " \"${action.name}\") ${action.command} ;;") cfg.action.actions - ); - - actionScript = pkgs.writeShellApplication { - name = "rofi-action"; - runtimeInputs = [ - config.terminal.bash.package - cfg.package - ]; - text = - builtins.replaceStrings - [ - "@@OPTIONS@@" - ''"@@CASES@@") : ;;'' - ] - [ actionOptionsString actionCasesString ] - (builtins.readFile ./rofi-action.sh); - }; in { options.desktop.rofi = { @@ -70,7 +46,6 @@ in package = lib.mkOption { type = lib.types.package; readOnly = true; - default = actionScript; description = "The rofi-action script package."; }; }; @@ -106,5 +81,30 @@ in }; home.packages = lib.mkIf (cfg.action.actions != [ ]) [ cfg.action.package ]; + + desktop.rofi.action.package = pkgs.writeShellApplication { + name = "rofi-action"; + runtimeInputs = [ + config.terminal.bash.package + cfg.package + ]; + text = + let + actions = cfg.action.actions; + optionsString = lib.concatMapStringsSep "\\n" ( + action: action.name + lib.optionalString (action.icon != null) "\\0icon\\x1f${action.icon}" + ) actions; + casesString = lib.concatStringsSep "\n" ( + map (action: " \"${action.name}\") ${action.command} ;;") actions + ); + in + builtins.replaceStrings + [ + "@@OPTIONS@@" + ''"@@CASES@@") : ;;'' + ] + [ optionsString casesString ] + (builtins.readFile ./rofi-action.sh); + }; }; } -- cgit v1.2.3