From ef4d6c73a883c45bf83048778721573d1a3545c9 Mon Sep 17 00:00:00 2001 From: Seth Freiberg Date: Wed, 29 Apr 2026 12:10:07 -0400 Subject: [PATCH] feat: generate stub .app bundle for Launchpad/Spotlight integration on macOS Co-Authored-By: Claude Sonnet 4.6 --- Formula/glabels-qt.rb | 71 +++++++++++++++++++++++++++++++++++++++++++ README.md | 14 +++++++++ 2 files changed, 85 insertions(+) diff --git a/Formula/glabels-qt.rb b/Formula/glabels-qt.rb index d34d432..fdcfa6c 100644 --- a/Formula/glabels-qt.rb +++ b/Formula/glabels-qt.rb @@ -22,6 +22,77 @@ class GlabelsQt < Formula *std_cmake_args system "cmake", "--build", "build" system "cmake", "--install", "build" + + # Build a thin .app wrapper for Launchpad/Spotlight integration. + # Upstream's CMakeLists doesn't set MACOSX_BUNDLE, so we synthesize one. + # The launcher script execs the real CLI binary in #{bin}/glabels-qt. + on_macos do + app_bundle = prefix/"glabels-qt.app" + contents = app_bundle/"Contents" + macos_dir = contents/"MacOS" + resources = contents/"Resources" + macos_dir.mkpath + resources.mkpath + + # Launcher script: 2-line shell that execs the real binary with all args. + launcher = macos_dir/"glabels-qt" + launcher.write <<~SH + #!/bin/bash + exec "#{bin}/glabels-qt" "$@" + SH + launcher.chmod 0755 + + # Info.plist: minimum keys for Launchpad/Spotlight to recognize the bundle. + (contents/"Info.plist").write <<~PLIST + + + + + CFBundleNamegLabels + CFBundleDisplayNamegLabels + CFBundleIdentifierorg.glabels.glabels-qt + CFBundleExecutableglabels-qt + CFBundleVersion#{version} + CFBundleShortVersionString#{version} + CFBundlePackageTypeAPPL + CFBundleIconFileglabels-qt.icns + LSMinimumSystemVersion10.13 + NSHighResolutionCapable + + + PLIST + + # Convert upstream PNG icon to .icns using sips (macOS built-in). + # Upstream installs hicolor PNGs at share/icons/hicolor//apps/glabels.png. + # Pick the largest available; fall back gracefully if none found. + candidate_pngs = Dir[share/"icons/hicolor/*/apps/glabels.png"].sort_by do |path| + size = path[%r{hicolor/(\d+)x\d+/}, 1].to_i + -size # largest first + end + if candidate_pngs.first + system "sips", "-s", "format", "icns", + candidate_pngs.first, + "--out", resources/"glabels-qt.icns" + else + opoo "No upstream PNG icon found; .app will use generic Mac icon." + end + end + end + + def caveats + on_macos do + <<~CAVEATS + gLabels has been installed as a CLI binary at: + #{HOMEBREW_PREFIX}/bin/glabels-qt + #{HOMEBREW_PREFIX}/bin/glabels-batch-qt + + For Launchpad / Spotlight / Dock integration, copy the .app bundle + to /Applications: + cp -R #{prefix}/glabels-qt.app /Applications/ + + (Re-run that command after each `brew upgrade glabels-qt` to refresh.) + CAVEATS + end end test do diff --git a/README.md b/README.md index dcd919a..05ad870 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,20 @@ The explicit URL form is required because Homebrew defaults to GitHub for tap names. When this repo is mirrored to GitHub at the public-flip, the URL becomes implicit and the tap command shortens to `brew tap seth/tap`. +### Launchpad / Spotlight integration (macOS) + +`brew install` puts `glabels-qt` and `glabels-batch-qt` on your `$PATH` as CLI +binaries. To get a Launchpad icon (and Spotlight matches), copy the bundled +`.app` wrapper to `/Applications/`: + +``` +cp -R "$(brew --prefix glabels-qt)/glabels-qt.app" /Applications/ +``` + +Re-run that one-liner after each `brew upgrade glabels-qt` so the wrapper +points at the latest version. (Brew formulas can't write to `/Applications/` +directly without elevation; the `cp` is the user's one-time step.) + ## Formulae | Formula | Description |