-
Notifications
You must be signed in to change notification settings - Fork 145
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add spec for login item revamp
- Loading branch information
1 parent
341a9af
commit dfaa3f8
Showing
1 changed file
with
74 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
# `app.{set|get}LoginItemSettings(settings)` | ||
|
||
## Summary | ||
|
||
`app.setLoginItemSettings(settings)` and `app.getLoginItemSettings(settings)` will be updated on macOS 13 to use a single streamlined underlying API on both Mac App Store and regular macOS builds. This will remove several configuration and settings options, including `openAsHidden` in `app.setLoginItemSettings` and `wasOpenedAtLogin` and `wasOpenedAsHidden` in `app.getLoginItemSettings`. | ||
|
||
This will simplify the underlying logic in accordance to the APIs apple has outlined for usage and improve parity between MAS and non-MAS builds. This will also allow developers to register app service objects, launch daemons, and login item services to launch on startup. | ||
|
||
## Platforms | ||
|
||
**macOS** | ||
|
||
## Impetus | ||
|
||
At present, Electron uses `LSSharedFileList` APIs to register applications as login items. These APIs have been deprecated since 10.11, and have not worked for several years on sandboxed Mac App Store builds. Chromium is also slowly [removing usage upstream](https://chromium-review.googlesource.com/c/chromium/src/+/3997795), requiring us to float increasingly deprecated code. As of Ventura, several key aspects of login item settings, | ||
namely `openAsHidden`, also no longer work. | ||
|
||
In macOS 13, Apple introduced [`SMAppService`](https://developer.apple.com/documentation/servicemanagement/smappservice?language=objc) to take the place of the APIs they phased out. This service is used to register and control `LoginItems`, `LaunchAgents`, and `LaunchDaemons` as helper executables for apps. | ||
|
||
## API Design | ||
|
||
The new methods will adhere to the following semantics: | ||
|
||
```md | ||
### `app.setLoginItemSettings(settings)` _macOS_ _Windows_ | ||
|
||
* `settings` Object | ||
* `openAtLogin` boolean (optional) - `true` to open the app at login, `false` to remove | ||
the app as a login item. Defaults to `false`. | ||
* `type` string (optional) _macOS_ - The type of service to add as a login item. Defaults to `mainAppService`. | ||
* `mainAppService` - The primary application. | ||
* `agentService` - The property list name for a launch agent. The property list name must correspond to a property list in the app’s `Contents/Library/LaunchAgents` directory. | ||
* `daemonService` string (optional) _macOS_ - The property list name for a launch agent. The property list name must correspond to a property list in the app’s `Contents/Library/LaunchDaemons` directory. | ||
* `loginItemService` string (optional) _macOS_ - The property list name for a login item service. The property list name must correspond to a property list in the app’s `Contents/Library/LoginItems` directory. | ||
* `path` string (optional) _Windows_ - The executable to launch at login. | ||
Defaults to `process.execPath`. | ||
* `args` string[] (optional) _Windows_ - The command-line arguments to pass to | ||
the executable. Defaults to an empty array. Take care to wrap paths in | ||
quotes. | ||
* `enabled` boolean (optional) _Windows_ - `true` will change the startup approved registry key and `enable / disable` the App in Task Manager and Windows Settings. | ||
Defaults to `true`. | ||
* `name` string (optional) _Windows_ - value name to write into registry. Defaults to the app's AppUserModelId(). | ||
``` | ||
|
||
```md | ||
### `app.getLoginItemSettings([options])` _macOS_ _Windows_ | ||
|
||
* `options` Object (optional) | ||
* `type` (optional) string _macOS_ - Can be one of `mainAppService`, `agentService`, `daemonService`, or `loginItemService`. Defaults to `mainAppService`. | ||
* `name` string (optional) _macOS_ - The name of the service. Required if `type` is non-default. | ||
* `path` string (optional) _Windows_ - The executable path to compare against. | ||
Defaults to `process.execPath`. | ||
* `args` string[] (optional) _Windows_ - The command-line arguments to compare | ||
against. Defaults to an empty array. | ||
|
||
If you provided `path` and `args` options to `app.setLoginItemSettings`, then you | ||
need to pass the same arguments here for `openAtLogin` to be set correctly. | ||
|
||
Returns `Object`: | ||
|
||
* `openAtLogin` boolean - `true` if the app is set to open at login. | ||
* `status` string _macOS_ - can be one of `not-registered`, `enabled`, `requires-approval`, or `not-found`. | ||
* `executableWillLaunchAtLogin` boolean _Windows_ - `true` if app is set to open at login and its run key is not deactivated. This differs from `openAtLogin` as it ignores the `args` option, this property will be true if the given executable would be launched at login with **any** arguments. | ||
* `launchItems` Object[] _Windows_ | ||
* `name` string _Windows_ - name value of a registry entry. | ||
* `path` string _Windows_ - The executable to an app that corresponds to a registry entry. | ||
* `args` string[] _Windows_ - the command-line arguments to pass to the executable. | ||
* `scope` string _Windows_ - one of `user` or `machine`. Indicates whether the registry entry is under `HKEY_CURRENT USER` or `HKEY_LOCAL_MACHINE`. | ||
* `enabled` boolean _Windows_ - `true` if the app registry key is startup approved and therefore shows as `enabled` in Task Manager and Windows settings. | ||
``` | ||
|
||
## Rollout Plan | ||
|
||
This will live in Electron `v25.0.0` and beyond. |