Skip to content

Commit 1d4debd

Browse files
committed
feat: add hidpi article
1 parent 23b39b8 commit 1d4debd

1 file changed

Lines changed: 48 additions & 0 deletions

File tree

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
---
2+
layout: post
3+
title: "HiDPI Electron <37 apps on Sway"
4+
date: 2025-11-22 18:55:00 +0100
5+
categories: linux wayland sway electron hidpi
6+
---
7+
8+
Electron 38 ships with Chromium 140 which landed [this change](https://chromium-review.googlesource.com/c/chromium/src/+/6775426) which made the Ozone (Chromium's platform abstraction layer) feature detection "auto" by default (from, like not feature detecting at all, apparently). It bases it's decision on the `XDG_SESSION_TYPE` environment variable.
9+
10+
Previously I always had to add those flags to the command line:
11+
12+
```bash
13+
/usr/bin/obsidian --enable-features=UseOzonePlatform --ozone-platform=wayland
14+
```
15+
16+
That works but is annoying: you either need a terminal open and remind yourself to _not_ use [Albert](https://albertlauncher.github.io/) (the launcher I'm using).
17+
18+
I also tried patching the installed `.desktop` files:
19+
20+
```bash
21+
# copy and patch a desktop entry (one-off)
22+
desktop-file-install --dir=$HOME/.local/share/applications /usr/share/applications/obsidian.desktop
23+
# then edit ~/.local/share/applications/obsidian.desktop and add the flags to Exec=
24+
```
25+
26+
It worked, but I was looking for a more permanent solution.
27+
28+
[This answer on the Unix Stack Exchange](https://unix.stackexchange.com/a/768861/93390) hinted me to use the `ELECTRON_OZONE_PLATFORM_HINT` environment variable, which is supported by electron between version 28 and 38 (at which point it was removed, because unnecessary).
29+
30+
I initially tried to edit my `~/.profile`:
31+
```bash
32+
export ELECTRON_OZONE_PLATFORM_HINT=wayland
33+
```
34+
35+
However, this wasn't working:
36+
* Albert was still launching apps with low DPI
37+
* Launching the app from the terminal (without flags) was finally HiDPI, but well, back to square one.
38+
39+
What worked is discovering a embracing systemd and discovering anew way of setting environment variables:
40+
41+
```bash
42+
cat ~/.config/environment.d/electron-hidpi.conf
43+
ELECTRON_OZONE_PLATFORM_HINT=wayland
44+
```
45+
46+
Another reboot later and Albert was finally launching apps with HiDPI.
47+
48+
That will do, until all my apps are not using Electron 38 ;)

0 commit comments

Comments
 (0)