diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d23cf89..a7d577c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -14,12 +14,27 @@ jobs: name: Build for ${{ matrix.target }} runs-on: ${{ matrix.os }} strategy: + fail-fast: false matrix: include: - target: x86_64-unknown-linux-gnu os: ubuntu-22.04 + ext: "" - target: aarch64-unknown-linux-gnu os: ubuntu-22.04-arm + ext: "" + # macos-13 is the last Intel-host runner image; once GitHub retires + # it, switch this entry to `os: macos-14` and add + # `--target x86_64-apple-darwin` cross-compile (Rosetta-host build). + - target: x86_64-apple-darwin + os: macos-13 + ext: "" + - target: aarch64-apple-darwin + os: macos-14 + ext: "" + - target: x86_64-pc-windows-msvc + os: windows-latest + ext: ".exe" steps: - name: Checkout @@ -39,19 +54,47 @@ jobs: run: cargo build --release --target ${{ matrix.target }} - name: Rename binary + shell: bash run: | PACKAGE_NAME=$(cargo metadata --no-deps --format-version 1 | jq -r ".packages[0].name") - cp "target/${{ matrix.target }}/release/${PACKAGE_NAME}" "${PACKAGE_NAME}-${{ matrix.target }}" + cp "target/${{ matrix.target }}/release/${PACKAGE_NAME}${{ matrix.ext }}" "${PACKAGE_NAME}-${{ matrix.target }}${{ matrix.ext }}" - name: Upload artifact uses: actions/upload-artifact@v4 with: name: binary-${{ matrix.target }} - path: opendeck-rotary-generic-${{ matrix.target }} + path: opendeck-rotary-generic-${{ matrix.target }}${{ matrix.ext }} compression-level: 0 - package: + macos-universal: + name: Lipo macOS universal binary needs: build + runs-on: macos-14 + steps: + - name: Download macOS binaries + uses: actions/download-artifact@v4 + with: + pattern: binary-*-apple-darwin + path: macos + merge-multiple: true + + - name: Create universal binary + run: | + lipo -create \ + macos/opendeck-rotary-generic-x86_64-apple-darwin \ + macos/opendeck-rotary-generic-aarch64-apple-darwin \ + -output opendeck-rotary-generic-universal-apple-darwin + lipo -info opendeck-rotary-generic-universal-apple-darwin + + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: binary-universal-apple-darwin + path: opendeck-rotary-generic-universal-apple-darwin + compression-level: 0 + + package: + needs: [build, macos-universal] runs-on: ubuntu-latest steps: - name: Checkout @@ -67,7 +110,14 @@ jobs: run: | mkdir -p "${UUID}.sdPlugin" cp -r assets/* "${UUID}.sdPlugin/" + # Universal supersedes the per-arch macOS slices; keep payload small. + rm -f binaries/opendeck-rotary-generic-x86_64-apple-darwin \ + binaries/opendeck-rotary-generic-aarch64-apple-darwin cp binaries/* "${UUID}.sdPlugin/" + for f in "${UUID}.sdPlugin/"opendeck-rotary-generic-*-unknown-linux-gnu \ + "${UUID}.sdPlugin/"opendeck-rotary-generic-universal-apple-darwin; do + [ -f "$f" ] && chmod +x "$f" + done zip -r "${UUID}.zip" "${UUID}.sdPlugin" - name: Upload package diff --git a/Cargo.lock b/Cargo.lock index 383d12d..1c51cbf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,12 +2,6 @@ # It is not intended for manual editing. version = 4 -[[package]] -name = "anyhow" -version = "1.0.102" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f202df86484c868dbad7eaa557ef785d5c66295e41b460ef922eca0723b842c" - [[package]] name = "async-trait" version = "0.1.89" @@ -291,9 +285,8 @@ dependencies = [ [[package]] name = "opendeck-rotary-generic" -version = "0.1.0" +version = "0.2.0" dependencies = [ - "anyhow", "dashmap", "log", "openaction", diff --git a/Cargo.toml b/Cargo.toml index f9b6b16..0ee617a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,11 +1,10 @@ [package] name = "opendeck-rotary-generic" -version = "0.1.0" +version = "0.2.0" edition = "2024" license = "MIT" [dependencies] -anyhow = "1.0" dashmap = "6" log = "0.4" openaction = "2.6" diff --git a/README.md b/README.md index 316ada3..6e98ca8 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ | Clockwise rotation | CW command | | Counter-clockwise rotation | CCW command | | Short press | Press command | -| Long press (> 500 ms) | Long press command | +| Long press (> 750 ms, fires on threshold) | Long press command | All four commands are configured per-instance via the property inspector. @@ -17,9 +17,10 @@ All four commands are configured per-instance via the property inspector. Download `info.degois.damien.opendeck.plugins.rotary-command.zip` from the [releases page](../../releases) and install it through OpenDeck. -### From source +### From source (Linux) -Requires Rust toolchain. +Requires the Rust toolchain. The supplied Makefile only knows the Linux XDG +plugin path; macOS and Windows users should install from the release zip. ```sh make install @@ -37,6 +38,10 @@ make clean # remove build artifacts Cross-compile with `TARGET=aarch64-unknown-linux-gnu make build`. +> **Note on logging.** Shell commands are echoed to the log stream at debug +> level (`RUST_LOG=debug`). Avoid embedding secrets directly in the command — +> read them from a file or environment variable instead. + ## Example Volume control via PipeWire: @@ -50,7 +55,7 @@ Volume control via PipeWire: ## Acknowledgments -CI workflow inspired by [OpenActionPlugins/mpris](https://github.com/OpenActionPlugins/mpris). +CI workflow originally inspired by [OpenActionPlugins/mpris](https://github.com/OpenActionPlugins/mpris); since extended for cross-platform builds and a macOS universal binary. ## License diff --git a/assets/manifest.json b/assets/manifest.json index bb249c5..a052b0b 100644 --- a/assets/manifest.json +++ b/assets/manifest.json @@ -2,17 +2,24 @@ "Name": "Rotary Generic Command", "Description": "Run custom shell commands on rotary encoder actions (CW, CCW, press, long press)", "Author": "babs", - "Version": "0.1.0", + "Version": "0.2.0", "Icon": "icons/plugin", - "Category": "Custom", + "Category": "Rotary Encoder", "SDKVersion": 2, "OS": [ - { "Platform": "linux" } + { "Platform": "linux" }, + { "Platform": "mac" }, + { "Platform": "windows" } ], "CodePathLin": "opendeck-rotary-generic-x86_64-unknown-linux-gnu", + "CodePathMac": "opendeck-rotary-generic-universal-apple-darwin", + "CodePathWin": "opendeck-rotary-generic-x86_64-pc-windows-msvc.exe", "CodePaths": { "x86_64-unknown-linux-gnu": "opendeck-rotary-generic-x86_64-unknown-linux-gnu", - "aarch64-unknown-linux-gnu": "opendeck-rotary-generic-aarch64-unknown-linux-gnu" + "aarch64-unknown-linux-gnu": "opendeck-rotary-generic-aarch64-unknown-linux-gnu", + "x86_64-apple-darwin": "opendeck-rotary-generic-universal-apple-darwin", + "aarch64-apple-darwin": "opendeck-rotary-generic-universal-apple-darwin", + "x86_64-pc-windows-msvc": "opendeck-rotary-generic-x86_64-pc-windows-msvc.exe" }, "Actions": [ { diff --git a/assets/propertyInspector/rotary.html b/assets/propertyInspector/rotary.html index 7017b83..ad88bcd 100644 --- a/assets/propertyInspector/rotary.html +++ b/assets/propertyInspector/rotary.html @@ -64,7 +64,7 @@