Skip to content

Commit 3b96590

Browse files
committed
fix(service): compare XDG_CONFIG_HOME to ~/.config after path resolution
1 parent 4d89c6a commit 3b96590

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

‎src/service/desktop-startup.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { execFileSync } from "node:child_process";
22
import { accessSync, constants, readFileSync, readlinkSync, realpathSync } from "node:fs";
33
import { homedir } from "node:os";
4-
import { basename, dirname, isAbsolute, join } from "node:path";
4+
import { basename, dirname, isAbsolute, join, resolve } from "node:path";
55
import { readPid } from "../config/process-state";
66
import { resolveServiceOwnership, sameServiceOwnershipSubject, type ServiceOwnershipResolution } from "./state";
77

@@ -146,7 +146,7 @@ export function diagnoseLinuxDesktopStartup(deps: DesktopStartupDeps = {}): Desk
146146
const config = configured && isAbsolute(configured) ? configured : join(home, ".config");
147147
// auto-launch 0.5.0 writes autostart under HOME; Tauri app_config_dir uses XDG for install-id.
148148
// A relocated XDG_CONFIG_HOME puts that entry outside the session's autostart search path.
149-
if (config !== join(home, ".config")) return deriveDesktopStartup(facts);
149+
if (resolve(config) !== resolve(home, ".config")) return deriveDesktopStartup(facts);
150150
const capture = () => {
151151
const id = readFileSync(join(config, "com.opencodex.desktop", "install-id"), "utf8");
152152
if (id.trim() !== owner.ownership.installId) return null;

‎tests/service/service-desktop-startup-linux.test.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ Exec=${f.app} --autostart
7878
`);
7979
expect(diagnoseLinuxDesktopStartup({ ...f.deps, env: { XDG_CONFIG_HOME: moved } })).toMatchObject({ viable: false });
8080
expect(diagnoseLinuxDesktopStartup({ ...f.deps, env: { XDG_CONFIG_HOME: join(f.home, ".config") } })).toMatchObject({ viable: true });
81+
expect(diagnoseLinuxDesktopStartup({ ...f.deps, env: { XDG_CONFIG_HOME: `${join(f.home, ".config")}/` } })).toMatchObject({ viable: true });
8182
});
8283

8384
for (const field of ["OnlyShowIn=GNOME;", "NotShowIn=GNOME;", "TryExec=/missing", "OnlyShowIn=", "NotShowIn=", "TryExec="]) {

0 commit comments

Comments
 (0)