{"id":28629748,"url":"https://github.com/fibjs/fib-launch","last_synced_at":"2025-09-01T02:41:11.575Z","repository":{"id":260410337,"uuid":"880664236","full_name":"fibjs/fib-launch","owner":"fibjs","description":"A cross-platform utility designed to manage the automatic launching of applications on system startup.","archived":false,"fork":false,"pushed_at":"2024-11-02T05:59:35.000Z","size":12,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-22T16:01:30.948Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fibjs.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-10-30T05:55:07.000Z","updated_at":"2024-11-02T05:59:38.000Z","dependencies_parsed_at":"2024-10-31T06:43:55.527Z","dependency_job_id":"6c4fc34a-8cb7-4cd8-a5f0-1fa65678888f","html_url":"https://github.com/fibjs/fib-launch","commit_stats":null,"previous_names":["fibjs/fib-launch"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/fibjs/fib-launch","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fibjs%2Ffib-launch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fibjs%2Ffib-launch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fibjs%2Ffib-launch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fibjs%2Ffib-launch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fibjs","download_url":"https://codeload.github.com/fibjs/fib-launch/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fibjs%2Ffib-launch/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273067813,"owners_count":25039907,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-01T02:00:09.058Z","response_time":120,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-06-12T12:13:27.042Z","updated_at":"2025-09-01T02:41:11.529Z","avatar_url":"https://github.com/fibjs.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# fib-launch\n\n### Overview\n`fib-launch` is a versatile and robust cross-platform utility designed to manage the automatic launching of applications on system startup. It supports a wide range of operating systems, including Windows, macOS, and Linux, providing a unified interface for registering and unregistering applications to start at login. This tool is particularly useful for developers and system administrators who need to ensure that certain applications are always running when the system starts, regardless of the operating system. By leveraging `fib-launch`, users can streamline their workflow, improve productivity, and ensure that critical applications are always available when needed.\n\n### Features\n\n- **Cross-Platform Support**: `fib-launch` works seamlessly on Windows, macOS, and Linux, making it a versatile tool for managing startup applications across different environments. This ensures that users can rely on a consistent experience regardless of the operating system they are using.\n- **Simple API**: `fib-launch` provides a straightforward API for registering and unregistering applications to start at login. This makes it easy for developers to integrate startup functionality into their applications.\n- **Lightweight**: `fib-launch` is designed to be lightweight and efficient, minimizing its impact on system resources while providing reliable startup management.\n- **Reliable**: The utility ensures that applications are consistently launched at startup, providing a dependable solution for critical applications that need to be available immediately after the system boots.\n\n## Installation\n\nTo install `fib-launch`, you need to have `fibjs` installed on your system. You can then install the package using npm:\n\n```bash\nfibjs --install fib-launch\n```\n\n## Usage\n\n### Basic Setup\n\nTo use `fib-launch`, you need to require it in your application and configure it according to your needs. Below is an example of how to set up `fib-launch`:\n\n```javascript\nconst launch = require('fib-launch');\n\nconst options = {\n    label: 'com.example.myapp',\n    script: 'path/to/your_script.js'\n};\n\nlaunch.register(options);\n```\n\n### Configuration\n\nWhile `fib-launch` does not require a specific configuration file, it is recommended to store your configuration in a JSON file for ease of management. An example configuration might look like this:\n\n```json\n{\n    \"startAtLogin\": true\n}\n```\n\nYou can load this configuration in your application as follows:\n\n```javascript\nconst fs = require('fs');\nconst path = require('path');\n\nconst configPath = path.join(require('os').homedir(), '.fib-launch', 'config.json');\nlet config = {};\n\nif (fs.existsSync(configPath)) {\n    config = JSON.parse(fs.readFileSync(configPath, 'utf8'));\n}\n\nconst options = {\n    label: 'com.example.myapp',\n    script: 'path/to/your_script.js',\n    ...config\n};\n\nlaunch.register(options);\n```\n\n### Unregistering Applications\n\nIf you need to unregister an application from starting at login, you can use the `unregister` method provided by `fib-launch`. Below is an example of how to unregister an application:\n\n```javascript\nconst launch = require('fib-launch');\n\nconst options = {\n    label: 'com.example.myapp'\n};\n\nlaunch.unregister(options);\n```\n\nBy following these instructions, you can effectively manage the automatic launching of applications on system startup using `fib-launch`.\n\n### Enhancing User Experience with System Tray\n\nAlthough `fib-launch` itself does not provide system tray functionality, you can enhance your application's user experience by integrating it with a system tray using a GUI module. Below is an example of how to set up a system tray using the `gui` module:\n\n```javascript\nconst gui = require('gui');\nconst path = require('path');\n\nconst tray = gui.createTray({\n    icon: path.resolve(__dirname, 'icon.png'),\n    menu: [\n        {\n            label: 'Open GitHub',\n            onclick: function () {\n                gui.open('https://github.com/fibjs');\n            }\n        },\n        {\n            label: 'Start at login',\n            checked: config.startAtLogin,\n            onclick: function () {\n                config.startAtLogin = this.checked;\n                save_config();\n\n                if (config.startAtLogin)\n                    launch.register(launch_config);\n                else\n                    launch.unregister(launch_config);\n            }\n        },\n        {\n            label: 'Exit',\n            onclick: function () {\n                process.exit();\n            }\n        }\n    ]\n});\n```\n\nBy following these instructions, you can effectively manage the automatic launching of applications on system startup using `fib-launch` and enhance the user experience with system tray integration.\n\n### Platform-Specific Details\n\n`fib-launch` provides a unified interface for managing startup applications across different operating systems. However, the underlying implementation varies depending on the platform. Below are the platform-specific details for Windows, macOS, and Linux.\n\n#### Windows\n\nOn Windows, `fib-launch` uses the Windows Registry to manage startup applications. Specifically, it interacts with the `HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Run` registry key. When an application is registered to start at login, an entry is added to this registry key with the application's name and the path to the executable or script. This ensures that the application is launched automatically when the user logs in.\n\n**Key Characteristics:**\n- **Registry-Based**: Uses the Windows Registry for startup management.\n- **User-Specific**: Entries are added under `HKEY_CURRENT_USER`, making them specific to the logged-in user.\n- **Executable Path**: The registry entry contains the path to the executable or script to be run at startup.\n\n#### macOS\n\nOn macOS, `fib-launch` leverages Launch Services to manage startup applications. This involves creating a property list (plist) file in the `~/Library/LaunchAgents` directory. The plist file contains key information such as the label, program arguments, and run conditions. When the user logs in, Launch Services reads the plist file and starts the specified application.\n\n**Key Characteristics:**\n- **Plist-Based**: Uses property list files for configuration.\n- **User-Specific**: Plist files are stored in the user's `~/Library/LaunchAgents` directory.\n- **Flexible Configuration**: Plist files allow for detailed configuration, including environment variables and run conditions.\n\n#### Linux\n\nOn Linux, `fib-launch` uses the `~/.config/autostart` directory to manage startup applications. It creates a desktop entry file (with a `.desktop` extension) in this directory. The desktop entry file follows the XDG Autostart specification and includes fields such as `Name`, `Exec`, and `Type`. When the user logs in, the desktop environment reads the desktop entry file and starts the specified application.\n\n**Key Characteristics:**\n- **Desktop Entry-Based**: Uses `.desktop` files for configuration.\n- **User-Specific**: Desktop entry files are stored in the user's `~/.config/autostart` directory.\n- **Standardized Format**: Follows the XDG Autostart specification, ensuring compatibility with various desktop environments.\n\n### Differences and Characteristics\n\n- **Implementation Method**: Windows uses the registry, macOS uses plist files, and Linux uses desktop entry files.\n- **Configuration Location**: Windows stores configuration in the registry, macOS in `~/Library/LaunchAgents`, and Linux in `~/.config/autostart`.\n- **User-Specific Management**: All platforms manage startup applications on a per-user basis, ensuring that configurations are specific to the logged-in user.\n- **Flexibility**: macOS and Linux offer more flexible configuration options through plist and desktop entry files, respectively, allowing for detailed startup conditions and environment settings.\n\nBy understanding these platform-specific details, you can effectively manage the automatic launching of applications on system startup using `fib-launch` across different operating systems.\n\n## Contributing\n\nWe welcome contributions to `fib-launch`. If you have any ideas, suggestions, or bug reports, please open an issue or submit a pull request on our GitHub repository.\n\n## License\n\n`fib-launch` is licensed under the ISC License. See the LICENSE file for more details.\n\n## Acknowledgements\n\nWe would like to thank the open-source community for their contributions and support.\n\n\n\n\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffibjs%2Ffib-launch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffibjs%2Ffib-launch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffibjs%2Ffib-launch/lists"}