Skip to content
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

Handle ignore unignore URL actions #1505

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

bric3
Copy link

@bric3 bric3 commented Oct 28, 2024

Adds the support for

  • open -g "rectangle://execute-action?name=ignore-app"
  • open -g "rectangle://execute-action?name=unignore-app"

@rxhanson
Copy link
Owner

Thanks for looking to contribute.

Rather than adding these as window actions, I recommend adding a new url query parameter that will call applicationToggle.enableFrontApp() or applicationToggle.disableFrontApp(). That way your changes are only in AppDelegate. The url stuff is at the bottom of AppDelegate.

Maybe something like rectangle://execute-task?name=ignore-app?

@bric3
Copy link
Author

bric3 commented Oct 30, 2024

What about adding a query pram for the app bundle id, so that even if IntelliJ is in background for some reason it can execute this action without affecting another app.

@bric3 bric3 marked this pull request as ready for review October 30, 2024 12:10
@rxhanson
Copy link
Owner

Sure! This looks good to me, but I can hold off on merging if you wanted to add in the bundleId query param.

@bric3
Copy link
Author

bric3 commented Oct 30, 2024

OK I'll do it shortly.

@bric3
Copy link
Author

bric3 commented Oct 30, 2024

Added app-bundle-id param for both ignore/unignore.

Rectangle/AppDelegate.swift Outdated Show resolved Hide resolved
Rectangle/AppDelegate.swift Outdated Show resolved Hide resolved
Rectangle/WindowAction.swift Outdated Show resolved Hide resolved
Rectangle/AppDelegate.swift Outdated Show resolved Hide resolved
@@ -555,17 +555,34 @@ extension AppDelegate {
func getUrlName(_ name: String) -> String {
return name.map { $0.isUppercase ? "-" + $0.lowercased() : String($0) }.joined()
}
func getAppBundleId(_ components: URLComponents) -> String? {
let appBundleId = (components.queryItems?.first { $0.name == "app-bundle-id" })?.value
return if appBundleId == nil {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for making this change here. Sorry to beleaguer this, but I figure we might as well get this tidied up.

  • What we have now can also be rewritten as return appBundleId ?? ApplicationToggle.frontAppId (hence one of the reasons why you don't typically see if come after return)
  • However, this would still be the same as return appBundleId since once we get to ApplicationToggle, we would be providing the ApplicationToggle.frontAppId at that time in the case of appBundleId being nil.
  • If we want to account for app-bundle-id= in the URL, then we would have to check that appBundleId != nil && appBundleId.isEmpty (depending on if we do indeed get back an empty string in that case - I didn't test it).

I'm still ok either way on doing the empty string check, but it still makes the most sense to me to at the very least change this to return appBundleId here.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I pushed a change in the train yesterday as a reflex, (if anything happen to the laptop).

I agree with your points; my original goal is indeed the third point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants