Skip to content

Commit

Permalink
Add flatpak-spawn wrapper for calling other flatpak apps
Browse files Browse the repository at this point in the history
  • Loading branch information
joshua-stone committed May 25, 2023
1 parent 15df89e commit ed18630
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,16 @@ Middle-click auto-scrolling can be enabled with the following:
$ flatpak override --user --env=OBSIDIAN_ENABLE_AUTOSCROLL=1 md.obsidian.Obsidian
```

## Calling external programs

Calling an external program may be required under some circumstances. This functionality can be enabled like so:

```bash
$ flatpak override --user --talk-name=org.freedesktop.Flatpak md.obsidian.Obsidian
$ flatpak install org.chromium.Chromium
$ flatpak run --command=/app/libexec/flatpak-spawn/org.chromium.Chromium md.obsidian.Obsidian
```

## Flatpak permissions

This flatpak goes into great lengths to provide a nice experience for end users. In order for the [Git plugin](https://github.com/denolehov/obsidian-git) to work it requires permission to the ssh-auth socket (`--socket=ssh-auth`). It also exposes the home directory in the sandbox (required for Drag and Drop operations). If you don't use the Git plugin you can disable the ssh-auth socket permission, e.g. using Flatseal. You can also remove access to the home directory if you want and the flatpak will continue to work, albeit with reduced functionality. In case you do remove access to the homedir, note that in order for things to not break for the Git plugin, `--persist=.ssh` flag has been passed and a bind mount to `~/.var/app/md.obsidian.Obsidian/` is created by flatpak, allowing that location to be used for persistent data (but your home directory's .ssh remains unaccessible)
15 changes: 15 additions & 0 deletions flatpak-app-spawn.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/sh

# This wrapper requires the following permission:
# --talk-name=org.freedesktop.Flatpak

set -oue pipefail

APP="$(basename $0)"

if [[ "$(basename "$(realpath $0)")" == "${APP}" ]]; then
echo "Error: Must be called from a symlink. Exiting."
exit 1
fi

flatpak-spawn --host /var/lib/flatpak/exports/bin/${APP} $@
8 changes: 8 additions & 0 deletions md.obsidian.Obsidian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,14 @@ modules:
url-query: .assets[] | select(.name=="pandoc-" + $version + "-linux-arm64.tar.gz")
| .browser_download_url
version-query: .tag_name
- name: flatpak-spawn
buildsystem: simple
build-commands:
- install -Dm755 flatpak-app-spawn.sh ${FLATPAK_DEST}/libexec/flatpak-spawn/flatpak-app-spawn.sh
- ln -s flatpak-app-spawn.sh ${FLATPAK_DEST}/libexec/flatpak-spawn/org.chromium.Chromium
sources:
- type: file
path: flatpak-app-spawn.sh
- name: obsidian
buildsystem: simple
build-commands:
Expand Down

0 comments on commit ed18630

Please sign in to comment.