Skip to main content

Autostart Plugin

The Autostart plugin manages launch-at-login registration across platforms.

Installation

<dependency>
<groupId>build.krema</groupId>
<artifactId>krema-plugin-autostart</artifactId>
<version>${krema.version}</version>
</dependency>

Permissions

[permissions]
allow = ["autostart:manage"]

Platform Support

PlatformImplementation
macOSLaunchAgent in ~/Library/LaunchAgents/
WindowsRegistry key in HKCU\...\Run
LinuxDesktop entry in ~/.config/autostart/

Commands

autostart:enable

Registers the app to start at login.

const success = await window.krema.invoke('autostart:enable');

autostart:disable

Removes the app from login startup.

const success = await window.krema.invoke('autostart:disable');

autostart:isEnabled

Checks if autostart is enabled.

const enabled = await window.krema.invoke('autostart:isEnabled');

Example: Settings Toggle

async function initAutostartSetting() {
const toggle = document.getElementById('autostart-toggle');

// Set initial state
toggle.checked = await window.krema.invoke('autostart:isEnabled');

// Handle changes
toggle.addEventListener('change', async (e) => {
if (e.target.checked) {
await window.krema.invoke('autostart:enable');
} else {
await window.krema.invoke('autostart:disable');
}
});
}