rxhanson / Rectangle

Move and resize windows on macOS with keyboard shortcuts and snap areas
https://rectangleapp.com
Other
25.87k stars 777 forks source link

Execute action by URL #925

Closed decodism closed 2 years ago

decodism commented 2 years ago

For basic scripting.

rxhanson commented 2 years ago

Nice! I didn't think about that way to do it. I'll start sponsoring you through GitHub sponsors if you wanted to set it up.

decodism commented 2 years ago

I didn't think about that way to do it.

The two main constraints I see with this way are the unidirectionality of the communication and the need for the caller not to activate Rectangle.

I'll start sponsoring you through GitHub sponsors if you wanted to set it up.

That's generous but I don't plan to become a regular contributor.

sentiasa commented 1 year ago

Can you please show an example for this?

When I tried open -g "rectangle://execute-action?name=left-half"

No application knows how to open URL rectangle://execute-action?name=left-half (Error Domain=NSOSStatusErrorDomain Code=-10814 "kLSApplicationNotFoundErr: E.g. no application claims the file" UserInfo={_LSLine=1489, _LSFunction=runEvaluator}).
rxhanson commented 1 year ago

@sentiasa this likely means that macOS hasn't made the association with the app. Maybe try uninstalling the app and reinstalling, or restarting your Mac.

sentiasa commented 1 year ago

@rxhanson great, it worked. I run it in my terminal and it placed the terminal successfully.

I was looking to achieve, for example, open phpstorm and place it left-half. Would this approach work with this? If so, how can I give application name to this command?

Maybe something like: open -g "rectangle://execute-action?name=left-half&app=phpstorm"

Or is it not possible to achieve this with execute action command?

rxhanson commented 1 year ago

@sentiasa These commands in Rectangle are the equivalent of executing the keyboard shortcut; there is no support for associating an app with the command at this time.

You can achieve this in Rectangle Pro (paid), by creating an "App Layout" and triggering that App Layout via URL (see https://github.com/rxhanson/RectanglePro-Community#programmatically-triggering-window-sizes--positions)

For future conversation on this topic, please create a new discussion in GitHub.