mirror of
https://github.com/fluxerapp/fluxer
synced 2026-10-17 13:05:32 +09:00
fix(desktop): supersede the legacy linux packages on upgrade (#2842)
This commit is contained in:
1 parent
cc75e1318d
commit
98a42f612b
4 files changed
+278
-7
No files matched your search
@@ -331,6 +331,10 @@ function desktopEntryBoolean(value: string | undefined): boolean {
|
||||
return value?.trim().toLowerCase() === 'true';
|
||||
}
|
||||
|
||||
function desktopEntryDisabled(value: string | undefined): boolean {
|
||||
return value?.trim().toLowerCase() === 'false';
|
||||
}
|
||||
|
||||
function parseDesktopExecCommand(value: string | undefined): string | null {
|
||||
if (!value) return null;
|
||||
const input = value.trimStart();
|
||||
@@ -583,7 +587,32 @@ async function isAutostartEnabled(): Promise<boolean> {
|
||||
return false;
|
||||
}
|
||||
|
||||
async function repairLinuxAutostartEntry(): Promise<void> {
|
||||
if (!isLinux || isFlatpakRuntime() || isPortableMode()) return;
|
||||
let contents: string;
|
||||
try {
|
||||
contents = fs.readFileSync(getLinuxDesktopFilePath(), 'utf8');
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
const entry = tryParseDesktopEntry(contents);
|
||||
if (entry.get('StartupWMClass')?.trim() !== LINUX_STARTUP_WM_CLASS) return;
|
||||
if (desktopEntryBoolean(entry.get('Hidden'))) return;
|
||||
if (desktopEntryDisabled(entry.get('X-GNOME-Autostart-enabled'))) return;
|
||||
if (linuxDesktopEntryTargetsExistingCommand(entry)) return;
|
||||
if (!commandExists(getStableLinuxLaunchPath())) return;
|
||||
try {
|
||||
await enableLinuxAutostart();
|
||||
log.info('[Autostart] Rewrote a Linux autostart entry whose command no longer exists', {
|
||||
execPath: getStableLinuxLaunchPath(),
|
||||
});
|
||||
} catch (error) {
|
||||
log.warn('[Autostart] Failed to rewrite the stale Linux autostart entry:', error);
|
||||
}
|
||||
}
|
||||
|
||||
export function registerAutostartHandlers(): void {
|
||||
void repairLinuxAutostartEntry();
|
||||
ipcMain.handle('autostart-enable', async (): Promise<void> => {
|
||||
await enableAutostart();
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user