mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-02-15 04:32:13 +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
|
@ -138,7 +138,8 @@
|
||||||
"telemetry": "Telemetry",
|
"telemetry": "Telemetry",
|
||||||
"telemetry_description": "Enable anonymous usage statistics",
|
"telemetry_description": "Enable anonymous usage statistics",
|
||||||
"behavior": "Behavior",
|
"behavior": "Behavior",
|
||||||
"quit_app_instead_hiding": "Close app instead of minimizing to tray"
|
"quit_app_instead_hiding": "Close app instead of minimizing to tray",
|
||||||
|
"launch_with_system": "Launch app on system start-up"
|
||||||
},
|
},
|
||||||
"notifications": {
|
"notifications": {
|
||||||
"download_complete": "Download complete",
|
"download_complete": "Download complete",
|
||||||
|
|
|
@ -134,7 +134,8 @@
|
||||||
"telemetry": "Telemetria",
|
"telemetry": "Telemetria",
|
||||||
"telemetry_description": "Habilitar estatísticas de uso anônimas",
|
"telemetry_description": "Habilitar estatísticas de uso anônimas",
|
||||||
"behavior": "Comportamento",
|
"behavior": "Comportamento",
|
||||||
"quit_app_instead_hiding": "Fechar o aplicativo em vez de minimizá-lo"
|
"quit_app_instead_hiding": "Fechar o aplicativo em vez de minimizá-lo",
|
||||||
|
"launch_with_system": "Iniciar aplicativo na inicialização do sistema"
|
||||||
},
|
},
|
||||||
"notifications": {
|
"notifications": {
|
||||||
"download_complete": "Download concluído",
|
"download_complete": "Download concluído",
|
||||||
|
|
|
@ -26,6 +26,7 @@ import "./torrenting/resume-game-download";
|
||||||
import "./torrenting/start-game-download";
|
import "./torrenting/start-game-download";
|
||||||
import "./user-preferences/get-user-preferences";
|
import "./user-preferences/get-user-preferences";
|
||||||
import "./user-preferences/update-user-preferences";
|
import "./user-preferences/update-user-preferences";
|
||||||
|
import "./user-preferences/auto-launch";
|
||||||
|
|
||||||
ipcMain.handle("ping", () => "pong");
|
ipcMain.handle("ping", () => "pong");
|
||||||
ipcMain.handle("getVersion", () => app.getVersion());
|
ipcMain.handle("getVersion", () => app.getVersion());
|
||||||
|
|
24
src/main/events/user-preferences/auto-launch.ts
Normal file
24
src/main/events/user-preferences/auto-launch.ts
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
import { registerEvent } from "../register-event";
|
||||||
|
import AutoLaunch from "auto-launch";
|
||||||
|
|
||||||
|
const autoLaunch = async (
|
||||||
|
_event: Electron.IpcMainInvokeEvent,
|
||||||
|
enabled: boolean
|
||||||
|
) => {
|
||||||
|
const appLauncher = new AutoLaunch({
|
||||||
|
name: "Hydra",
|
||||||
|
});
|
||||||
|
if (enabled) {
|
||||||
|
appLauncher
|
||||||
|
.enable()
|
||||||
|
.catch((err) => console.error("Error enabling auto-launch:", err));
|
||||||
|
} else {
|
||||||
|
appLauncher
|
||||||
|
.disable()
|
||||||
|
.catch((err) => console.error("Error disabling auto-launch:", err));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
registerEvent(autoLaunch, {
|
||||||
|
name: "autoLaunch",
|
||||||
|
});
|
1
src/preload/index.d.ts
vendored
1
src/preload/index.d.ts
vendored
|
@ -48,6 +48,7 @@ contextBridge.exposeInMainWorld("electron", {
|
||||||
getUserPreferences: () => ipcRenderer.invoke("getUserPreferences"),
|
getUserPreferences: () => ipcRenderer.invoke("getUserPreferences"),
|
||||||
updateUserPreferences: (preferences: UserPreferences) =>
|
updateUserPreferences: (preferences: UserPreferences) =>
|
||||||
ipcRenderer.invoke("updateUserPreferences", preferences),
|
ipcRenderer.invoke("updateUserPreferences", preferences),
|
||||||
|
autoLaunch: (enabled: boolean) => ipcRenderer.invoke("autoLaunch", enabled),
|
||||||
|
|
||||||
/* Library */
|
/* Library */
|
||||||
addGameToLibrary: (
|
addGameToLibrary: (
|
||||||
|
|
|
@ -57,6 +57,7 @@ contextBridge.exposeInMainWorld("electron", {
|
||||||
getUserPreferences: () => ipcRenderer.invoke("getUserPreferences"),
|
getUserPreferences: () => ipcRenderer.invoke("getUserPreferences"),
|
||||||
updateUserPreferences: (preferences: UserPreferences) =>
|
updateUserPreferences: (preferences: UserPreferences) =>
|
||||||
ipcRenderer.invoke("updateUserPreferences", preferences),
|
ipcRenderer.invoke("updateUserPreferences", preferences),
|
||||||
|
autoLaunch: (enabled: boolean) => ipcRenderer.invoke("autoLaunch", enabled),
|
||||||
|
|
||||||
/* Library */
|
/* Library */
|
||||||
addGameToLibrary: (
|
addGameToLibrary: (
|
||||||
|
|
1
src/renderer/src/declaration.d.ts
vendored
1
src/renderer/src/declaration.d.ts
vendored
|
@ -74,6 +74,7 @@ declare global {
|
||||||
updateUserPreferences: (
|
updateUserPreferences: (
|
||||||
preferences: Partial<UserPreferences>
|
preferences: Partial<UserPreferences>
|
||||||
) => Promise<void>;
|
) => Promise<void>;
|
||||||
|
autoLaunch: (enabled: boolean) => Promise<void>;
|
||||||
|
|
||||||
/* Hardware */
|
/* Hardware */
|
||||||
getDiskFreeSpace: (path: string) => Promise<DiskSpace>;
|
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 * as styles from "./settings.css";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { UserPreferences } from "@types";
|
import { UserPreferences } from "@types";
|
||||||
// import { autoLaunch } from "./auto-launch";
|
|
||||||
|
|
||||||
export function Settings() {
|
export function Settings() {
|
||||||
const [form, setForm] = useState({
|
const [form, setForm] = useState({
|
||||||
|
@ -128,10 +127,10 @@ export function Settings() {
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<CheckboxField
|
<CheckboxField
|
||||||
label={"autoLaunch"}
|
label={t("launch_with_system")}
|
||||||
onChange={() => {
|
onChange={() => {
|
||||||
updateUserPreferences("startWithSystem", !form.startWithSystem);
|
updateUserPreferences("startWithSystem", !form.startWithSystem);
|
||||||
// autoLaunch();
|
window.electron.autoLaunch(!form.startWithSystem);
|
||||||
}}
|
}}
|
||||||
checked={form.startWithSystem}
|
checked={form.startWithSystem}
|
||||||
/>
|
/>
|
||||||
|
|
Loading…
Reference in a new issue