Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 53 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
9 changes: 1 addition & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
13 changes: 9 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -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
Expand All @@ -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:
Expand All @@ -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

Expand Down
15 changes: 11 additions & 4 deletions assets/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
{
Expand Down
2 changes: 1 addition & 1 deletion assets/propertyInspector/rotary.html
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
<div class="field">
<label for="long_press_command">Long Press Command</label>
<input type="text" id="long_press_command" placeholder="e.g. pavucontrol" />
<div class="hint">Shell command to run on long press (hold &gt; 500ms).</div>
<div class="hint">Shell command to run on long press (hold &gt; 750ms; fires as soon as the threshold is reached).</div>
</div>

<script>
Expand Down
8 changes: 7 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,14 @@ use openaction::{register_action, run};

#[tokio::main]
async fn main() {
// Honor RUST_LOG as a plain level (off|error|warn|info|debug|trace); the
// README documents this knob for command-echo debug logging.
let level = std::env::var("RUST_LOG")
.ok()
.and_then(|s| s.parse::<log::LevelFilter>().ok())
.unwrap_or(log::LevelFilter::Info);
if let Err(e) = simplelog::TermLogger::init(
log::LevelFilter::Info,
level,
simplelog::Config::default(),
simplelog::TerminalMode::Stdout,
simplelog::ColorChoice::Never,
Expand Down
Loading