feat: expose transcription over dbus for wayland support
Add Wayland/Hyprland Support via D-Bus
What This Does
Adds support for Wayland/Hyprland! I implemented most of this PR with Claude Sonnet 4.5 and it works consistently in my testing.
The Problem
I'm on Hyprland (Wayland) and ran into two major issues:
- Global keyboard shortcuts don't work - Wayland handles shortcuts differently than X11
- Chrome ignores the transcription - Chrome/Chromium on Wayland blocks synthetic keyboard input for security, so even when transcription completed, nothing would paste into the browser
The Solution
D-Bus Interface
Added a D-Bus service so you can trigger transcription via system commands instead of global shortcuts:
# Start transcription
busctl --user call com.pais.Handy /com/pais/Handy com.pais.Handy.Transcription StartTranscription
# Stop transcription
busctl --user call com.pais.Handy /com/pais/Handy com.pais.Handy.Transcription StopTranscription
You can bind these to keys in your Hyprland config:
bind = SUPER, R, exec, busctl --user call com.pais.Handy /com/pais/Handy com.pais.Handy.Transcription StartTranscription
bindrt = SUPER, R, exec, busctl --user call com.pais.Handy /com/pais/Handy com.pais.Handy.Transcription StopTranscription
wtype Integration for Chrome
Chrome blocks synthetic input from libraries like enigo, so I added support for wtype (a Wayland-native text input tool). When you set the paste method to "Direct Input" in settings, it automatically uses wtype on Wayland, which Chrome trusts.
Install with: sudo pacman -S wtype (or your distro's equivalent)
Focus Handling
The app now captures which window has focus before showing the overlay, then restores it before pasting. This ensures the text goes to the right place (using hyprctl for Hyprland).
What Changed
-
New files:
src-tauri/src/dbus.rs- D-Bus interface implementation
-
Modified files:
src-tauri/src/clipboard.rs- Added wtype supportsrc-tauri/src/overlay.rs- Added focus capture/restoresrc-tauri/src/actions.rs- Calls focus restoration before pastingsrc-tauri/src/shortcut.rs- Detects Wayland and disables shortcutssrc-tauri/src/lib.rs- Initializes D-Bus servicesrc-tauri/Cargo.toml- Added zbus dependencies
Automatic Behavior
The app automatically:
- Detects Wayland sessions (via
WAYLAND_DISPLAYenv var) - Disables keyboard shortcuts on Wayland (they don't work anyway)
- Shows helpful log messages about using D-Bus instead
- Uses
wtypewhen available and on Wayland
On X11, everything works exactly as before - no changes to the existing behavior.
Question for Maintainer
I'm disabling the old keybinding system on Wayland since I'm pretty sure they don't work for anyone on Wayland (that's the whole reason I needed D-Bus). But I'm not 100% certain - it could just be my setup. Let me know if you think this should be optional instead of automatic!
Testing
Tested on Arch Linux with Hyprland. Works consistently with:
- VSCode ✅
- Discord ✅
- Chrome/Chromium ✅ (with wtype)
Wow big thank you for this! I won't be able to test near-term, but I definitely will try and get a build kicked off sometime soon so others can test
I'm going to mention this in the discord so people can test there too
@tbezman could you also take a look at #281
im curious if adding the Wayland flag to enigo will obviate the need for paste_via_wtype?
might slim down this change a bit
@cjpais heads up my wife is in labor so i won't be carrying this one over the finish line anytime soon 😂
@tbezman hahahha congratulations! hope it goes well!
@tbezman could you also take a look at #281
im curious if adding the Wayland flag to enigo will obviate the need for
paste_via_wtype?might slim down this change a bit
FYI, enigo wayland feature is a deadend as discussed in https://github.com/cjpais/Handy/pull/320#issuecomment-3508924115.