(Almost) Native Obsidian

I’ve been on a quest to get the Linux Obsidian client working on Sailfish OS and need some help from the community because my LXC knowledge is limited, this is actually the first time I’m working with it.

Let me first list the current alternatives:

  • Volcanic Glass 2 by @roundedrectangle from the Jolla Store
  • the Android client in AAS
    • issues with permissions and syncing

I’ve been working on this on my JP2 that I also use as my daily driver so I haven’t done too crazy things. I already had a close shave where I thought I had to reinstall my phone again.

The following steps should get you an Obsidian up and running but all these steps are as root! So please realize this will not get you a functional Obsidian install but something to experiment and play around with that we can hopefully develop into a package for others to use.

Setting Up an LXC Container

  • devel-su
  • pkcon remove busybox-symlinks-tar
    • this hasn’t given me any issues so far (if you install gnu-tar below)
  • pkcon install lxc-templates xz wget gnu-tar
    • wget comes from Chum so I guess you need to have that
  • lxc-create --name obsidian --template download -- --dist archlinux --release current --arch arm64
    • I started with Arch because it had an Obsidian package on amd64 but apparently not on arm64 :frowning:

Edit /var/lib/lxc/obsidian/config as follows:

  • remove all lxc.net.* entries
  • add the following:
lxc.net.0.type = none
lxc.net.0.flags = up
lxc.environment = WAYLAND_DISPLAY=wayland-0
lxc.environment = XDG_RUNTIME_DIR=/mnt/run-user-0
lxc.mount.entry = /run/display/wayland-0 mnt/run-user-0/wayland-0 none bind,create=file,ro
lxc.mount.entry = /dev/dri /dev/dri none bind,create=dir

Preparing the OS and Obsidian

  • lxc-start --foreground --name obsidian
    • foreground for now so you can diagnose problems
    • you cannot login from the console, go to next step
  • lxc-attach --name obsidian in another terminal

Inside the container:

  • pacman -Sy --disable-sandbox
  • pacman -S --disable-sandbox chromium wget
    • Obsidian is an Electron app and this will get you all the dependencies
    • you can use curl instead of wget
  • mkdir /opt/obsidian
  • cd /opt/obsidian
  • wget https://github.com/obsidianmd/obsidian-releases/releases/download/v1.13.7/obsidian-1.13.7-arm64.tar.gz
  • tar xvf obsidian-1.13.7-arm64.tar.gz
  • cd obsidian-1.13.7-arm64
  • ./obsidian --no-sandbox --enable-features=UseOzonePlatform --ozone-platform=wayland --force-device-scale-factor=1.5
    • 1.5 scale still shows all the UI we need
  • create a note (and thus a vault)

I’m assuming your vault is at /root/Obsidian Vault.

  • cd to your vault
  • cd .obsidian/plugins, create it if it doesn’t exist
  • mkdir always-mobile
  • cd always-mobile
  • create the following 2 files:

manifest.json:

{
  "id": "always-mobile",
  "name": "Always Mobile",
  "version": "1.0.0",
  "minAppVersion": "1.0.0",
  "description": "Always enable Obsidian mobile emulation.",
  "author": "SFOS Forum",
  "isDesktopOnly": true
}

main.js:

const { Plugin } = require("obsidian");

module.exports = class AlwaysMobile extends Plugin
{
    async onload() {
        this.app.emulateMobile(true);
    }

    onunload() {
        this.app.emulateMobile(false);
    }
};

Enable the plugin by starting Obsidian again and going to Settings > Community Plugins > Always Mobile.

Start Obsidian

Now you can start Obsidian with a scale factor that feels comfortable to you.

This is it for now. I’m sure I forgot something.

To Do

  • get keyboard working
  • run LXC container as a normal user (prevented by the point below)
  • do not use none for LXC net type
  • package it all up somehow
6 Likes

Question: what makes the virtual keyboard show up in SFOS, what triggers it?

Because I have not been able to make it show up for Obsidian in LXC.