mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-03-09 15:40:26 +00:00
initial commit
This commit is contained in:
parent
21296cba95
commit
5b9af9e0ea
6 changed files with 78 additions and 0 deletions
22
src/renderer/src/pages/settings/auto-launch.ts
Normal file
22
src/renderer/src/pages/settings/auto-launch.ts
Normal file
|
@ -0,0 +1,22 @@
|
|||
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,6 +4,7 @@ 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({
|
||||
|
@ -12,6 +13,7 @@ export function Settings() {
|
|||
repackUpdatesNotificationsEnabled: false,
|
||||
telemetryEnabled: false,
|
||||
preferQuitInsteadOfHiding: false,
|
||||
startWithSystem: false,
|
||||
});
|
||||
|
||||
const { t } = useTranslation("settings");
|
||||
|
@ -30,6 +32,7 @@ export function Settings() {
|
|||
telemetryEnabled: userPreferences?.telemetryEnabled ?? false,
|
||||
preferQuitInsteadOfHiding:
|
||||
userPreferences?.preferQuitInsteadOfHiding ?? false,
|
||||
startWithSystem: userPreferences?.startWithSystem ?? false,
|
||||
});
|
||||
});
|
||||
}, []);
|
||||
|
@ -123,6 +126,15 @@ export function Settings() {
|
|||
)
|
||||
}
|
||||
/>
|
||||
|
||||
<CheckboxField
|
||||
label={"autoLaunch"}
|
||||
onChange={() => {
|
||||
updateUserPreferences("startWithSystem", !form.startWithSystem);
|
||||
// autoLaunch();
|
||||
}}
|
||||
checked={form.startWithSystem}
|
||||
/>
|
||||
</div>
|
||||
</section>
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue