Skip to content

Fix shell command substitution in binary path configuration#491

Open
BrianGreenhill wants to merge 1 commit intoJean-Tinland:masterfrom
BrianGreenhill:path-substitution-fix
Open

Fix shell command substitution in binary path configuration#491
BrianGreenhill wants to merge 1 commit intoJean-Tinland:masterfrom
BrianGreenhill:path-substitution-fix

Conversation

@BrianGreenhill
Copy link
Copy Markdown

@BrianGreenhill BrianGreenhill commented Nov 21, 2025

Description

Add support for shell command substitutions (e.g., $(which aerospace)) in binary path configuration options. This allows portable configuration files that work across different architectures and installation paths.

Previously, the default settings advertised support for $(which ...) syntax in paths like aerospacePath, yabaiPath, etc., but this was never actually implemented. The literal string "$(which aerospace)" would be used as the command, causing execution failures.

This commit adds proper expansion of shell substitutions when loading the external config file:

  • Expands $(which ...) patterns by setting PATH to include common Homebrew locations (/opt/homebrew/bin, /usr/local/bin) before evaluation
  • Works in Übersicht's restricted environment where user PATH is not available
  • Preserves original substitution syntax when saving config back to disk, so $(which aerospace) remains in the file rather than being replaced with the expanded path
  • Handles expansion failures gracefully by falling back to original value

This enables truly portable configuration files that work across:

  • Apple Silicon Macs (Homebrew in /opt/homebrew)
  • Intel Macs (Homebrew in /usr/local)
  • Different installation methods and paths

Binary path options affected:

  • global.aerospacePath
  • global.yabaiPath
  • global.flashspacePath
  • githubWidgetOptions.ghBinaryPath
  • mpdWidgetOptions.mpdBinaryPath
  • gpuWidgetOptions.gpuMacmonBinaryPath

Fixes # #492

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Test A: Shell substitution expansion on config load

  1. Set "aerospacePath": "$(which aerospace)" in ~/.simplebarrc
  2. Restart Übersicht
  3. Verify in Debug Console that path expands correctly (e.g., to /opt/homebrew/bin/aerospace)
  4. Verify simple-bar loads without errors
  5. Verify workspace switching and window management functions work

Test B: Config preservation on save

  1. Set "aerospacePath": "$(which aerospace)" in ~/.simplebarrc
  2. Make a change to simple-bar settings via UI
  3. Verify ~/.simplebarrc still contains "$(which aerospace)" (not the expanded path)
  4. Restart Übersicht
  5. Verify expansion still works after reload

Test C: Fallback behavior

  1. Set "aerospacePath": "$(which nonexistent)" in ~/.simplebarrc
  2. Verify simple-bar handles gracefully (uses original value, logs warning)
  3. Revert to valid path and verify recovery

Test Configuration:

  • OS version: macOS Tahoe 26.1
  • AeroSpace version: v0.19.2-Beta (d246f250468fc9d427a2eb901d56794af7ac6609)
  • Übersicht version: 1.6 (82)
  • Architecture: Apple Silicon (M3)

Additional Testing Notes:

  • Tested with aerospace installed via Homebrew at /opt/homebrew/bin/aerospace
  • Verified workspace data fetching, window management, and display queries all function correctly
  • Checked Debug Console for expansion logs showing successful path resolution

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas (make use of JSDoc if necessary)
  • My changes generate no new warnings

Changes to make to the documentation

Please list any changes to the documentation that are required to reflect your changes.

Add support for shell command substitutions (e.g., $(which aerospace))
in binary path configuration options. This allows portable configuration
files that work across different architectures and installation paths.

Previously, the default settings advertised support for $(which ...)
syntax in paths like aerospacePath, yabaiPath, etc., but this was never
actually implemented. The literal string "$(which aerospace)" would be
used as the command, causing execution failures.

This commit adds proper expansion of shell substitutions when loading
the external config file:

- Expands $(which ...) patterns by setting PATH to include common
  Homebrew locations (/opt/homebrew/bin, /usr/local/bin) before
  evaluation
- Works in Übersicht's restricted environment where user PATH is not
  available
- Preserves original substitution syntax when saving config back to
  disk, so $(which aerospace) remains in the file rather than being
  replaced with the expanded path
- Handles expansion failures gracefully by falling back to original
  value

This enables truly portable configuration files that work across:
- Apple Silicon Macs (Homebrew in /opt/homebrew)
- Intel Macs (Homebrew in /usr/local)
- Different installation methods and paths

Binary path options affected:
- global.aerospacePath
- global.yabaiPath
- global.flashspacePath
- githubWidgetOptions.ghBinaryPath
- mpdWidgetOptions.mpdBinaryPath
- gpuWidgetOptions.gpuMacmonBinaryPath
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant