Auto launch any application or executable at startup

Overview

Auto Launch

Crates.io API reference License

Auto launch any application or executable at startup. Supports Windows, Mac (via AppleScript or Launch Agent), 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.

Or you can construct the AutoLaunch by using AutoLaunchBuilder.

Linux

On Linux, it supports hidden parameter which means that hidden the app on launch.

use auto_launch::AutoLaunch;

fn main() {
    let app_name = "the-app";
    let app_path = "/path/to/the-app";
    let auto = AutoLaunch::new(app_name, app_path, false);

    // enable the auto launch
    auto.enable().is_ok();
    auto.is_enabled().unwrap();

    // disable the auto launch
    auto.disable().is_ok();
    auto.is_enabled().unwrap();
}

Macos

Macos supports two ways to achieve auto launch (via AppleScript or Launch Agent). When the use_launch_agent is true, it will achieve by Launch Agent, otherwise by AppleScript. On Macos, it supports hidden parameter which means that hidden the app on launch.

Note:

  • The app_path should be a absolute path and exists. Otherwise, it will cause an error when enable.
  • When in the AppleScript way, the app_name should be same as the basename of app_path, or it will be corrected automately.
use auto_launch::AutoLaunch;

fn main() {
    let app_name = "the-app";
    let app_path = "/path/to/the-app.app";
    let auto = AutoLaunch::new(app_name, app_path, false, false);

    // enable the auto launch
    auto.enable().is_ok();
    auto.is_enabled().unwrap();

    // disable the auto launch
    auto.disable().is_ok();
    auto.is_enabled().unwrap();
}

Windows

On Windows, it will add a registry entry under \HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Run.

use auto_launch::AutoLaunch;

fn main() {
    let app_name = "the-app";
    let app_path = "C:\\path\\to\\the-app.exe";
    let auto = AutoLaunch::new(app_name, app_path);

    // enable the auto launch
    auto.enable().is_ok();
    auto.is_enabled().unwrap();

    // disable the auto launch
    auto.disable().is_ok();
    auto.is_enabled().unwrap();
}

Builder

AutoLaunch Builder helps to eliminate the constructor difference on various platforms.

use auto_launch::*;

fn main() -> std::io::Result<()> {
    let auto = AutoLaunchBuilder::new()
        .set_app_name("the-app")
        .set_app_path("/path/to/the-app")
        .set_use_launch_agent(true)
        .set_hidden(true)
        .build();

    auto.enable()?;
    auto.is_enabled()?;

    auto.disable()?;
    auto.is_enabled()?;

    Ok(())
}

License

MIT License. See the License file for details.

Acknowledgement

The project is based on node-auto-launch.

You might also like...
A clean and simple network looking glass application
A clean and simple network looking glass application

lg lg is my custom Looking Glass server software for use in ZZANet. The whole application is lightweight, self-contained, and easy to use even outside

01 Solana program application interface.

01 abi The abi is a repository for interfacing with the 01 program either through a rust client or through CPIs from another Solana program. Program A

A example bevy application using bevy-kajiya for its renderer
A example bevy application using bevy-kajiya for its renderer

☀️ bevy-kajiya playground A example bevy application using bevy-kajiya for its renderer NOTE: only tested on Windows. For more context, check out the

Envwoman is an application, to sync your .env-files across multiple machines

Envwoman is an application, to sync your .env-files across multiple machines. The main goal is to make Envwoman secure and trustworthy, so everything is open-source and the data will never in plain-text on the server. Encryption happens client-sided via aes-gcm.

Application that simulates a large grid of Pokémon types fighting each other.
Application that simulates a large grid of Pokémon types fighting each other.

poke-fighting-rust Rust project that simulates a grid of Pokémon fighting with each other. Each Pokémon type is a pixel on the grid and is represented

A cross-platform application for custom presence on Discord.
A cross-platform application for custom presence on Discord.

