marp-team / marp-vscode

Marp for VS Code: Create slide deck written in Marp Markdown on VS Code
https://marketplace.visualstudio.com/items?itemName=marp-team.marp-vscode
MIT License
1.55k stars 72 forks source link

Unable to export in Flatpak VSCode #451

Closed josecastillolema closed 5 months ago

josecastillolema commented 5 months ago

Is there a way to export slides in the Flatpak version of VSCode?

I am able to run i.e.: Chrome from the Flatpak vscode version:

> flatpak run --command=sh com.visualstudio.code
[📦 com.visualstudio.code]$ flatpak-spawn --host flatpak run com.google.Chrome

However unfortunately the following setting does not seem to work:

"markdown.marp.chromePath": "flatpak-spawn --host flatpak run com.google.Chrome"
yhatt commented 5 months ago

markdown.marp.chromePath does not allow the shell command. You must specify the actual path for the Flatpak Chrome binary.

{
  "markdown.marp.chromePath": "/var/lib/flatpak/exports/bin/com.google.Chrome"
}

Related

josecastillolema commented 5 months ago

Hi @yhatt , thanks for your quick response! Unfortunately that won't work, /var/lib/flatpak is not accessible from inside flatpaks (neither is $HOME/.local/share/flatpak/exports/bin):

> ls /var/lib/flatpak/exports/bin/com.google.Chrome
/var/lib/flatpak/exports/bin/com.google.Chrome

> ls .local/share/flatpak/exports/bin/com.google.Chrome
.local/share/flatpak/exports/bin/com.google.Chrome

> flatpak run --command=sh com.visualstudio.code
[📦 com.visualstudio.code ~]$ ls /var/lib/flatpak/exports/bin/com.google.Chrome
ls: cannot access '/var/lib/flatpak/exports/bin/com.google.Chrome': No such file or directory

[📦 com.visualstudio.code ~]$ ls .local/share/flatpak/exports/bin/com.google.Chrome
ls: cannot access '.local/share/flatpak/exports/bin/com.google.Chrome': No such file or directory

The proposed workaround would work if VSCode was not a Flatpak and Chrome was, but wont work when both of them are.

This is by design, see Allow a flatpak to discover/call another flatpak #283

yhatt commented 5 months ago

Thank you for more context to recognize the problem. By the design of flatpak as you've described, using flatpak Chrome from flatpak VS Code to export Marp slides would be difficult for now.

It looks like able to spawn Chrome process, by making the wrapper shell script like below and setting its path to markdown.marp.chromePath. But even if it succeed, the result of export PDF will save to inside of the Chrome flatpak sandbox, so VS Code cannot read that across sandboxes.

The example of wrapper script (Click to open) ```sh #!/bin/sh flatpak-spawn --host /var/lib/flatpak/exports/bin/com.google.Chrome "$@" ```

If there were the SDK Extension of freedesktop.org for Chrome/Chromium, this problem may be solved because the browser will be available in inside of the VS Code flatpak sandbox. This is already feedbacked to the Flathub community through Obsidian Marp Slides plugin, but there is no progress.

josecastillolema commented 5 months ago

The wrapper works! And the result of the export PDF is not saved inside the Chrome flatpak, but in any directory inside the home folder selected by the user.

Thanks