feat: macOS menu-bar plugin (sshshot menubar install)#26
Merged
Conversation
bd1b7e1 to
c6bce4a
Compare
Drops a SwiftBar plugin script at ~/SwiftBarPlugins/sshshot.5s.sh that renders a 📸 icon in the menu bar showing the daemon state (running / paused / idle) and the active target. Clicking the icon opens a submenu to switch target across all configured remotes, pause/resume/restart, or open config/log files — every action is a click-through to existing sshshot CLI subcommands, no new daemon endpoints needed. The plugin script is embedded as a template literal in src/menubar.ts so the CLI distribution is a single file. Install is idempotent, writes atomically (tmp-then-rename), and detects whether SwiftBar is installed to print the right next-step message. Two CLI-side fixes that the menu bar needs: - 'sshshot start' now accepts an optional target argument: 'sshshot start <target>' bypasses the interactive promptSelect. The menu bar can't answer interactive prompts, so without this the Start-Daemon button silently did nothing. Existing 'sshshot start' with no args is unchanged (still prompts). - The plugin exports PATH with node's directory prepended at the top. SwiftBar runs plugin scripts with a minimal PATH (/usr/bin:/bin) that doesn't include nvm; without this prepend, the #!/usr/bin/env node shebang fails and every menu click silently no-ops behind the notifications. node's directory is captured from process.execPath at install time. Users on nvm should re-run 'sshshot menubar install' after switching node versions. New commands: sshshot menubar install write the plugin (creates dir if needed) sshshot menubar uninstall remove the plugin file sshshot menubar status show install state + SwiftBar presence Linux/Windows are no-ops with a clear message — SwiftBar is macOS-only. The clipboardMode work (Phase 6b context-aware routing) will surface in this menu later with auto/manual/always toggle entries.
c6bce4a to
ab1a968
Compare
|
🎉 This PR is included in version 0.9.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
sshshot menubar install / uninstall / statussubcommands that drop a SwiftBar plugin at~/SwiftBarPlugins/sshshot.5s.sh. The plugin renders a 📸 icon in the macOS menu bar showing daemon state and active target; clicking opens a submenu with target switcher (all configured remotes), pause/resume/restart, and open-config/log shortcuts.sshshotsubcommands — no new daemon endpoints. Refresh interval: 5 s. Status readssshshot status --jsonwith~/.config/sshshot/config.jsonas fallback when the daemon isn't running yet.sshshot start <target>now accepts a positional target so SwiftBar can bypass the interactive prompt; the plugin prepends node's directory toPATHso the shebang resolves under SwiftBar's minimal env (the root cause of "switch notifications fire but daemon never starts").Why
Manually running
sshshot target <one-of-16-remotes>from a terminal is friction. The menu bar replaces a tab-completed CLI dance with a click, and surfaces "paused" / "not running" state visibly — easy to forget the daemon is paused without it.Implementation
src/menubar.ts— the plugin script is embedded as a TS template literal so the CLI distribution stays a single file.install()writes atomically (tmp→rename), detects SwiftBar presence, prints the right next-step message. Non-macOS platforms get a clear "macOS-only" message.src/index.ts— dispatcher wiresmenubarsubcommand;startCommand()accepts optionaltargetArgto make the start-daemon button work non-interactively.Test plan
yarn test— 12 new tests intest/menubar.test.ts(53 passing total)yarn lint,yarn typecheck,yarn format:check,yarn build— all greenbrew install --cask swiftbar→ launch SwiftBar → point at~/SwiftBarPlugins→ 📸 appears~/.config/sshshot/config.jsonupdatessshshot menubar uninstall→ file removedsshshot menubar status→ reports correctly when installed and when notsshshot menubar installexits cleanly with "macOS-only" messageFuture work (out of scope)
The
clipboardMode: "auto" | "manual" | "always"setting from the Phase 6b roadmap will surface in the menu's daemon-control block as a mode toggle once it lands. Noted in README.