Repository navigation
feat(macos): create macos switchyard deamon #863
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
79cc21e
feat(macos): create macos switchyard deamon
messiaen 0b0b40c
chore: add macos to make help
messiaen 3675c84
refactor(macos): separate menu bar from daemon install
messiaen dfc2f1f
chore: cleanup
messiaen 801263c
chore: fix xlm
messiaen 545b17c
chore: cleanup
messiaen 6d987d7
chore: remove cmd alias
messiaen 355b603
chore: review feedback
messiaen 2fe2551
chore: remove direct toml updates
messiaen 7948b10
fix: dry-run
messiaen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,117 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| SY_HOME="${SY_HOME:-$HOME/.switchyard}" | ||
| SY_PORT="${SY_PORT:-4123}" | ||
| CODEX_DIR="${CODEX_HOME:-$HOME/.codex}" | ||
| # Both installers use Codex's standalone profile file for the CLI. | ||
| CODEX_PROFILE_CONFIG="$CODEX_DIR/sy.config.toml" | ||
| ALIAS_START="# >>> switchyard codex alias >>>" | ||
| ALIAS_END="# <<< switchyard codex alias <<<" | ||
|
|
||
| say() { printf '%s\n' "$*"; } | ||
| step() { printf '\n==> %s\n' "$*"; } | ||
|
|
||
| strip_block() { | ||
| local path="$1" start="$2" end="$3" label="${4:-the switchyard block}" | ||
| if [[ ! -f "$path" ]] || ! grep -qF "$start" "$path"; then | ||
| return 1 | ||
| fi | ||
| if ! grep -qF "$end" "$path"; then | ||
| say " $path has no end marker for $label; not editing it" >&2 | ||
| return 1 | ||
| fi | ||
| if (( DRY_RUN )); then | ||
| say " would remove $label from $path" | ||
| return 0 | ||
| fi | ||
| local temp | ||
| temp="$(mktemp)" | ||
| awk -v start="$start" -v end="$end" ' | ||
| index($0, start) { skipping = 1 } | ||
| !skipping { print } | ||
| index($0, end) { skipping = 0 } | ||
| END { if (skipping) exit 1 } | ||
| ' "$path" > "$temp" | ||
| cat "$temp" > "$path" | ||
| rm -f "$temp" | ||
| say " removed $label from $path" | ||
| return 0 | ||
| } | ||
|
|
||
| run() { | ||
| if (( DRY_RUN )); then | ||
| say " would run: $*" | ||
| else | ||
| "$@" | ||
| fi | ||
| } | ||
|
|
||
| write_once() { | ||
| local path="$1" | ||
| if [[ -f "$path" ]]; then | ||
| say " keeping existing $path" | ||
| cat >/dev/null | ||
| return | ||
| fi | ||
| if (( DRY_RUN )); then | ||
| say " would create $path" | ||
| cat >/dev/null | ||
| else | ||
| mkdir -p "$(dirname "$path")" | ||
| cat > "$path" | ||
| say " created $path" | ||
| fi | ||
| } | ||
|
|
||
| write_with_backup() { | ||
| local path="$1" | ||
| if (( DRY_RUN )); then | ||
| [[ -f "$path" ]] && say " would back up $path" | ||
| say " would write $path" | ||
| cat >/dev/null | ||
| return | ||
| fi | ||
| mkdir -p "$(dirname "$path")" | ||
| local incoming | ||
| incoming="$(mktemp)" | ||
| cat > "$incoming" | ||
| if [[ -f "$path" ]] && cmp -s "$incoming" "$path"; then | ||
| say " $path is already up to date" | ||
| rm -f "$incoming" | ||
| return | ||
| fi | ||
| if [[ -f "$path" ]]; then | ||
| local backup | ||
| backup="$path.switchyard-backup.$(date +%Y%m%d%H%M%S)" | ||
| cp "$path" "$backup" | ||
| say " backed up $path to $backup" | ||
| fi | ||
| cat "$incoming" > "$path" | ||
| rm -f "$incoming" | ||
| say " wrote $path" | ||
| } | ||
|
|
||
| write_always() { | ||
| local path="$1" | ||
| if (( DRY_RUN )); then | ||
| say " would write $path" | ||
| cat >/dev/null | ||
| else | ||
| mkdir -p "$(dirname "$path")" | ||
| cat > "$path" | ||
| say " wrote $path" | ||
| fi | ||
| } | ||
|
|
||
| remove_file() { | ||
| local path="$1" | ||
| if [[ ! -e "$path" ]]; then | ||
| say " nothing to remove at $path" | ||
| elif (( DRY_RUN )); then | ||
| say " would delete $path" | ||
| else | ||
| rm -f "$path" | ||
| say " deleted $path" | ||
| fi | ||
| } | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,47 +1,8 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # | ||
| # Paths, markers, and helpers shared by install.sh and uninstall.sh. | ||
| # The markers must match between the two, which is why they live here. | ||
| # shellcheck source=scripts/common.sh | ||
| source "$(dirname "${BASH_SOURCE[0]}")/../common.sh" | ||
|
|
||
| SY_HOME="${SY_HOME:-$HOME/.switchyard}" | ||
| SY_PORT="${SY_PORT:-4123}" | ||
| SERVICE_NAME="switchyard.service" | ||
| SYSTEMD_USER_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/systemd/user" | ||
| CODEX_DIR="${CODEX_HOME:-$HOME/.codex}" | ||
| # Since Codex 0.134.0, `--profile sy` reads sy.config.toml and fails if | ||
| # config.toml still has [profiles.sy]. | ||
| CODEX_PROFILE_CONFIG="$CODEX_DIR/sy.config.toml" | ||
| ALIAS_START="# >>> switchyard codex alias >>>" | ||
| ALIAS_END="# <<< switchyard codex alias <<<" | ||
|
|
||
| say() { printf '%s\n' "$*"; } | ||
| step() { printf '\n==> %s\n' "$*"; } | ||
|
|
||
| # Deletes the marked block, inclusive, leaving the rest of the file alone. | ||
| strip_block() { | ||
| local path="$1" start="$2" end="$3" label="${4:-the switchyard block}" | ||
| if [[ ! -f "$path" ]] || ! grep -qF "$start" "$path"; then | ||
| return 1 | ||
| fi | ||
| if ! grep -qF "$end" "$path"; then | ||
| say " $path has no end marker for $label; not editing it" >&2 | ||
| return 1 | ||
| fi | ||
| if (( DRY_RUN )); then | ||
| say " would remove $label from $path" | ||
| return 0 | ||
| fi | ||
| local temp | ||
| temp="$(mktemp)" | ||
| awk -v start="$start" -v end="$end" ' | ||
| index($0, start) { skipping = 1 } | ||
| !skipping { print } | ||
| index($0, end) { skipping = 0 } | ||
| END { if (skipping) exit 1 } | ||
| ' "$path" > "$temp" | ||
| cat "$temp" > "$path" | ||
| rm -f "$temp" | ||
| say " removed $label from $path" | ||
| return 0 | ||
| } |
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # | ||
| # Paths shared by install.sh and uninstall.sh. | ||
|
|
||
| # shellcheck source=scripts/common.sh | ||
| source "$(dirname "${BASH_SOURCE[0]}")/../common.sh" | ||
|
|
||
| SERVER_LABEL="com.nvidia.switchyard.server" | ||
| LAUNCH_AGENTS="$HOME/Library/LaunchAgents" |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.