mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-03-09 15:40:26 +00:00
added option to start hydra on system startup
This commit is contained in:
parent
5b9af9e0ea
commit
970a3be280
9 changed files with 34 additions and 27 deletions
1
src/renderer/src/declaration.d.ts
vendored
1
src/renderer/src/declaration.d.ts
vendored
|
@ -74,6 +74,7 @@ declare global {
|
|||
updateUserPreferences: (
|
||||
preferences: Partial<UserPreferences>
|
||||
) => Promise<void>;
|
||||
autoLaunch: (enabled: boolean) => Promise<void>;
|
||||
|
||||
/* Hardware */
|
||||
getDiskFreeSpace: (path: string) => Promise<DiskSpace>;
|
||||
|
|
|
@ -1,22 +0,0 @@
|
|||
import AutoLaunch from "auto-launch";
|
||||
|
||||
export const autoLaunch = () => {
|
||||
Promise.all([window.electron.getUserPreferences()]).then(
|
||||
(userPreferences) => {
|
||||
if (userPreferences && userPreferences.length > 0) {
|
||||
const appLauncher = new AutoLaunch({
|
||||
name: "Hydra",
|
||||
});
|
||||
if (userPreferences[0]?.startWithSystem) {
|
||||
appLauncher
|
||||
.enable()
|
||||
.catch((err) => console.error("Error enabling auto-launch:", err));
|
||||
} else {
|
||||
appLauncher
|
||||
.disable()
|
||||
.catch((err) => console.error("Error disabling auto-launch:", err));
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
};
|
|
@ -4,7 +4,6 @@ import { Button, CheckboxField, TextField } from "@renderer/components";
|
|||
import * as styles from "./settings.css";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { UserPreferences } from "@types";
|
||||
// import { autoLaunch } from "./auto-launch";
|
||||
|
||||
export function Settings() {
|
||||
const [form, setForm] = useState({
|
||||
|
@ -128,10 +127,10 @@ export function Settings() {
|
|||
/>
|
||||
|
||||
<CheckboxField
|
||||
label={"autoLaunch"}
|
||||
label={t("launch_with_system")}
|
||||
onChange={() => {
|
||||
updateUserPreferences("startWithSystem", !form.startWithSystem);
|
||||
// autoLaunch();
|
||||
window.electron.autoLaunch(!form.startWithSystem);
|
||||
}}
|
||||
checked={form.startWithSystem}
|
||||
/>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue