-
Notifications
You must be signed in to change notification settings - Fork 374
feat: add the ability to check if the app is autostart #2650
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
base: v2
Are you sure you want to change the base?
Conversation
Package Changes Through 92ce8e4There are 7 changes which include single-instance with patch, fs with minor, fs-js with minor, http with patch, http-js with patch, opener with patch, opener-js with patch Planned Package VersionsThe following package releases are the planned based on the context of changes in this pull request.
Add another change file through the GitHub UI by following this link. Read about change files or the docs at github.com/jbolda/covector |
async fn is_autostart(manager: State<'_, AutoLaunchManager>) -> Result<bool> { | ||
let process_args: Vec<String> = std::env::args().collect(); | ||
|
||
let passed_args = manager.0.get_args(); | ||
|
||
let is_autostart = passed_args.iter().all(|arg| process_args.contains(arg)); | ||
|
||
Ok(is_autostart) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is just checking if all the args used to launch the program match the ones we passed into the plugin builder, this wouldn't work if we didn't pass in anything or if we changed the args
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be used to determine whether the app was launched automatically or manually during its first startup. In the case of a manual launch, these parameters are usually not present.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, you can pass in nothing in the builder, and this wouldn't work in that case, also when you relaunch/restart your app with app.restart
, it will include all the args you previously set and that's going to be another false positive
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I really didn't think about that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are there any other approaches to determine whether an application is set to launch automatically at startup?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's fine to use command line args for this purpose, maybe a function in the builder that adds in a special cli arg to the args and we can detect if that cli arg is present or not, about the restart, that one would probably be a bit more involved since we don't have a way to change the restart cli args right now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If that's an opt-in, I'm fine with that 🙃, or we could provide some docs for people to do it in their own apps for now
Resolved #2568