Auto Launch
Auto launch any application or executable at startup. Supports Windows, macOS (Launch Agent, AppleScript, or SMAppService), and Linux.
How does it work? See Teamwork/node-auto-launch for details.
If you find any bugs, welcome to PR or issue.
Usage
The parameters of AutoLaunch::new are different on each platform.
See the function definition or the demo below for details.
AutoLaunchBuilder helps to eliminate the constructor difference on various platforms.
use *;
Linux
Linux supports two ways to achieve auto launch:
- XDG Autostart: Uses
.desktopfiles in~/.config/autostart/(default) - systemd: Uses systemd user services in
~/.config/systemd/user/- Uses
systemctl --user enableto enable the service. - Requires
systemctlto be available in the environment.
- Uses
use ;
macOS
macOS supports three ways to achieve auto launch:
- Launch Agent: Uses plist files in
~/Library/LaunchAgents/(default) - AppleScript: Uses AppleScript to add login items
- SMAppService: Uses the SMAppService API (macOS 13+)
Note:
- The
app_pathshould be an absolute path and exists. Otherwise, it will cause an error whenenable. - In case using AppleScript, the
app_nameshould be same as the basename ofapp_path, or it will be corrected automatically. - In case using AppleScript, only
--hiddenand--minimizedinargsare valid, which means that hide the app on launch. - In case using SMAppService,
app_nameandapp_pathcan be empty strings because it registers the running app.
use ;
Windows
On Windows, it will add registry entries under:
\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run(system)\HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Run(current user)\HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\StartupApproved\Run(Task Manager status)
It will also detect if startup is disabled inside Task Manager or the Windows settings UI, and can re-enable after being disabled in one of those.
Enable behavior is controlled by WindowsEnableMode:
Dynamic(default): try system-wide, fall back to current user on access deniedCurrentUser: write to current user onlySystem: write to system only (admin required)
use ;
License
MIT License. See the License file for details.
Acknowledgement
The project is based on node-auto-launch.