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 Nov 27, 2021
1 parent cb4db0c commit 31481b8
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions app/src/lib/helpers/linux.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,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 @@ -31,6 +31,13 @@ export function convertToFlatpakPath(path: string) {
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 @@ -84,12 +91,13 @@ export function spawnEditor(
options: SpawnOptions
): ChildProcess {
if (isFlatpakBuild()) {
const actualpath = formatPathForFlatpak(path)
const EscapedworkingDirectory = formatWorkingDirectoryForFlatpak(
workingDirectory
)
return spawn(
'flatpak-spawn',
['--host', path, EscapedworkingDirectory],
['--host', actualpath, EscapedworkingDirectory],
options
)
} else {
Expand Down

0 comments on commit 31481b8

Please sign in to comment.