Skip to content

Support 'login-items' as a first-class citizen of the CLI #19744

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

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

vraravam
Copy link

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes? Here's an example.
  • Have you successfully run brew style with your changes locally?
  • Have you successfully run brew typecheck with your changes locally?
  • Have you successfully run brew tests with your changes locally?

  1. First cut of moving login_item from under the uninstall block to the top-level
  2. Fix issues found when running brew update and brew upgrade
  3. Incorporate login_items into info command output (not yet verified)
  4. added login_items option for reinstall command

@vraravam vraravam force-pushed the login-item branch 17 times, most recently from c97b261 to eaba8a8 Compare April 12, 2025 09:42
@vraravam
Copy link
Author

Could someone please help? I am not sure if I am going in the right direction or not. Would love to get some feedback. This PR is trying to solve the #19333 ticket.

@vraravam vraravam marked this pull request as draft April 12, 2025 10:07
@vraravam vraravam force-pushed the login-item branch 4 times, most recently from 7db01f2 to ca5e83a Compare April 13, 2025 00:50
Copy link
Member

@MikeMcQuaid MikeMcQuaid left a comment

Choose a reason for hiding this comment

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

@vraravam Looks good so far! Anything specific you need help with?

@vraravam
Copy link
Author

vraravam commented Apr 14, 2025

@vraravam Looks good so far! Anything specific you need help with?

Thanks @MikeMcQuaid - I am first trying to cover all scenarios/commands from the CLI perspective, and finally will proceed to the actual implementation of the osascript calls. Hope that's fine with you?

Also, I'm trying to ensure that all code that I write have tests - if I miss something (since this is my first time contributing to this codebase, i don't know the contributing guidelines/rules), please do point me in that direction as well.

Based on the CLI commands, do you recon that I am missing any? I have tried with install, reinstall and uninstall.

@MikeMcQuaid
Copy link
Member

@vraravam Sounds good to me! When CI is 🟢 let us know and we can give this a more thorough review. CC @homebrew/cask folks for any thoughts before that, too.

homepage "https://brew.sh/"

app "Caffeine.app"
login_items "Caffeine.app"
Copy link
Member

Choose a reason for hiding this comment

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

I think the dsl here should be login_item, and repeated if there are multiple.
This will keep it consistent with the other artifacts, that aren't pluralised.

Copy link
Author

Choose a reason for hiding this comment

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

do you mean like how multiple language blocks are supported in the DSL?

Copy link
Member

Choose a reason for hiding this comment

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

I'm referring to other artifacts such as app, binary, artifact, font, qlplugin, etc..

Copy link
Author

Choose a reason for hiding this comment

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

If we look at the everything.rb DSL, there are other stanzas that are pluralized as well maybe?

@@ -13,6 +13,7 @@
==> Downloading file:.*caffeine.zip
Already downloaded: .*--caffeine.zip
==> Uninstalling Cask local-caffeine
==> Skipping processing of login_items
Copy link
Member

Choose a reason for hiding this comment

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

I have a concern that there may be side effects of skipping the uninstallation of login_items.
I understand having the option to automatically register a login_item, but is the idea here to be able to skip uninstalling them? The reason we generally aim to remove as much as possible with brew uninstall (which also runs with brew upgrade) is to not leave things behind that aren't connected to the application anymore.

What happens if the login_item changes between versions?

Copy link
Author

Choose a reason for hiding this comment

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

Agree - I was also facing the same conundrum. This is predominantly for the usecase where the user has chosen to not uninstall by using --no-login-items CLI switch. By default, the registered login items will be uninstalled (I think that's how I have coded it?)

…the top-level

Fix issues found when running brew cli commands (upgrade, update, install)
Incorporate 'login_items' into 'info' command output (not yet verified)
Incorporate 'login_items' option for 'reinstall' command
Copy link
Member

@SMillerDev SMillerDev left a comment

Choose a reason for hiding this comment

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

Two things I'm worried about here:

  • how will this work on Linux
  • more importantly: how can maintainers know the values are correct? The uninstall blocks are tested by CI, but how will this be tested?

@vraravam
Copy link
Author

vraravam commented Apr 15, 2025

* how will this work on Linux

For now, I'm only thinking of supporting macos. If needed, and if someone else can take up the work for linux, we can collaborate (I don't have a linux box to test this on)

* more importantly: how can maintainers know the values are correct? The uninstall blocks are tested by CI, but how will this be tested?

That's the reason the onus on correctness is envisioned to be with the cask's author and not at the framework/tool maintainer. This is similar to how the uninstall stanza's login-items is currently implemented.

@bevanjkay
Copy link
Member

That's the reason the onus on correctness is envisioned to be with the cask's author and not at the framework/tool maintainer. This is similar to how the uninstall stanza's login-items is currently implemented.

If we systematically add a login_item that is incorrect, does that result in a broken login item being added to the system?

@vraravam
Copy link
Author

If we systematically add a login_item that is incorrect, does that result in a broken login item being added to the system?

My assumption is the osascript will return an error code / message if an incorrect login item is tried to be added.

@SMillerDev
Copy link
Member

That's the reason the onus on correctness is envisioned to be with the cask's author and not at the framework/tool maintainer.

Not sure who the tool maintainer is in this case, but the most common scenario for casks is:

  • someone finds a cool new tool
  • makes a pull request to add a cask
  • PR gets merged
  • author is never seen again
  • others, mostly maintainers, fix the cask on updates. Often after users report it broken.

So you can see why I'd want to ensure the CI catches faulty entries here like it does for the uninstall step.

@vraravam
Copy link
Author

i see your point @SMillerDev . I am only banking on the precedent scenario of how the uninstall handles this scenario. If you have any other suggestions, I'm all ears.

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.

4 participants