1
0
mirror of https://github.com/tw93/Mole.git synced 2026-03-22 20:15:07 +00:00

refactor quick launcher metadata and docs

This commit is contained in:
tw93
2026-02-24 14:24:46 +08:00
parent db602a0022
commit 7dac5dc4e2
3 changed files with 42 additions and 24 deletions

View File

@@ -271,7 +271,7 @@ After running the script, complete these steps in Raycast:
3. Click **"Add Script Directory"** (or **"+"**) 3. Click **"Add Script Directory"** (or **"+"**)
4. Add path: `~/Library/Application Support/Raycast/script-commands` 4. Add path: `~/Library/Application Support/Raycast/script-commands`
5. Search in Raycast for: **"Reload Script Directories"** and run it 5. Search in Raycast for: **"Reload Script Directories"** and run it
6. Done! Search for `mole clean`, `mole optimize`, or `mole status` to use the commands 6. Done! Search for `Mole Clean` or `clean`, `Mole Optimize`, or `Mole Status` to use the commands
> **Note**: The script creates the commands, but Raycast still requires a one-time manual script directory setup. > **Note**: The script creates the commands, but Raycast still requires a one-time manual script directory setup.

View File

@@ -14,6 +14,14 @@ ICON_SUCCESS="✓"
ICON_WARN="!" ICON_WARN="!"
ICON_ERR="✗" ICON_ERR="✗"
LAUNCHER_COMMAND_SPECS=(
"clean|Mole Clean|Deep system cleanup with Mole|Run Mole clean"
"uninstall|Mole Uninstall|Uninstall applications with Mole|Uninstall apps via Mole"
"optimize|Mole Optimize|System health checks and optimization|System health and optimization"
"analyze|Mole Analyze|Disk space analysis with Mole|Disk space analysis"
"status|Mole Status|Live system status dashboard|Live system dashboard"
)
log_step() { echo -e "${BLUE}${ICON_STEP}${NC} $1"; } log_step() { echo -e "${BLUE}${ICON_STEP}${NC} $1"; }
log_success() { echo -e "${GREEN}${ICON_SUCCESS}${NC} $1"; } log_success() { echo -e "${GREEN}${ICON_SUCCESS}${NC} $1"; }
log_warn() { echo -e "${YELLOW}${ICON_WARN}${NC} $1"; } log_warn() { echo -e "${YELLOW}${ICON_WARN}${NC} $1"; }
@@ -239,14 +247,18 @@ create_raycast_commands() {
local mo_bin="$1" local mo_bin="$1"
local default_dir="$HOME/Library/Application Support/Raycast/script-commands" local default_dir="$HOME/Library/Application Support/Raycast/script-commands"
local dir="$default_dir" local dir="$default_dir"
local entry
local subcommand
local title
local description
local alfred_subtitle
log_step "Installing Raycast commands..." log_step "Installing Raycast commands..."
mkdir -p "$dir" mkdir -p "$dir"
write_raycast_script "$dir/mole-clean.sh" "Mole Clean" "Deep system cleanup with Mole" "$mo_bin" "clean" for entry in "${LAUNCHER_COMMAND_SPECS[@]}"; do
write_raycast_script "$dir/mole-uninstall.sh" "Mole Uninstall" "Uninstall applications with Mole" "$mo_bin" "uninstall" IFS="|" read -r subcommand title description alfred_subtitle <<< "$entry"
write_raycast_script "$dir/mole-optimize.sh" "Mole Optimize" "System health checks and optimization" "$mo_bin" "optimize" write_raycast_script "$dir/mole-${subcommand}.sh" "$title" "$description" "$mo_bin" "$subcommand"
write_raycast_script "$dir/mole-analyze.sh" "Mole Analyze" "Disk space analysis with Mole" "$mo_bin" "analyze" done
write_raycast_script "$dir/mole-status.sh" "Mole Status" "Live system status dashboard" "$mo_bin" "status"
log_success "Scripts ready in: $dir" log_success "Scripts ready in: $dir"
log_header "Raycast Configuration" log_header "Raycast Configuration"
@@ -279,22 +291,24 @@ create_alfred_workflow() {
local mo_bin="$1" local mo_bin="$1"
local prefs_dir="${ALFRED_PREFS_DIR:-$HOME/Library/Application Support/Alfred/Alfred.alfredpreferences}" local prefs_dir="${ALFRED_PREFS_DIR:-$HOME/Library/Application Support/Alfred/Alfred.alfredpreferences}"
local workflows_dir="$prefs_dir/workflows" local workflows_dir="$prefs_dir/workflows"
local entry
local subcommand
local title
local subtitle
local bundle
local keyword
local command
if [[ ! -d "$workflows_dir" ]]; then if [[ ! -d "$workflows_dir" ]]; then
return return
fi fi
log_step "Installing Alfred workflows..." log_step "Installing Alfred workflows..."
local workflows=( for entry in "${LAUNCHER_COMMAND_SPECS[@]}"; do
"fun.tw93.mole.clean|Mole clean|clean|Run Mole clean|\"${mo_bin}\" clean" IFS="|" read -r subcommand title _ subtitle <<< "$entry"
"fun.tw93.mole.uninstall|Mole uninstall|uninstall|Uninstall apps via Mole|\"${mo_bin}\" uninstall" bundle="fun.tw93.mole.${subcommand}"
"fun.tw93.mole.optimize|Mole optimize|optimize|System health & optimization|\"${mo_bin}\" optimize" keyword="${subcommand}"
"fun.tw93.mole.analyze|Mole analyze|analyze|Disk space analysis|\"${mo_bin}\" analyze" command="\"${mo_bin}\" ${subcommand}"
"fun.tw93.mole.status|Mole status|status|Live system dashboard|\"${mo_bin}\" status"
)
for entry in "${workflows[@]}"; do
IFS="|" read -r bundle name keyword subtitle command <<< "$entry"
local workflow_uid="user.workflow.$(uuid | LC_ALL=C tr '[:upper:]' '[:lower:]')" local workflow_uid="user.workflow.$(uuid | LC_ALL=C tr '[:upper:]' '[:lower:]')"
local input_uid local input_uid
local action_uid local action_uid
@@ -313,7 +327,7 @@ create_alfred_workflow() {
<key>createdby</key> <key>createdby</key>
<string>Mole</string> <string>Mole</string>
<key>name</key> <key>name</key>
<string>${name}</string> <string>${title}</string>
<key>objects</key> <key>objects</key>
<array> <array>
<dict> <dict>
@@ -326,7 +340,7 @@ create_alfred_workflow() {
<key>subtext</key> <key>subtext</key>
<string>${subtitle}</string> <string>${subtitle}</string>
<key>text</key> <key>text</key>
<string>${name}</string> <string>${title}</string>
<key>withspace</key> <key>withspace</key>
<true/> <true/>
</dict> </dict>
@@ -385,7 +399,7 @@ ${command}
</dict> </dict>
</plist> </plist>
EOF EOF
log_success "Workflow ready: ${name}, keyword: ${keyword}" log_success "Workflow ready: ${title}, keyword: ${keyword}"
done done
log_step "Open Alfred preferences → Workflows if you need to adjust keywords." log_step "Open Alfred preferences → Workflows if you need to adjust keywords."
@@ -406,11 +420,13 @@ main() {
echo "" echo ""
log_success "Done! Raycast and Alfred are ready with 5 commands:" log_success "Done! Raycast and Alfred are ready with 5 commands:"
echo " • Mole Clean, Deep system cleanup" local entry
echo " • Mole Uninstall, Remove applications" local subcommand
echo " • Mole Optimize, System health & tuning" local title
echo " • Mole Analyze, Disk space explorer" for entry in "${LAUNCHER_COMMAND_SPECS[@]}"; do
echo " • Mole Status, Live system monitor" IFS="|" read -r subcommand title _ _ <<< "$entry"
echo " • Raycast: ${title} | Alfred keyword: ${subcommand}"
done
echo "" echo ""
} }

View File

@@ -84,6 +84,8 @@ EOF
run env HOME="$HOME" TERM="dumb" PATH="$fake_bin:/usr/bin:/bin:/usr/sbin:/sbin" \ run env HOME="$HOME" TERM="dumb" PATH="$fake_bin:/usr/bin:/bin:/usr/sbin:/sbin" \
"$PROJECT_ROOT/scripts/setup-quick-launchers.sh" "$PROJECT_ROOT/scripts/setup-quick-launchers.sh"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
[[ "$output" == *"Raycast: Mole Clean | Alfred keyword: clean"* ]]
[[ "$output" == *"Raycast: Mole Status | Alfred keyword: status"* ]]
local raycast_dir="$HOME/Library/Application Support/Raycast/script-commands" local raycast_dir="$HOME/Library/Application Support/Raycast/script-commands"
[ -d "$raycast_dir" ] [ -d "$raycast_dir" ]