MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / registerLinux

Function registerLinux

source code/utils/deepLink/registerProtocol.ts:146–182  ·  view source on GitHub ↗

* Register the protocol handler on Linux. * Creates a .desktop file and registers it with xdg-mime.

(claudePath: string)

Source from the content-addressed store, hash-verified

144 * Creates a .desktop file and registers it with xdg-mime.
145 */
146async function registerLinux(claudePath: string): Promise<void> {
147 await fs.mkdir(path.dirname(linuxDesktopPath()), { recursive: true })
148
149 const desktopEntry = `[Desktop Entry]
150Name=${APP_NAME}
151Comment=Handle ${DEEP_LINK_PROTOCOL}:// deep links for Claude Code
152${linuxExecLine(claudePath)}
153Type=Application
154NoDisplay=true
155MimeType=x-scheme-handler/${DEEP_LINK_PROTOCOL};
156`
157
158 await fs.writeFile(linuxDesktopPath(), desktopEntry)
159
160 // Register as the default handler for the scheme. On headless boxes
161 // (WSL, Docker, CI) xdg-utils isn't installed — not a failure: there's
162 // no desktop to click links from, and some apps read the .desktop
163 // MimeType line directly. The artifact check still short-circuits
164 // next session since the .desktop file is present.
165 const xdgMime = await which('xdg-mime')
166 if (xdgMime) {
167 const { code } = await execFileNoThrow(
168 xdgMime,
169 ['default', DESKTOP_FILE_NAME, `x-scheme-handler/${DEEP_LINK_PROTOCOL}`],
170 { useCwd: false },
171 )
172 if (code !== 0) {
173 throw Object.assign(new Error(`xdg-mime exited with code ${code}`), {
174 code: 'XDG_MIME_FAILED',
175 })
176 }
177 }
178
179 logForDebugging(
180 `Registered ${DEEP_LINK_PROTOCOL}:// protocol handler at ${linuxDesktopPath()}`,
181 )
182}
183
184/**
185 * Register the protocol handler on Windows via the registry.

Callers 1

registerProtocolHandlerFunction · 0.85

Calls 4

linuxDesktopPathFunction · 0.85
linuxExecLineFunction · 0.85
execFileNoThrowFunction · 0.85
logForDebuggingFunction · 0.85

Tested by

no test coverage detected