mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-03-09 15:40:26 +00:00
Merge pull request #207 from Hachi-R/auto-launch
added option to start hydra on system startup
This commit is contained in:
commit
e041d27988
13 changed files with 630 additions and 400 deletions
|
@ -37,6 +37,7 @@
|
|||
"@sentry/vite-plugin": "^2.16.1",
|
||||
"@vanilla-extract/css": "^1.14.2",
|
||||
"@vanilla-extract/recipes": "^0.5.2",
|
||||
"auto-launch": "^5.0.6",
|
||||
"axios": "^1.6.8",
|
||||
"better-sqlite3": "^9.5.0",
|
||||
"check-disk-space": "^3.4.0",
|
||||
|
@ -66,6 +67,7 @@
|
|||
"@electron-toolkit/eslint-config-ts": "^1.0.1",
|
||||
"@electron-toolkit/tsconfig": "^1.0.1",
|
||||
"@swc/core": "^1.4.16",
|
||||
"@types/auto-launch": "^5.0.5",
|
||||
"@types/jsdom": "^21.1.6",
|
||||
"@types/lodash-es": "^4.17.12",
|
||||
"@types/node": "^20.12.7",
|
||||
|
|
|
@ -138,7 +138,8 @@
|
|||
"telemetry": "Telemetry",
|
||||
"telemetry_description": "Enable anonymous usage statistics",
|
||||
"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": {
|
||||
"download_complete": "Download complete",
|
||||
|
|
|
@ -134,7 +134,8 @@
|
|||
"telemetry": "Telemetria",
|
||||
"telemetry_description": "Habilitar estatísticas de uso anônimas",
|
||||
"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": {
|
||||
"download_complete": "Download concluído",
|
||||
|
|
|
@ -29,6 +29,9 @@ export class UserPreferences {
|
|||
@Column("boolean", { default: false })
|
||||
preferQuitInsteadOfHiding: boolean;
|
||||
|
||||
@Column("boolean", { default: false })
|
||||
runAtStartup: boolean;
|
||||
|
||||
@CreateDateColumn()
|
||||
createdAt: Date;
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@ import "./torrenting/resume-game-download";
|
|||
import "./torrenting/start-game-download";
|
||||
import "./user-preferences/get-user-preferences";
|
||||
import "./user-preferences/update-user-preferences";
|
||||
import "./user-preferences/auto-launch";
|
||||
|
||||
ipcMain.handle("ping", () => "pong");
|
||||
ipcMain.handle("getVersion", () => app.getVersion());
|
||||
|
|
21
src/main/events/user-preferences/auto-launch.ts
Normal file
21
src/main/events/user-preferences/auto-launch.ts
Normal file
|
@ -0,0 +1,21 @@
|
|||
import { registerEvent } from "../register-event";
|
||||
import AutoLaunch from "auto-launch";
|
||||
import { app } from "electron";
|
||||
|
||||
const autoLaunch = async (
|
||||
_event: Electron.IpcMainInvokeEvent,
|
||||
enabled: boolean
|
||||
) => {
|
||||
const appLauncher = new AutoLaunch({
|
||||
name: app.getName(),
|
||||
});
|
||||
if (enabled) {
|
||||
appLauncher.enable().catch();
|
||||
} else {
|
||||
appLauncher.disable().catch();
|
||||
}
|
||||
};
|
||||
|
||||
registerEvent(autoLaunch, {
|
||||
name: "autoLaunch",
|
||||
});
|
|
@ -26,7 +26,7 @@ export class WindowManager {
|
|||
}
|
||||
}
|
||||
|
||||
public static async createMainWindow() {
|
||||
public static createMainWindow() {
|
||||
// Create the browser window.
|
||||
this.mainWindow = new BrowserWindow({
|
||||
width: 1200,
|
||||
|
|
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"),
|
||||
updateUserPreferences: (preferences: UserPreferences) =>
|
||||
ipcRenderer.invoke("updateUserPreferences", preferences),
|
||||
autoLaunch: (enabled: boolean) => ipcRenderer.invoke("autoLaunch", enabled),
|
||||
|
||||
/* Library */
|
||||
addGameToLibrary: (
|
||||
|
|
|
@ -57,6 +57,7 @@ contextBridge.exposeInMainWorld("electron", {
|
|||
getUserPreferences: () => ipcRenderer.invoke("getUserPreferences"),
|
||||
updateUserPreferences: (preferences: UserPreferences) =>
|
||||
ipcRenderer.invoke("updateUserPreferences", preferences),
|
||||
autoLaunch: (enabled: boolean) => ipcRenderer.invoke("autoLaunch", enabled),
|
||||
|
||||
/* Library */
|
||||
addGameToLibrary: (
|
||||
|
|
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>;
|
||||
|
|
|
@ -12,6 +12,7 @@ export function Settings() {
|
|||
repackUpdatesNotificationsEnabled: false,
|
||||
telemetryEnabled: false,
|
||||
preferQuitInsteadOfHiding: false,
|
||||
runAtStartup: false,
|
||||
});
|
||||
|
||||
const { t } = useTranslation("settings");
|
||||
|
@ -30,6 +31,7 @@ export function Settings() {
|
|||
telemetryEnabled: userPreferences?.telemetryEnabled ?? false,
|
||||
preferQuitInsteadOfHiding:
|
||||
userPreferences?.preferQuitInsteadOfHiding ?? false,
|
||||
runAtStartup: userPreferences?.runAtStartup ?? false,
|
||||
});
|
||||
});
|
||||
}, []);
|
||||
|
@ -123,6 +125,15 @@ export function Settings() {
|
|||
)
|
||||
}
|
||||
/>
|
||||
|
||||
<CheckboxField
|
||||
label={t("launch_with_system")}
|
||||
onChange={() => {
|
||||
updateUserPreferences("runAtStartup", !form.runAtStartup);
|
||||
window.electron.autoLaunch(!form.runAtStartup);
|
||||
}}
|
||||
checked={form.runAtStartup}
|
||||
/>
|
||||
</div>
|
||||
</section>
|
||||
);
|
||||
|
|
|
@ -106,6 +106,7 @@ export interface UserPreferences {
|
|||
repackUpdatesNotificationsEnabled: boolean;
|
||||
telemetryEnabled: boolean;
|
||||
preferQuitInsteadOfHiding: boolean;
|
||||
runAtStartup: boolean;
|
||||
}
|
||||
|
||||
export interface HowLongToBeatCategory {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue