|
| 1 | +{ |
| 2 | + config, |
| 3 | + lib, |
| 4 | + pkgs, |
| 5 | + |
| 6 | + ... |
| 7 | +}: |
| 8 | +let |
| 9 | + cfg = config.khanelinix.programs.graphical.apps.raycast; |
| 10 | + |
| 11 | + basePath = lib.concatStringsSep ":" [ |
| 12 | + "/etc/profiles/per-user/${config.home.username}/bin" |
| 13 | + "/run/current-system/sw/bin" |
| 14 | + "/nix/var/nix/profiles/default/bin" |
| 15 | + "/opt/homebrew/bin" |
| 16 | + "/usr/local/bin" |
| 17 | + "/usr/bin" |
| 18 | + "/bin" |
| 19 | + "/usr/sbin" |
| 20 | + "/sbin" |
| 21 | + ]; |
| 22 | + |
| 23 | + mkScript = |
| 24 | + { |
| 25 | + title, |
| 26 | + description, |
| 27 | + body, |
| 28 | + icon ? "command-symbol", |
| 29 | + mode ? "compact", |
| 30 | + argument1 ? null, |
| 31 | + }: |
| 32 | + '' |
| 33 | + #!${pkgs.runtimeShell} |
| 34 | + # @raycast.schemaVersion 1 |
| 35 | + # @raycast.title ${title} |
| 36 | + # @raycast.mode ${mode} |
| 37 | + # @raycast.icon ${icon} |
| 38 | + # @raycast.description ${description} |
| 39 | + ${lib.optionalString (argument1 != null) "# @raycast.argument1 ${builtins.toJSON argument1}"} |
| 40 | +
|
| 41 | + set -euo pipefail |
| 42 | + export PATH=${lib.escapeShellArg basePath} |
| 43 | +
|
| 44 | + ${body} |
| 45 | + ''; |
| 46 | +in |
| 47 | +{ |
| 48 | + options.khanelinix.programs.graphical.apps.raycast.enable = |
| 49 | + lib.mkEnableOption "Raycast script commands"; |
| 50 | + |
| 51 | + config = lib.mkIf cfg.enable { |
| 52 | + # Raycast stores script directory registrations in private app state. |
| 53 | + # Add ~/.config/raycast/script-commands once from Raycast Settings > |
| 54 | + # Script Commands > Add Script Directory; scripts below stay declarative. |
| 55 | + xdg.configFile = { |
| 56 | + "raycast/script-commands/nix-switch.sh" = { |
| 57 | + executable = true; |
| 58 | + text = mkScript { |
| 59 | + title = "Nix Switch"; |
| 60 | + description = "Switch current nix-darwin configuration."; |
| 61 | + icon = "hammer"; |
| 62 | + body = "exec nh darwin switch"; |
| 63 | + }; |
| 64 | + }; |
| 65 | + |
| 66 | + "raycast/script-commands/nix-switch-fast.sh" = { |
| 67 | + executable = true; |
| 68 | + text = mkScript { |
| 69 | + title = "Nix Switch Fast"; |
| 70 | + description = "Switch nix-darwin with parallel Nix jobs."; |
| 71 | + icon = "bolt"; |
| 72 | + body = '' |
| 73 | + NIX_CONFIG=$'max-jobs = auto\ncores = 0' |
| 74 | + export NIX_CONFIG |
| 75 | + exec nh darwin switch |
| 76 | + ''; |
| 77 | + }; |
| 78 | + }; |
| 79 | + |
| 80 | + "raycast/script-commands/restart-sketchybar.sh" = { |
| 81 | + executable = true; |
| 82 | + text = mkScript { |
| 83 | + title = "Restart Sketchybar"; |
| 84 | + description = "Restart Home Manager Sketchybar launch agent."; |
| 85 | + icon = "bar-chart"; |
| 86 | + body = ''exec launchctl kickstart -k "gui/$(id -u)/org.nix-community.home.sketchybar"''; |
| 87 | + }; |
| 88 | + }; |
| 89 | + |
| 90 | + "raycast/script-commands/restart-skhd.sh" = { |
| 91 | + executable = true; |
| 92 | + text = mkScript { |
| 93 | + title = "Restart Skhd"; |
| 94 | + description = "Restart Home Manager skhd launch agent."; |
| 95 | + icon = "keyboard"; |
| 96 | + body = ''exec launchctl kickstart -k "gui/$(id -u)/org.nix-community.home.skhd"''; |
| 97 | + }; |
| 98 | + }; |
| 99 | + |
| 100 | + "raycast/script-commands/restart-yabai.sh" = { |
| 101 | + executable = true; |
| 102 | + text = mkScript { |
| 103 | + title = "Restart Yabai"; |
| 104 | + description = "Restart nix-darwin yabai launch agent."; |
| 105 | + icon = "window"; |
| 106 | + body = ''exec launchctl kickstart -k "gui/$(id -u)/org.nixos.yabai"''; |
| 107 | + }; |
| 108 | + }; |
| 109 | + |
| 110 | + "raycast/script-commands/open-khanelinix.sh" = { |
| 111 | + executable = true; |
| 112 | + text = mkScript { |
| 113 | + title = "Open Khanelinix"; |
| 114 | + description = "Open khanelinix workspace in Kitty and Zellij."; |
| 115 | + icon = "terminal"; |
| 116 | + body = ''exec kitty --single-instance -d "$HOME/khanelinix" -- zellij''; |
| 117 | + }; |
| 118 | + }; |
| 119 | + |
| 120 | + "raycast/script-commands/sesh-connect.sh" = { |
| 121 | + executable = true; |
| 122 | + text = mkScript { |
| 123 | + title = "Sesh Connect"; |
| 124 | + description = "Open named sesh session in Kitty."; |
| 125 | + icon = "terminal"; |
| 126 | + argument1 = { |
| 127 | + type = "text"; |
| 128 | + placeholder = "session"; |
| 129 | + optional = true; |
| 130 | + }; |
| 131 | + body = '' |
| 132 | + session="''${1:-khanelinix}" |
| 133 | + export SESSION="$session" |
| 134 | + exec kitty --single-instance -d "$HOME" -- zsh -lc 'sesh connect "$SESSION"' |
| 135 | + ''; |
| 136 | + }; |
| 137 | + }; |
| 138 | + }; |
| 139 | + }; |
| 140 | +} |
0 commit comments