Skip to content

Instantly share code, notes, and snippets.

@lbrame
Last active November 5, 2024 18:21
Show Gist options
  • Save lbrame/a9268c3cdf688edf2243a968b9f03be2 to your computer and use it in GitHub Desktop.
Save lbrame/a9268c3cdf688edf2243a968b9f03be2 to your computer and use it in GitHub Desktop.
Work around Obsidian not being able to move or tile tabs in Wayland mode

Update 05/11/2024

The Obsidian package on Flathub defaults to Electron 32 now, which fixes the problem it used to have in Wayland mode. Also, should one want to run it in X11 mode for any reason, Fedora 41 released with GNOME 47, enabling its new xwayland-native-scaling feature, that finally makes XWayland apps crisp in fractional scaling scenarios. For all intents and purposes, either of these two advancements obsolete this gist.


Obsidian has had a long-standing bug open for a couple years now. The problem with this bug is that, when Obsidian is running in Wayland mode, it is not possible to drag tabs around, tile them, or move them around in any way. The only way to restore this functionality is to run Obsidian in X11 mode, through XWayland. Sadly, doing that degrades the experience on HiDPI setups with fractional scaling enabled, because fonts become very fuzzy to read.

Here, I am posting the workaround I found. There seems to be a mitigation to this bug in Electron version 32. Obsidian still appears to use Electron 30, which is too old. While chatting about this with other Obsidian users, I was directed to trying to use the ArchLinux package, hence, I used Distrobox to create a local Arch Linux container to play with.

Nothing is more permanent than a temporary solution, but this truly is just a temporary solution. Eventually, Obsidian will get around to updating their own build with a more current version of Electron. Until then, taking advantage of Arch's very modular packaging seems to be a pretty easy way to have something working for now.

The workaround

First, create a home directory for your Arch Linux container. In my case, I chose ~/distrobox/archbox

mkdir -p ~/distrobox/archbox

We want to mount this folder as $HOME in the container to avoid breakage and to prevent the Arch system from rewriting configuration files already present on your host system.

Then, clone the distrobox.ini file from this gist into any unique folder you want (I used the container's homedir) and run distrobox assemble create. Make sure to change nvidia=false to nvidia=true if you are using a NVidia GPU with the proprietary driver as your primary GPU.

This will create an Arch Linux container with a home directory mounted to the folder we just created, with a bunch of packages we will need already installed.

Our goal is to patch the official package to change the launch script that gets placed in /usr/bin/obsidian replacing electron30 with electron32. Let's spawn a shell inside our container:

distrobox enter archbox

Then, cd to a suitable location and download the package source from the ABS:

pkgctl repo clone --protocol=https --switch 1.6.7-1 obsidian

You should replace --switch 1.6.7-1 with a more current version, or remove it entirely to install the latest version. I decided to leave it in the gist to give a baseline of what will surely work, but I encourage trying to patch the newest version first. It should be pretty easy to re-do what I did for a newer version if my specific patch file ever breaks.

Then, navigate to the obsidian folder. Drop inside the electron32.patch file from this gist and then patch the repo, then make and install the package

cd obsidian
cp path/to/electron32.patch .
git apply electron32.patch
makepkg --install

Next, we want to export the desktop file. This can be done with

distrobox-export --app obsidian

A new Obsidian icon should now appear in the apps list in your host system. If all went well, opening Obsidian from that icon should lead us to the Arch Obsidian build, running with electron32. This specific combination - Obsidian1.6.7-1 with electron32 - seems to work great on Wayland.

Screenshot from 2024-10-07 00-15-05

Screenshot from 2024-10-07 00-27-44

[archbox]
image=archlinux:latest
additional_packages="obsidian electron32 asar base-devel git devtools"
init=false
nvidia=false # Set this to true if you will be using an NVidia GPU to render Obsidian
pull=true
replace=false
home=~/distrobox/archbox
diff --git a/PKGBUILD b/PKGBUILD
index 092f2b2..7b32ccf 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -17,7 +17,7 @@ source=("obsidian.sh"
"obsidian.desktop"
"https://github.com/obsidianmd/obsidian-releases/releases/download/v${pkgver}/obsidian-${pkgver}.tar.gz"
)
-sha256sums=('2a0d464795bce06f757a7e6271d14fae004e93ec0dc469b9846663696fd9a78f'
+sha256sums=('aaf46c3c8a510aa63b81e87da37364829613335c54673a9c8fbc1f183ac84f68'
'be67713e873a5935d910efc6f6005c104b35c7b3a002dfcb5643fd185d1b0056'
'a24d5f79d37cf8e5c18ac1695576ca456d8e844e28f4c0bd9499ad30c493e95f')
diff --git a/obsidian.sh b/obsidian.sh
index 8773b64..065c8e1 100644
--- a/obsidian.sh
+++ b/obsidian.sh
@@ -8,4 +8,4 @@ if [[ -f "${OBSIDIAN_USER_FLAGS_FILE}" ]]; then
fi
# Launch
-exec electron30 /usr/lib/obsidian/app.asar $OBSIDIAN_USER_FLAGS "$@"
+exec electron32 /usr/lib/obsidian/app.asar $OBSIDIAN_USER_FLAGS "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment