From 0a0d91b0da83349b89a17ee6839e180494553199 Mon Sep 17 00:00:00 2001 From: Micah R Ledbetter Date: Tue, 14 Oct 2025 06:35:07 -0500 Subject: [PATCH] Include libadwaita and other dependencies in the app bundle on macOS (#271) * Include libadwaita and other dependencies in the app bundle on macOS * Fix missing pipes * Use recent bash for associative array support (declare -A) * Use correct path for homebrew bash on Intel macOS * Get homebrew path from the brew command * Simplify copy-macos-dylib and convert to POSIX sh Remove need for recent bash altogether * Fix permissions nit * Update macOS dylib copy script path in release workflow * fix a few typos * fix script invocation in pre-release.yml --------- Co-authored-by: Apoorv Khandelwal Co-authored-by: Ferdinand Schober --- .github/workflows/pre-release.yml | 8 ++- .github/workflows/rust.yml | 8 ++- .github/workflows/tagged-release.yml | 8 ++- README.md | 23 ++++++- dylibs/.gitignore | 1 + scripts/copy-macos-dylib.sh | 93 ++++++++++++++++++++++++++++ 6 files changed, 133 insertions(+), 8 deletions(-) create mode 100644 dylibs/.gitignore create mode 100755 scripts/copy-macos-dylib.sh diff --git a/.github/workflows/pre-release.yml b/.github/workflows/pre-release.yml index 311e46d..2b76f8b 100644 --- a/.github/workflows/pre-release.yml +++ b/.github/workflows/pre-release.yml @@ -94,7 +94,9 @@ jobs: - name: Install cargo bundle run: cargo install cargo-bundle - name: Bundle - run: cargo bundle --release + run: | + cargo bundle --release + scripts/copy-macos-dylib.sh "target/release/bundle/osx/Lan Mouse.app/Contents/MacOS/lan-mouse" - name: Zip bundle run: | cd target/release/bundle/osx @@ -120,7 +122,9 @@ jobs: - name: Install cargo bundle run: cargo install cargo-bundle - name: Bundle - run: cargo bundle --release + run: | + cargo bundle --release + scripts/copy-macos-dylib.sh "target/release/bundle/osx/Lan Mouse.app/Contents/MacOS/lan-mouse" - name: Zip bundle run: | cd target/release/bundle/osx diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index f5569e5..778e05e 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -112,7 +112,9 @@ jobs: - name: Install cargo bundle run: cargo install cargo-bundle - name: Bundle - run: cargo bundle + run: | + cargo bundle + scripts/copy-macos-dylib.sh - name: Zip bundle run: | cd target/debug/bundle/osx @@ -142,7 +144,9 @@ jobs: - name: Install cargo bundle run: cargo install cargo-bundle - name: Bundle - run: cargo bundle + run: | + cargo bundle + scripts/copy-macos-dylib.sh - name: Zip bundle run: | cd target/debug/bundle/osx diff --git a/.github/workflows/tagged-release.yml b/.github/workflows/tagged-release.yml index d047bb6..0892589 100644 --- a/.github/workflows/tagged-release.yml +++ b/.github/workflows/tagged-release.yml @@ -90,7 +90,9 @@ jobs: - name: Install cargo bundle run: cargo install cargo-bundle - name: Bundle - run: cargo bundle --release + run: | + cargo bundle --release + scripts/copy-macos-dylib.sh "target/release/bundle/osx/Lan Mouse.app/Contents/MacOS/lan-mouse" - name: Zip bundle run: | cd target/release/bundle/osx @@ -116,7 +118,9 @@ jobs: - name: Install cargo bundle run: cargo install cargo-bundle - name: Bundle - run: cargo bundle --release + run: | + cargo bundle --release + scripts/copy-macos-dylib.sh "target/release/bundle/osx/Lan Mouse.app/Contents/MacOS/lan-mouse" - name: Zip bundle run: | cd target/release/bundle/osx diff --git a/README.md b/README.md index b3ad523..802b4e1 100644 --- a/README.md +++ b/README.md @@ -83,7 +83,6 @@ paru -S lan-mouse-git
Fedora - You can install Lan Mouse from the [Terra Repository](https://terra.fyralabs.com). @@ -94,6 +93,18 @@ dnf install lan-mouse ```
+
+ MacOS + +- Download the package for your Mac (Intel or ARM) from the releases page +- Unzip it +- Remove the quarantine with `xattr -rd com.apple.quarantine "Lan Mouse.app"` +- Launch the app +- Grant accessibility permissions in System Preferences + +
+ +
Manual Installation @@ -172,7 +183,15 @@ For a detailed list of available features, checkout the [Cargo.toml](./Cargo.tom MacOS ```sh -brew install libadwaita pkg-config +# Install dependencies +brew install libadwaita pkg-config imagemagick +cargo install cargo-bundle +# Create the macOS icon file +scripts/makeicns.sh +# Create the .app bundle +cargo bundle +# Copy all dynamic libraries into the bundle, and update the bundle to find them there +scripts/copy-macos-dylib.sh ```
diff --git a/dylibs/.gitignore b/dylibs/.gitignore new file mode 100644 index 0000000..72e8ffc --- /dev/null +++ b/dylibs/.gitignore @@ -0,0 +1 @@ +* diff --git a/scripts/copy-macos-dylib.sh b/scripts/copy-macos-dylib.sh new file mode 100755 index 0000000..f2ba501 --- /dev/null +++ b/scripts/copy-macos-dylib.sh @@ -0,0 +1,93 @@ +#!/bin/sh +set -eu + +homebrew_path="" +exec_path="target/debug/bundle/osx/Lan Mouse.app/Contents/MacOS/lan-mouse" + +usage() { + cat < $dest" + cp -f "$old_path" "$dest" + # Ensure the copied dylib is writable so that xattr -rd /path/to/Lan\ Mouse.app works. + chmod 644 "$dest" + + echo "Updating $dest to have install_name of @rpath/$base_name..." + install_name_tool -id "@rpath/$base_name" "$dest" + + # Recursively process this dylib + fix_references "$dest" + fi + + echo "Updating $bin to reference @rpath/$base_name..." + install_name_tool -change "$old_path" "@rpath/$base_name" "$bin" + done +} + +fix_references "$exec_path" + +# Ensure the main executable has our Frameworks path in its RPATH +if ! otool -l "$exec_path" | grep -q "@executable_path/../Frameworks"; then + echo "Adding RPATH to $exec_path" + install_name_tool -add_rpath "@executable_path/../Frameworks" "$exec_path" +fi + +# Se-sign the .app +codesign --force --deep --sign - "$bundle_path" + +echo "Done!"