Skip to content

macOS: Add app bundle support with runtime data directory resolution#217

Draft
edjw wants to merge 2 commits intodagargo:masterfrom
edjw:macos-app-bundle
Draft

macOS: Add app bundle support with runtime data directory resolution#217
edjw wants to merge 2 commits intodagargo:masterfrom
edjw:macos-app-bundle

Conversation

@edjw
Copy link

@edjw edjw commented Mar 18, 2026

Problem

Elektroid has no macOS app bundle support. On macOS you can build from source and run the binary, but there's no way to package it as a .app in /Applications — because DATADIR is hardcoded at compile time to wherever ./configure pointed. Move the binary anywhere else and it can't find its UI files, CSS, or device configs.

Solution

Runtime data directory resolution — a new get_data_dir() function that, on macOS, uses _NSGetExecutablePath() to find the executable's actual location and resolves the data directory relative to the bundle structure (../Resources/share/elektroid). If it's not running from a bundle, or on any other platform, it falls back to the compile-time DATADIR. Zero change in behaviour for Linux.

All 7 DATADIR string literal usages across 4 files are replaced with g_build_filename(get_data_dir(), ...) calls.

Also includes macos-bundle.sh, a script to package a build into a proper .app with icon generation, Info.plist, and bundled resources.

Changes

  • src/utils.c / src/utils.h — new get_data_dir() function
  • src/elektroid.c — 4 usages updated
  • src/connectors/elektron.c — 1 usage updated
  • src/connectors/volca_sample_2.c — 1 usage updated
  • src/mactions/microbrute.c — 1 usage updated
  • macos-bundle.sh — app bundle build script
  • .gitignore — ignore generated Elektroid.app/

Test plan

  • Builds cleanly on macOS (ARM64, Homebrew dependencies)
  • Verify Linux build is unaffected (get_data_dir() compiles to return DATADIR)
  • Verify app launches correctly from the .app bundle in /Applications
  • Verify app still works when run directly from the build directory

🤖 Generated with Claude Code

edjw and others added 2 commits March 18, 2026 23:17
Previously, DATADIR was hardcoded at compile time, which meant the
binary could only find its resources (UI files, CSS, device configs)
at the path baked in by ./configure. This prevents packaging as a
macOS .app bundle, since bundles can be placed anywhere on disk.

Add get_data_dir() which uses _NSGetExecutablePath() on macOS to
locate the executable and resolve the data directory relative to
the bundle structure (../Resources/share/elektroid). Falls back to
the compile-time DATADIR if not running from a bundle or on other
platforms — no change in behaviour for Linux.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Script to package Elektroid as a macOS .app with proper icon,
Info.plist, and bundled resources. Requires rsvg-convert for
icon generation.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@dagargo
Copy link
Owner

dagargo commented Mar 19, 2026

This is really cool!

Thanks for improving Elektroid support on OSX.

I'll review this carefully and merge it this during the following days.

@dagargo dagargo self-assigned this Mar 19, 2026
@dagargo dagargo added this to the 3.4 milestone Mar 19, 2026
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.

2 participants