Skip to content

Commit

Permalink
Flatpak: locate and launch flatpaked code editors (#602)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lunarequest authored and shiftkey committed Aug 11, 2024
1 parent 22bf947 commit f7501df
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions app/src/lib/helpers/linux.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export function convertToFlatpakPath(path: string) {
return path
}

if (path.startsWith('/opt/')) {
if (path.startsWith('/opt/') || path.startsWith('/var/lib/flatpak')) {
return path
}

Expand All @@ -32,6 +32,12 @@ export function formatWorkingDirectoryForFlatpak(path: string): string {
return path.replace(/(\s)/, ' ')
}

export function formatPathForFlatpak(path: string): string {
if (path.startsWith('/var/lib/flatpak/app')) {
return path.replace('/var/lib/flatpak/app/', '')
}
return path
}
/**
* Checks the file path on disk exists before attempting to launch a specific shell
*
Expand Down Expand Up @@ -85,11 +91,12 @@ export function spawnEditor(
options: SpawnOptions
): ChildProcess {
if (isFlatpakBuild()) {
const actualPath = formatPathForFlatpak(path)
const EscapedworkingDirectory =
formatWorkingDirectoryForFlatpak(workingDirectory)
return nodeSpawn(
'flatpak-spawn',
['--host', path, EscapedworkingDirectory],
['--host', actualPath, EscapedworkingDirectory],
options
)
} else {
Expand Down

0 comments on commit f7501df

Please sign in to comment.