-
-
Notifications
You must be signed in to change notification settings - Fork 155
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature Request: Embedded script language #560
Comments
Thanks both to you and @jakenvac (#278 (comment)) for taking in-depth look at the problem. It's good to see people doing such investments. Very much appreciated! I didn't even know about the existance of JavaScriptCore in macOS SDK. However, right now, I don't plan to introduce any embedded scripting programming language. AeroSpace is not a framework like Hammerspoon. I want AeroSpace to be designed as "ready to go" solution. AeroSpace is optimized for specific workflows and adds just enough of extensibility. If users want something beyond, well - sorry. As a supportive argument I want to mention Helix vs Neovim approaches. I'm very much for Helix approach of all batteries included and sensible defaults. If users want to do scripting, they should do it outside of the AeroSpace configuration in whatever users' favorite programming language. All AeroSpace query commands should support About my suggestion in #278. I don't want it to be a programming language. Initially, I thought to only include on-window-detected = '''
test %{app-bundle-id} == org.jetbrains.intellij && move-node-to-workspace I
|| test %{app-bundle-id} == com.google.chrome && move-node-to-workspace W
''' but then I realized the common gotcha https://www.shellcheck.net/wiki/SC2015, and it, unfortunatelly, made me think about the on-window-detected = '''
if test %{app-bundle-id} == org.jetbrains.intellij do
move-node-to-workspace I
elif test %{app-bundle-id} == com.google.chrome do
move-node-to-workspace W
end
''' Regarding #60, I think the current go to solution is I'd very happy if we managed to simplify |
Thank you for sharing your perspective on this, and I completely understand where you're coming from. The vision of AeroSpace as a "ready-to-go" solution, optimized for specific workflows with sensible defaults, definitely has its strengths. My only concern is the potential latency introduced when triggering external programs (which may then query properties, such as windows count, etc.), but without the actual measurements, I wouldn't worry too much.
|
Latency is my main issue when shelling out for custom behaviors (I integrate my window manager with my terminal mux), but after reading @nikitabobko's justifications for wanting a batteries included solution I think it makes sense to not implement a scripting language. I think there are other ways we can alleviate the latency, such as the async/threaded AX requests discussed in #497. Combine this with improved JSON and Callback support, I think shell scripting will augment Aerospace nicely. On top of this, if it were possible to set config options via the cli, as discussed in #355 then you could essentially define your config as a shell script if you so desired. |
One of the things that I was thinking about and would like to add to this discussion is that targeting developers is a core project value:
I think, as a developer, the most important thing I would want is the ability to customize my tools to make them work the way I want to fit my workflow. In some sense, it is a philosophical difference because I would always chose neovim over helix for this reason, so perhaps we just disagree on what to do. In that case, I would, of course, defer to your vision of what aerospace would be. Handling scripting outside of the configuration would be a neat approach and honestly, the improvements discussed about reducing the latency would be sufficient for this. Right now, to properly handle visible workspaces being highlighted in sketchybar for example, I need to call an |
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
I'd like to discuss embedding a scripting language into AeroSpace to enable more flexible customization and configuration. Currently, AeroSpace supports limited "dynamic" behavior, such as the
on-window-detected
callback with a matcher. However, there's a growing need for more advanced conditional behavior (see #278). Instead of turning TOML into a pseudo-programming language, would it make sense to support scripting directly?Does this feature align with the project's values?
If the answer is yes, then I'd like to discuss the following questions:
Which scripting language would be the best fit?
Two options come to mind:
There is also a Lua 5.1 JIT implementation, though there are known performance issues on aarch64: LuaJIT/LuaJIT#285
What features should the API support?
Some of my ideas:
My current probe/research
I have the same issue as #60, and I wanted more generic solution, so I have been probing/researching how well Lua fits into AeroSpace's current architecture, and I had promising results. Some of my testing can be found in my
probe-lua
branch. Lua integrates smoothly with the current config and callback system. For example, I implemented dynamic gaps for my ultrawide monitor:The branch implements a lightweight Lua 5.1 wrapper for Swift (chosen for easy switch to LuaJIT) and abstractions for adding new API functions with type-checked parameters. However, it has evolved organically (based on what I currently needed to implement feature X), so the wrapper needs some refactoring/remodeling; for example, the error handling is pretty much via the
error
function that kills the app.Supported features:
The currently implemented API functions can be found:
aero.api
: https://github.com/Henkru/AeroSpace/blob/lua-probe/Sources/AppBundle/script/api.swiftaero.callbacks
: https://github.com/Henkru/AeroSpace/blob/lua-probe/Sources/AppBundle/script/callbacks.swiftaero.config
: https://github.com/Henkru/AeroSpace/blob/lua-probe/Sources/AppBundle/script/configApi.swiftaero.keymap
: https://github.com/Henkru/AeroSpace/blob/lua-probe/Sources/AppBundle/script/keymap.swiftAreas for improvement:
For a more comprehensive example, I fully implemented my current configuration in Lua to showcase what can be done.
The text was updated successfully, but these errors were encountered: