Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add flatpak-spawn wrapper for running other apps #159

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -170,6 +170,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