Only bind F9 to Voxtype if installed (#5882) - #5897
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Conditionally bind the F9 push-to-talk dictation keys only when the voxtype command is available, using a new has_command helper.
Changes:
- Added
o.has_commandhelper that shells out toomarchy-cmd-presentto detect installed commands. - Wrapped the F9 push-to-talk bindings in a
has_command("voxtype")guard.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| default/hypr/helpers.lua | Adds has_command helper for detecting available CLI commands. |
| default/hypr/bindings/utilities.lua | Guards F9 voxtype bindings behind the new has_command check. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| o.bind("SUPER + CTRL + X", "Toggle dictation", "voxtype record toggle") | ||
| o.bind("F9", "Start dictation (push-to-talk)", "voxtype record start") | ||
| o.bind("F9", "Stop dictation (push-to-talk)", "voxtype record stop", { release = true }) | ||
|
|
||
| if o.has_command("voxtype") then | ||
| o.bind("F9", "Start dictation (push-to-talk)", "voxtype record start") | ||
| o.bind("F9", "Stop dictation (push-to-talk)", "voxtype record stop", { release = true }) | ||
| end |
| local output = handle and handle:read("*a") or "" | ||
| if handle then handle:close() end | ||
| return output:match("1") ~= nil | ||
| end |
There was a problem hiding this comment.
Never wrote LUA, but I was wondering why this code is so complicated. Would this just work instead?
function o.has_command(cmd)
return os.execute("omarchy-cmd-present " .. shell_quote(cmd)) == true
endThere was a problem hiding this comment.
This does not work. Like I said in the PR comment, os.execute never receives the exit code of the command when run live in Hyprland. Your code works fine if you run it straight through Lua or the LuaJIT, just not when Hyprland runs it. I do not really know why but you are free to try on your machine.
|
I like this PR, as the bind on F9 is really inconvenient and I don't use voxtype. (F9 is the default for toggling a breakpoint in VSCode) |
|
I think I'd rather that we add a lua rule as a toggle when voxtype is installed and remove it when uninstalled. Like we do for the single-window-aspect-ratio.lua. Then we don't need any runtime checks. |
|
In general, Omarchy should probably namespace almost all its own binds behind SUPER or CAPS LOCK as otherwise the potential for conflict with individual applications is just too high. F9 is also used in mc, IntelliJ and many more... |
|
This specific keybind needs a single key for activation, so that just is what it is. But it's your system, so you can always change how it works. |
|
@dhh Reworked. Is this what you meant? |
Only bind F9 to Voxtype if installed (#5882)
Fixes #5882
Currently, F9 is globally bound to Voxtype dictation, which overrides default app bindings even for users who don't have it installed.
This PR:
utilities.luaonly if thevoxtypecommand is present.o.has_commandhelper inhelpers.lua. Had to useio.popeninstead of an inlineif os.execute("omarchy-cmd-present voxtype")...for this because Hyprland intercepts theSIGCHLDsignal. This causesos.executeto miss the child's exit code (returningnilwith anECHILD"No child processes" error), making it fail silently. Readingstdoutvia.popensolves this.No migration needed.
This is my first proper PR, so I apologize for any oversights on contribution standards; couldn't really find any.