Skip to content

About

Local Surface Dial media controls for macOS and Linux: exponential volume, multi-click gestures, held-turn seeking and visible Mac status.

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

Surface Dial Control

Turn a Microsoft Surface Dial into a local media controller on macOS and Linux.

Fine volume adjustments when you turn slowly, a smooth exponential ramp when you spin quickly, and familiar media controls from the Dial's button. The Mac client includes a visible menu-bar indicator with connection status, the last action, Pause/Resume and Quit.

Controls

Gesture Action
Turn Output volume, with smooth 1–8 percentage-point acceleration
Single click Play/pause
Double click Next track
Triple click Previous/restart, following the player's behavior
Hold down and turn Seek backward/forward in five-second steps

Single click waits 320 ms after release to distinguish double/triple clicks. Releasing after a held turn never toggles playback. An unassigned long hold does nothing.

Volume changes stay within 0–100%, never automatically unmute, and stop if the selected output changes. The speed curve uses input timestamps, ramps up gradually, and returns to fine control on reversal, pause or reconnect. Output updates are capped at five per second.

macOS

Requires Python 3.9+ and a Swift compiler, available with Xcode or the Command Line Tools. No Python packages are required.

git clone https://github.com/StoneHub/surface-dial-control.git
cd surface-dial-control
./scripts/build-mac.sh
./scripts/run-mac.sh

Pair the Dial in macOS Bluetooth settings. Its vendor/product IDs are 045e:091b. The capture helper opens only that device.

A small dial icon appears in the menu bar. It shows Connected, Waiting or Paused, plus the last action. Use Pause controls or Quit controller there. The default session runs until stopped; ./scripts/run-mac.sh --seconds 600 explicitly selects a timed test. Closing the launching terminal/session can also stop the controller. This does not install a login item.

The helpers check existing input/event access and report a clear failure when access is unavailable. Depending on macOS and the launch context, enable the appropriate Input Monitoring/Accessibility access for your launcher in System Settings. The program does not grant permissions itself.

Playback and scrubbing

Play/pause and next/previous use normal macOS media-key events and follow the active media player. Volume uses CoreAudio on the explicitly selected current output.

Scrubbing on the Mac currently targets Spotify's Safari web player. Keep that tab in front and focus outside text fields and sliders. The seek helper verifies Safari, the HTTPS open.spotify.com URL and focus before sending Spotify's Command–Shift–Left/Right shortcut. When another app/site is active, it blocks seeking and the menu-bar indicator explains why. It does not activate or navigate Safari. Other players can be added behind this backend interface.

Linux

Requires Python 3.9+, an existing Bluetooth LE controller/BlueZ setup, readable input access for the paired Dial, pactl, busctl and a user D-Bus session. The client uses Python's standard library to read evdev; it installs no Python dependencies.

The client discovers only Surface Dial multi-axis input nodes, verifies their identity again after opening, and reconnects when the device returns. It does not read unrelated keyboards or mice. The installer does not pair devices, load drivers, add groups or install udev rules. Arrange access to the exact Dial node using your distribution's device-access policy.

Choose an explicit PipeWire/PulseAudio sink and an explicit MPRIS player, or a systemd user service whose main process owns the browser's MPRIS name:

# Discover the output you intend to control:
pactl get-default-sink

# Use the actual MPRIS name from your user session:
python3 scripts/install-linux.py \
  --sink YOUR_SINK_NAME \
  --player org.mpris.MediaPlayer2.YOUR_PLAYER

# Alternative: resolve the player from its existing user service's MainPID:
python3 scripts/install-linux.py \
  --sink YOUR_SINK_NAME \
  --player-service YOUR_BROWSER.service

The installer copies a clean committed revision to a versioned user-local release, writes a configuration and installs the user service. It preserves differing existing configuration instead of overwriting it. It does not enable or start the service.

Read capabilities first:

cd ~/.local/share/surface-dial-control/current
python3 -m dial_control.linux --diagnose
python3 -m dial_control.linux --dry-run

Diagnostics are read-only. Exit code 2 means a required capability is not ready, including a missing Dial. Dry run reads only the Dial and prints proposed actions.

When the receiver, pairing, input access and actual player controls are verified:

systemctl --user start surface-dial-control.service
journalctl --user -u surface-dial-control.service -f

# Optional, only when you want it on future user sessions:
systemctl --user enable surface-dial-control.service

# Stop it:
systemctl --user stop surface-dial-control.service

The Linux backend checks MPRIS capabilities before each media command. Seeking uses relative Seek calls and needs CanSeek. Browser MPRIS exposure alone does not establish that its active tab can play or seek. There is no fallback to all players or another output sink.

Validation status

  • macOS / Apple silicon: paired Dial input, both rotation directions, output volume, play/pause, exponential acceleration, multi-click controls and held-turn scrubbing were tested hands-on with Safari Spotify. The menu-bar indicator was confirmed visible. Long sleep, relaunch and automatic-login behavior remain separate checks.
  • Linux: input decoding, identity filtering, player ownership/capability checks, seek units, output targeting and volume limits have fixture coverage. A physical Bluetooth adapter/Dial end-to-end test is pending.
  • 27 automated checks cover gesture timing, accidental-click suppression, acceleration/reset behavior, Linux input filtering and media/audio boundaries.
PYTHONDONTWRITEBYTECODE=1 python3 -m unittest discover -s tests -v

Structure

  • dial_control/gestures.py: platform-independent button/turn gestures.
  • dial_control/volume_acceleration.py: shared exponential volume feel.
  • dial_control/mac.py and native/: Mac capture, native media/audio actions and menu-bar UI.
  • dial_control/linux.py, linux_input.py, linux_backend.py: restricted evdev input, MPRIS and PipeWire/PulseAudio.
  • scripts/install-linux.py: user-local, versioned install with inactive service by default.

The per-event control loop is deterministic and local. OpenClaw can assist with setup and higher-level requests; it is not needed for each click or detent.

Acknowledgements

Mac Dial helped establish the macOS report layout and media-key event pattern. Its MIT notice is retained in LICENSES/. surface-dial-linux informed Linux compatibility and evdev research; its Rust code is not included. See NOTICE.md.

MIT license.

About

Local Surface Dial media controls for macOS and Linux: exponential volume, multi-click gestures, held-turn seeking and visible Mac status.

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages