AutoLaunch targets JVM platform.
repositories {
mavenCentral()
}
dependencies {
implementation("io.github.vinceglb:auto-launch:0.4.0")
}
// Create an instance of AutoLaunch.
val autoLaunch = AutoLaunch(appPackageName = "com.autolaunch.sample")
// Enable or disable launch at startup.
autoLaunch.enable()
autoLaunch.disable()
// Check if auto launch is enabled.
val isEnabled = autoLaunch.isEnabled()
// Check if the app was started by autostart.
val isStartedViaAutostart = autoLaunch.isStartedViaAutostart()
ℹ️ Note: To test the auto-launch feature, your application must be distributed. With Compose Multiplatform, you can run a distributable package using
./gradlew :runDistributable
// Get the app resolved executable path
val appPath = AutoLaunch.resolvedExecutable
// Determine whether the app is distributable
val isDistributable = AutoLaunch.isRunningFromDistributable
By default, your application path is detected automatically. You can customize the application path that will be launched at startup:
- MacOS: something like
/Applications/JetBrains Toolbox.app/Contents/MacOS/jetbrains-toolbox
. - Windows: the path to the
.exe
file.
val autoLaunch = AutoLaunch(
appPackageName = "com.autolaunch.sample",
appPath = "/path/to/your/app"
)
Depending on the platform, AutoLaunch uses the following techniques:
- MacOS: create a plist file in
~/Library/LaunchAgents/
directory. - Windows: create a registry key in
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run
. - Linux: create a
.desktop
file in~/.config/autostart/
directory.
You can find a sample project in the sample
directory. Run the following command to test the auto-launch feature:
:sample:runDistributable
Your contributions are welcome 🔥 Here are some features that are missing:
- Linux support
- Pass optional arguments to the application
Made with ❤️ by Vince