Discord Presence ⚠️ macOS is NOT supported. This is due the package for setting the presence being broken on mac. It may work for some people (only wh

Open Source Application Stack & PaaS

mycelia Open Source Application Stack & PaaS Installation cargo xtask build NOTE: We opted for cargo-xtask because Cargo build.rs is not supported for

Distrod is a meta-distro for WSL 2 which runs Systemd as init process. You can run Ubuntu, Arch, and et.c with systemd in a minute. Distrod also has built-in auto-start feature on Windows startup and port forwarding abiltiy.
Distrod is a meta-distro for WSL 2 which runs Systemd as init process. You can run Ubuntu, Arch, and et.c with systemd in a minute. Distrod also has built-in auto-start feature on Windows startup and port forwarding abiltiy.

Distrod - WSL2 Distros with Systemd! Distrod is a systemd-based meta-distro for WSL2 that allows you to install Ubuntu, Arch Linux, Gentoo and many ot

Auto-Complete is an intelligent auto-completion extension for Emacs.
Auto-Complete is an intelligent auto-completion extension for Emacs.

Auto-Complete is an intelligent auto-completion extension for Emacs. It extends the standard Emacs completion interface and provides an environment that allows users to concentrate more on their own work.

shavee is a Program to automatically decrypt and mount ZFS datasets using Yubikey HMAC as 2FA or any USB drive with support for PAM to auto mount home directories.

shavee is a simple program to decrypt and mount encrypted ZFS user home directories at login using Yubikey HMAC or a Simple USB drive as 2FA written in rust.

Minimal runtime / startup for RISC-V CPUs from Espressif

esp-riscv-rt Minimal runtime / startup for RISC-V CPUs from Espressif. Much of the code in this repository originated in the rust-embedded/riscv-rt re

Provides a single TUI-based registry for drm-free, wine and steam games on linux, accessed through a rofi launch menu.
Provides a single TUI-based registry for drm-free, wine and steam games on linux, accessed through a rofi launch menu.

eidolon A conversion of steam_suite to rust with additional features. Provides a single TUI-based registry for drm-free, wine and steam games on linux

Live Server - Launch a local network server with live reload feature for static pages

Live Server - Launch a local network server with live reload feature for static pages

A CLI tool to launch vscode projects, which supports devcontainers.

vscli A CLI tool to launch vscode projects, which supports devcontainers. Features A shorthand for launching vscode projects Detects whether a project

Simple tool to change gmsts on launch.
Simple tool to change gmsts on launch.

Starfield GMST editor A simple UI to edit Starfield GMSTs and manage your bat file mods. Features filter GMSTs revert to default mod integration merge

Standard Graphics is a command-line tool for printing 2D graphics from any language to any screen.
Standard Graphics is a command-line tool for printing 2D graphics from any language to any screen.

2D graphics in any programming language with just print statements!

A diff-based data management language to implement unlimited undo, auto-save for games, and cloud-apps which needs to retain every change.

Docchi is a diff-based data management language to implement unlimited undo, auto-save for games, and cloud-apps which needs to save very often. User'

An extension to the bevy_ecs_tilemap, allowing for configurable tilesets, auto tiling, and more
An extension to the bevy_ecs_tilemap, allowing for configurable tilesets, auto tiling, and more

bevy_ecs_tilemap_tileset A mouthful, I know. Working on a better name. An extension to the wonderful bevy_ecs_tilemap crate for Bevy, allowing for con

Rust Auto-Differentiation.

RustAD - Rust Auto-Differentiation A super restrictive rough WIP beginnings of a library attempting to implement auto-differentiation in Rust. forward

Comments
  • Please fix tests and push new vesion to crates.io

    Please fix tests and push new vesion to crates.io

    Hi!

    I'm using your crate in my app, but can't compile on macOS because the tests on the main branch are failing, and I'm pulling the latest changes because of the costume args.

    Please fix the tests and publish the new version. I tired to fix the test myselft but I didn't succeed.

    Thanks.

    opened by Levminer 2
  • feat: add support for arbitrary startup args

    feat: add support for arbitrary startup args

    previously, the hidden option simply just passed --hidden argument to the app on startup but that didn't guarantee that the app will be hidden becaue the app itself needed to handle that argument explicity so it is better to let the users pass arbitray number of args to their app on startup and handle it as they see fit

    BREAKING CHANGE: hidden option is removed and replaced with args option to pass arbitrary number of args to the binary on startup

    opened by amrbashir 1
Symbolically Executable Stack Machines in Rust

Symbolically Executable Stack Machines in Rust Symbolic Stack Machines is a library for implementing symbolically executable stack-based virtual machi

TannrA 64 Dec 28, 2022
Executable memory allocator with support for dual mapping and W^X protection

jit-allocator A simple memory allocator for executable code. Use JitAllocator type to allocate/release memory and virtual_memory module functions to e

playX 5 Jul 5, 2023
Simple library to host lv2 plugins. Is not meant to support any kind of GUI.

lv2-host-minimal Simple library to host lv2 plugins. Is not meant to support any kind of GUI. Host fx plugins (audio in, audio out) Set parameters Hos

Cody Bloemhard 11 Aug 31, 2022
dm-jitaux is a Rust-based JIT compiler using modified auxtools, dmasm and Inkwell LLVM wrapper for boosting Byond DM performance without any hassle!

dm-jitaux is a Rust-based JIT compiler using modified auxtools, dmasm and Inkwell LLVM wrapper for boosting Byond DM performance without any hassle (such as rewriting/refactroing your DM code).

SS220 20 Dec 13, 2022
Adds size optimizations to any Perseus app automatically.

Perseus Size Optimization Plugin WARNING: Until Perseus #66 is fixed, this plugin can actually increase overall binary size! Once that issue is fixed

arctic_hen7 6 Aug 14, 2022
sblade or switchblade it's a multitool in one capable of doing simple analysis with any type of data, attempting to speed up ethical hacking activities

sblade or switchblade it's a multitool in one capable of doing simple analysis with any type of data, attempting to speed up ethical hacking activities

Gabriel Correia 1 Dec 27, 2022
Federated blogging application, thanks to ActivityPub (now on https://git.joinplu.me/ — this is just a mirror)

Plume Website — Documentation — Contribute — Instances list Plume is a federated blogging engine, based on ActivityPub. It is written in Rust, with th

Plume 1.9k Jan 8, 2023
QueingSimulator is an application that can be used to build intuitions about behavior of synchronous request/reply systems

Queueing Simulator QueingSimulator is an application that can be used to build intuitions about behavior of synchronous request/reply systems (such as

Joe Magerramov 7 Sep 11, 2022
Simple tray application which shows battery level for HyperX Cloud Flight Wireless Headset.

HyperX Cloud Flight Battery Monitoring Introduction Simple tray application which shows battery level for HyperX Cloud Flight Wireless Headset. Screen

Stefan Kondinski 18 Dec 27, 2022
An application for reading comics together.

Shared comic reader Creates a web server that serves image sets to one or more clients. When one of those clients turns a page, all other clients who

null 0 Dec 17, 2021