autostart
stableGenerate platform-appropriate shell commands and entry descriptors to register or remove application autostart entries on Windows, macOS, and Linux.
use plugin autostart::{registry_path, create_entry, create_shortcut_command, …} Functions (9)
- registry_path Return the platform autostart location
- create_entry Build an autostart entry descriptor
- create_shortcut_command Generate a shell command to add autostart
- remove_command Generate a shell command to remove autostart
- is_supported Check if autostart is supported on this OS
- platform Return the current OS name string
- check_command Generate a command to check if entry exists
- create_entry_with_args Build an entry descriptor with extra args
- status_command Generate a command to query entry status
Overview
The autostart plugin helps you register applications to launch when the user logs in, across Windows, macOS, and Linux. Rather than touching the registry or filesystem directly, it is a pure command-and-descriptor generator: functions return either a data table describing the entry or a ready-to-run shell command string that you execute with your own shell runner. The location it targets is platform-specific — the Windows Run registry key, a macOS LaunchAgents plist, or a Linux .config/autostart .desktop file — and helpers like platform and is_supported let you branch on the host OS. Reach for this plugin when you need cross-platform "start on login" behavior without bundling a native installer.
Common patterns
Build an entry and immediately get the command that installs it:
use plugin autostart::{is_supported, create_entry, create_shortcut_command}
if is_supported() {
let entry = create_entry("MyApp", "/usr/local/bin/myapp")
print("registering {entry["name"]} at {entry["location"]}")
let cmd = create_shortcut_command("MyApp", "/usr/local/bin/myapp")
print(cmd)
// hand cmd to your shell runner to actually install the entry
}
Branch on the platform before emitting a check command:
use plugin autostart::{platform, check_command, status_command}
print("host: {platform()}")
print(check_command("MyApp")) // prints FOUND / NOT_FOUND when run
print(status_command("MyApp")) // prints live load/enabled status when run
Register an app that needs startup flags, then clean it up later:
use plugin autostart::{create_entry_with_args, remove_command}
let entry = create_entry_with_args("MyApp", "/usr/bin/myapp", "--minimized --tray")
print("startup command: {entry["command"]}")
print("uninstall with: {remove_command("MyApp")}")
Return the platform autostart location
Returns the platform-specific autostart location path:
- Windows:
HKCU\Software\Microsoft\Windows\CurrentVersion\Run - macOS:
~/Library/LaunchAgents/ - Linux:
~/.config/autostart/
use plugin autostart::{registry_path, platform}
print("platform: {platform()}")
print("autostart location: {registry_path()}")
Build an autostart entry descriptor
Returns a table describing an autostart entry with name, path, platform, and location fields. This is a data descriptor — pass create_shortcut_command to get the shell command that actually writes the entry.
use plugin autostart::{create_entry}
let entry = create_entry("MyApp", "/usr/local/bin/myapp")
print(entry["name"])
print(entry["location"])
The descriptor also carries the resolved platform, so you can log or inspect
where the entry would land before installing it:
use plugin autostart::{create_entry}
let entry = create_entry("Backup", "/opt/backup/run")
print("{entry["name"]} -> {entry["path"]} ({entry["platform"]})")
Generate a shell command to add autostart
Returns a platform-specific shell command string that, when executed, registers app_path as an autostart entry under app_name:
- Windows: a
reg addcommand - macOS: a
cat > ~/Library/LaunchAgents/...plistcommand - Linux: a
cat > ~/.config/autostart/...desktopcommand
use plugin autostart::{create_shortcut_command}
let cmd = create_shortcut_command("MyApp", "/usr/local/bin/myapp")
print(cmd)
// Execute the command with your preferred shell runner
Pair it with is_supported so you only emit the command on platforms that can
honor it:
use plugin autostart::{is_supported, create_shortcut_command}
if is_supported() {
print(create_shortcut_command("Daemon", "/usr/sbin/myd"))
} else {
print("autostart not available on this OS")
}
Generate a shell command to remove autostart
Returns a platform-specific shell command that removes the autostart entry for app_name.
use plugin autostart::{remove_command}
let cmd = remove_command("MyApp")
print(cmd)
Check if autostart is supported on this OS
Returns true when running on Windows, macOS, or Linux. Returns false on other platforms where autostart management is not implemented.
use plugin autostart::{is_supported}
if is_supported() {
print("autostart is available")
}
Return the current OS name string
Returns "windows", "macos", "linux", or "unknown" depending on the OS the plugin was compiled for.
use plugin autostart::{platform}
let os = platform()
print("running on {os}")
Generate a command to check if entry exists
Returns a shell command that checks whether the autostart entry for app_name exists, printing FOUND or NOT_FOUND to stdout.
use plugin autostart::{check_command}
let cmd = check_command("MyApp")
print(cmd)
// Run cmd in a shell to detect if entry is registered
Build an entry descriptor with extra args
Like create_entry, but also includes args and a combined command field ("app_path args"). Use this when the app requires command-line arguments at startup.
use plugin autostart::{create_entry_with_args, create_shortcut_command}
let entry = create_entry_with_args("MyApp", "/usr/bin/myapp", "--minimized --tray")
print(entry["command"])
When args is empty the command field collapses to just the path, so the
same call works for apps with and without flags:
use plugin autostart::{create_entry_with_args}
let plain = create_entry_with_args("MyApp", "/usr/bin/myapp", "")
print(plain["command"]) // "/usr/bin/myapp"
Generate a command to query entry status
Returns a shell command that queries the current autostart status for app_name (e.g. whether it is loaded on macOS via launchctl, or enabled on Linux via the .desktop file).
use plugin autostart::{status_command}
let cmd = status_command("MyApp")
print(cmd)
// Run cmd in a shell to get the live status