Skip to content

Add CLI controls for menu bar app and launch-at-login #6

@Jing-yilin

Description

@Jing-yilin

Summary

Add Perch CLI commands for controlling the native macOS menu bar app and launch-at-login behavior.

Today the Swift menu bar app already has LaunchAtLoginManager, and install.sh can opportunistically open a locally available app, but the published perch CLI only supports session management (add/list/done/reopen/doctor). Users should be able to manage the menu bar app from terminal scripts as well.

Proposed CLI

perch menubar start [--app-path <path>]
perch menubar stop
perch menubar status
perch menubar login enable [--app-path <path>]
perch menubar login disable
perch menubar login status

Behavior

perch menubar start

  • Locate a local PerchApp executable and launch it.
  • Candidate locations, in order:
    1. explicit --app-path
    2. /Applications/Perch.app
    3. repo/dev builds such as App/.build/arm64-apple-macosx/release/PerchApp
    4. repo/dev builds such as App/.build/arm64-apple-macosx/debug/PerchApp
  • If already running, exit successfully and print the existing PID.
  • If no app is found, exit non-zero with a clear message explaining that the current CLI release does not install PerchApp yet.

perch menubar stop

  • Stop the native menu bar app, e.g. by finding/killing PerchApp.
  • Exit successfully if it is already stopped.

perch menubar status

  • Print whether the menu bar app is running.
  • Include PID(s) when running.
  • Optional future: --json.

perch menubar login enable

  • Create/update ~/Library/LaunchAgents/com.resciencelab.perch.plist using the selected PerchApp executable path.
  • Run the equivalent of:
    • launchctl bootout gui/$UID <plist> best-effort
    • launchctl bootstrap gui/$UID <plist>
    • launchctl enable gui/$UID/com.resciencelab.perch
  • Validate the executable exists and is executable before writing the plist.

perch menubar login disable

  • launchctl bootout gui/$UID ~/Library/LaunchAgents/com.resciencelab.perch.plist best-effort.
  • Remove ~/Library/LaunchAgents/com.resciencelab.perch.plist.
  • Exit successfully if already disabled.

perch menubar login status

  • Report whether the LaunchAgent plist exists.
  • Ideally also report the configured executable path.

Non-goals

  • Do not bundle or install PerchApp in this issue.
  • Do not add signing/notarization/DMG packaging.
  • Do not change session storage or Raycast behavior.

Implementation Notes

  • The Swift app already has equivalent behavior in App/Sources/PerchAppCore/LaunchAtLoginManager.swift; mirror this behavior in Rust CLI to avoid requiring the app to be running.
  • Keep this macOS-only. On unsupported platforms, return a clear error.
  • Consider adding a small cli/src/menubar.rs module.

Acceptance Criteria

  • perch menubar start starts a local dev/release PerchApp when available.
  • perch menubar start --app-path <path> starts the explicit executable path.
  • perch menubar start gives actionable error when no app is found.
  • perch menubar stop stops the app and is idempotent.
  • perch menubar status reports running/stopped state.
  • perch menubar login enable --app-path <path> writes a valid LaunchAgent plist and bootstraps it.
  • perch menubar login disable removes/unloads the LaunchAgent and is idempotent.
  • perch menubar login status reports enabled/disabled state.
  • Unit tests cover plist generation, executable validation, and idempotent enable/disable behavior.
  • README documents the new commands and notes that current CLI releases do not install PerchApp automatically.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions