Skip to content

Build your personal knowledge base with Trilium Notes

fix(desktop): launch the Flatpak on startup

Elian Doran32b2541964ae
diff --git a/apps/desktop/src/services/auto_launch.spec.ts b/apps/desktop/src/services/auto_launch.spec.ts
index e4488d41e1..18291cb219 100644
--- a/apps/desktop/src/services/auto_launch.spec.ts
+++ b/apps/desktop/src/services/auto_launch.spec.ts
@@ -14,6 +14,7 @@ const state = vi.hoisted(() => ({
mkdirSync: vi.fn(),
writeFileSync: vi.fn(),
rmSync: vi.fn(),
+ execFile: vi.fn(),
log: { info: vi.fn(), error: vi.fn() }
}));
@@ -41,6 +42,10 @@ vi.mock("fs", () => ({
}
}));
+vi.mock("child_process", () => ({
+ execFile: (...a: unknown[]) => state.execFile(...a)
+}));
+
vi.mock("os", () => ({ default: { homedir: () => "/home/user" } }));
vi.mock("@triliumnext/core", () => ({
@@ -82,6 +87,7 @@ beforeEach(() => {
delete process.env.APPIMAGE;
delete process.env.TRILIUM_LAUNCH_EXEC;
delete process.env.XDG_CONFIG_HOME;
+ delete process.env.FLATPAK_ID;
});
afterEach(() => {
@@ -90,6 +96,7 @@ afterEach(() => {
delete process.env.APPIMAGE;
delete process.env.TRILIUM_LAUNCH_EXEC;
delete process.env.XDG_CONFIG_HOME;
+ delete process.env.FLATPAK_ID;
});
describe("auto_launch", () => {
@@ -204,6 +211,43 @@ describe("auto_launch", () => {
expect(state.writeFileSync).not.toHaveBeenCalled();
});
+ it("asks the Background portal for autostart inside a Flatpak, without writing a file", () => {
+ setPlatform("linux");
+ process.env.FLATPAK_ID = "org.triliumnotes.Trilium";
+ state.launchOnStartup = true;
+
+ applyLaunchOnStartup();
+ state.hideOnAutoStart = true;
+ applyLaunchOnStartup();
+ state.launchOnStartup = false;
+ applyLaunchOnStartup();
+
+ const portalOptions = state.execFile.mock.calls.map(([ command, args ]) => {
+ expect(command).toBe("gdbus");
+ expect(args).toContain("org.freedesktop.portal.Background.RequestBackground");
+ return (args as string[]).at(-1);
+ });
+ expect(portalOptions).toEqual([
+ "{'autostart': <true>, 'commandline': <['trilium']>}",
+ `{'autostart': <true>, 'commandline': <['trilium', '${START_HIDDEN_FLAG}']>}`,
+ "{'autostart': <false>, 'commandline': <['trilium']>}"
+ ]);
+ expect(state.writeFileSync).not.toHaveBeenCalled();
+ expect(state.rmSync).not.toHaveBeenCalled();
+ });
+
+ it("logs a failed Background portal call", () => {
+ setPlatform("linux");
+ process.env.FLATPAK_ID = "org.triliumnotes.Trilium";
+ state.launchOnStartup = true;
+
+ applyLaunchOnStartup();
+ const callback = state.execFile.mock.calls[0]?.[2] as (error: Error | null) => void;
+ callback(new Error("no portal"));
+
+ expect(state.log.error).toHaveBeenCalledWith(expect.stringContaining("no portal"));
+ });
+
it("logs and does not throw when applying fails", () => {
setPlatform("win32");
state.setLoginItemThrows = true;
diff --git a/apps/desktop/src/services/auto_launch.ts b/apps/desktop/src/services/auto_launch.ts
index 161f278677..7626d22bb7 100644
--- a/apps/desktop/src/services/auto_launch.ts
+++ b/apps/desktop/src/services/auto_launch.ts
@@ -1,4 +1,5 @@
import { getLog, options as optionService, utils as coreUtils } from "@triliumnext/core";
+import { execFile } from "child_process";
import electron from "electron";
import fs from "fs";
import os from "os";
@@ -26,7 +27,9 @@ export function applyLaunchOnStartup() {
const enabled = optionService.getOptionBool("launchOnStartup");
const hidden = enabled && optionService.getOptionBool("hideOnAutoStart");
- if (process.platform === "linux") {
+ if (process.platform === "linux" && process.env.FLATPAK_ID) {
+ applyFlatpakAutostart(enabled, hidden);
+ } else if (process.platform === "linux") {
applyLinuxAutostart(enabled, hidden);
} else {
// macOS + Windows: handled natively by Electron. `args` is the Windows
@@ -63,6 +66,26 @@ export function setupAutoLaunch() {
electron.ipcMain.on("reapply-launch-on-startup", applyLaunchOnStartup);
}
+/**
+ * A Flatpak cannot write the host's autostart directory, and its executable path only exists
+ * inside the sandbox, so the Background portal writes the entry, with a `flatpak run` command.
+ */
+function applyFlatpakAutostart(enabled: boolean, hidden: boolean) {
+ const commandline = hidden ? `['trilium', '${START_HIDDEN_FLAG}']` : "['trilium']";
+ const options = `{'autostart': <${enabled}>, 'commandline': <${commandline}>}`;
+ execFile("gdbus", [
+ "call", "--session",
+ "--dest", "org.freedesktop.portal.Desktop",
+ "--object-path", "/org/freedesktop/portal/desktop",
+ "--method", "org.freedesktop.portal.Background.RequestBackground",
+ "", options
+ ], (error) => {
+ if (error) {
+ getLog().error(`Failed to request autostart from the Background portal: ${error.message}`);
+ }
+ });
+}
+
function applyLinuxAutostart(enabled: boolean, hidden: boolean) {
const autostartDir = getLinuxAutostartDir();
const desktopFile = path.join(autostartDir, "trilium.desktop");
diff --git a/apps/server/src/assets/help/help_content.json b/apps/server/src/assets/help/help_content.json
index 9191d54909..f2f952f46f 100644
--- a/apps/server/src/assets/help/help_content.json
+++ b/apps/server/src/assets/help/help_content.json
@@ -5,7 +5,7 @@
"_help_Rp0q8bSP6Ayl": "<p>The desktop version of Trilium supports all three main operating systems:</p><div class=\"trilium-tabs\"><section class=\"trilium-tab\"><p class=\"trilium-tab-title\"><span class=\"tn-icon bx bxl-windows\"></span>&nbsp;Windows</p><div class=\"trilium-tab-panel\"><ul><li>Windows 11 is officially supported.</li><li>Windows on ARM is also supported</li></ul></div></section><section class=\"trilium-tab\"><p class=\"trilium-tab-title\"><span class=\"tn-icon bx bxl-tux\"></span>&nbsp;Linux</p><div class=\"trilium-tab-panel\"><ul><li>Most modern distributions are supported, including NixOS.</li><li>ARM is supported in <code>aarch64</code> (no ARM v7 support).</li></ul></div></section><section class=\"trilium-tab\"><p class=\"trilium-tab-title\"><span class=\"tn-icon bx bxl-apple\"></span>&nbsp;macOS</p><div class=\"trilium-tab-panel\"><ul><li>Minimum supported operating system: macOS Ventura</li><li>Both Intel and Apple Silicon devices are supported.</li></ul></div></section></div>",
"_help_Un4wj2Mak2Ky": "<p>Since TriliumNext 0.94.1, the desktop and server applications can be built using <a href=\"https://nixos.org/\">Nix</a>.</p><h2>System requirements</h2><p>Installation of Nix on Mac or Linux (<a href=\"https://nixos.org/download/\">download page</a>). About 3-4 gigabytes of additional storage space, for build artifacts.</p><h2>Run directly</h2><p>Using <a href=\"https://nix.dev/manual/nix/stable/command-ref/new-cli/nix3-run.html\">nix run</a>, the desktop app can be started as: <code>nix run github:TriliumNext/Trilium/v0.95.0</code></p><p>Running the server requires explicitly specifying the desired package: <code>nix run github:TriliumNext/Trilium/v0.95.0#server</code></p><p>Instead of a version (<code>v0.95.0</code> above), you can also specify a commit hash (or a branch name). This makes it easy to test development builds.</p><h2>Install on NixOS</h2><p>Add to your <code>flake.nix</code>:</p><pre><code class=\"language-text-x-trilium-auto\">{\n inputs = {\n nixpkgs.url = # ...;\n trilium-notes = {\n url = \"github:TriliumNext/Trilium/v0.95.0\";\n inputs.nixpkgs.follows = \"nixpkgs\";\n };\n };\n\n outputs =\n {\n self,\n # ...\n trilium-notes,\n ...\n }:\n {\n nixosConfigurations = {\n \"nixos\" = nixpkgs.lib.nixosSystem {\n system = \"x86_64-linux\";\n modules = [\n ./configuration.nix\n ];\n specialArgs = {\n inherit\n trilium-notes\n ;\n };\n };\n };\n };\n}\n</code></pre><p>Add to your <code>configuration.nix</code>:</p><pre><code class=\"language-text-x-trilium-auto\">{\n # ...\n trilium-notes,\n ...\n}:\n\n{\n # ...\n\n services.trilium-server.package = trilium-notes.packages.x86_64-linux.server;\n\n environment.systemPackages = [\n trilium-notes.packages.x86_64-linux.desktop\n ];\n}</code></pre><p>The flake aims to be compatible with the latest NixOS stable and unstable.</p>",
"_help_swSFivWk6KkA": "<p>Prior to v0.104.0, the <a href=\"#root/_help_poXkQfguuA0U\">desktop application</a> would also open a network port so that it can offer access to&nbsp;<a class=\"reference-link\" href=\"#root/_help_pgxEVkzLl1OP\">ETAPI (REST API)</a>&nbsp;or even use it as a web server (see&nbsp;<a class=\"reference-link\" href=\"#root/_help_nRqcgfTb97uV\">Using the desktop application as a server</a>).</p><p>In order to reduce the attack surface, Trilium now enables these services only for the local device (e.g. <code>localhost</code>) instead of serving them over the LAN.</p><p>To better understand what is affected, refer to the following table:</p><figure class=\"table\"><table><thead><tr><th>Feature</th><th>Network access OFF</th><th>Network access ON</th></tr></thead><tbody><tr><td><a class=\"reference-link\" href=\"#root/_help_MtPxeAWVAzMg\">Web Clipper</a></td><td>πŸ”’οΈ <code>localhost</code> only (still accessible to the browser extension on the same device)</td><td>🌐 <code>localhost</code> + LAN</td></tr><tr><td><a class=\"reference-link\" href=\"#root/_help_pgxEVkzLl1OP\">ETAPI (REST API)</a></td><td>πŸ”’οΈ <code>localhost</code> only</td><td>🌐 <code>localhost</code> + LAN</td></tr><tr><td><a href=\"#root/_help_GBBMSlVSOIGP\">LLM MCP</a> (only if enabled in settings)</td><td>πŸ”’οΈ <code>localhost</code> only (needs auth)</td><td>🌐 <code>localhost</code> + LAN (needs auth)</td></tr><tr><td><a href=\"#root/_help_nRqcgfTb97uV\">Web app</a></td><td>❌️ completely disabled (403), only the desktop app is usable.</td><td>🌐 <code>localhost</code> + LAN</td></tr><tr><td><a class=\"reference-link\" href=\"#root/_help_R9pX4DGra2Vt\">Sharing</a>&nbsp;notes</td><td>❌️ completely disabled (403), if you are using&nbsp;<a class=\"reference-link\" href=\"#root/_help_cbkrhQjrkKrh\">Synchronization</a>&nbsp;this will still work as part of the <a href=\"#root/_help_WOcw2SLH6tbX\">server</a>.</td><td>🌐 <code>localhost</code> + LAN</td></tr></tbody></table></figure>",
- "_help_7iwde4lsKc6O": "<aside class=\"admonition note\"><p>Automatic startup and better integration with the system tray was introduced in v0.104.0. Versions prior to that only have the system tray option which could be found in&nbsp;<a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a>&nbsp;β†’ <em>Others</em>.</p></aside><h2>Tray icon</h2><figure class=\"image image-style-align-right\"><img style=\"aspect-ratio:332/71;\" src=\"{{helpAssets}}/User%20Guide/Installation%20%26%20Setup/Desktop%20Installation/Tray%20icon%20%26%20automatic%20startup_image.png\" width=\"332\" height=\"71\"></figure><p>The desktop application has native integration with the system tray on all operating systems.</p><p>The tray icon is enabled by default, but it can be toggled from&nbsp;<a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a>&nbsp;β†’ <em>Desktop</em>.</p><p>The tray icon has the following functionality:</p><ul><li>When clicked, the last window is hidden (minimized to the tray icon). Clicking it again will reveal that window.</li><li>Right clicking reveals the following options:<ul><li>Each window can be individually shown or hidden, identified by their active note.</li><li>New windows can be opened.</li><li>A new note can be created directly, which will be created in the&nbsp;<a class=\"reference-link\" href=\"#root/_help_S0Fos78ZfcY7\">Note Inbox</a>&nbsp;(or&nbsp;<a class=\"reference-link\" href=\"#root/_help_l0tKav7yLHGF\">Day Notes</a>&nbsp;if an inbox is not available).</li><li>Today's day note can be opened.</li><li>Bookmarks and recent notes are displayed in a sub-menu and clicking them navigates to that note.</li><li>Quitting the application.</li></ul></li></ul><h3>Opening a new window from the taskbar</h3><p>A new window can also be opened without the tray icon, by right-clicking the application's icon:</p><ul><li>On Windows, in the taskbar, select <em>Open New Window</em>.</li><li>On Linux, in the dock or application launcher (such as GNOME's or KDE's), select <em>New Window</em>.</li></ul><h3>Closing to system tray</h3><p>This is an option which is not enabled by default and it allows a specific behavior: instead of exiting the application when the last window has been closed, the last window is instead hidden with the tray icon remaining available.</p><p>This option requires the tray icon to be enabled, otherwise it has no effect.</p><h2>Automatic startup</h2><p>Two options control the automatic startup functionality in&nbsp;<a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a>&nbsp;β†’ <em>Startup</em>:</p><ul><li>When <em>Launch on startup</em> is enabled, the application will automatically start up when logging into the current user.<ul><li>Note that on Linux support depends on the desktop environment. Feel free to <a href=\"#root/_help_wy8So3yZZlH9\">report</a> any issues.</li></ul></li><li>If <em>Start minimized to tray</em> is also enabled, the application will start up in the background and can be revealed from the tray icon.<ul><li>This only applies if <em>Launch on startup</em> is enabled, manual starts are not impacted by this option.</li></ul></li></ul><h3>Linux: custom launch command for packagers</h3><p>On Linux, <em>Launch on startup</em> writes a <code>trilium.desktop</code> entry to the user's autostart directory (<code>$XDG_CONFIG_HOME/autostart</code>, usually <code>~/.config/autostart</code>). Its <code>Exec</code> line points to the AppImage when running from one, or to the running executable otherwise.</p><p>Distribution packages that run Trilium on a system-wide Electron (for example <code>electron /usr/lib/trilium/app.asar</code>) cannot rely on the running executable, since it is the bare Electron binary, which starts without Trilium. Such packages can set the <code>TRILIUM_LAUNCH_EXEC</code> environment variable, typically in their wrapper script, to the full command that starts Trilium:</p><pre><code class=\"language-text-x-trilium-auto\">export TRILIUM_LAUNCH_EXEC='electron \"/usr/lib/trilium/app.asar\"'</code></pre><p>The value is written to the <code>Exec</code> line as-is, so any paths containing spaces must already be quoted. When <em>Start minimized to tray</em> is enabled, <code>--start-hidden</code> is appended to it. <code>TRILIUM_LAUNCH_EXEC</code> takes precedence over both the AppImage path and the running executable.</p>",
+ "_help_7iwde4lsKc6O": "<aside class=\"admonition note\"><p>Automatic startup and better integration with the system tray was introduced in v0.104.0. Versions prior to that only have the system tray option which could be found in&nbsp;<a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a>&nbsp;β†’ <em>Others</em>.</p></aside><h2>Tray icon</h2><figure class=\"image image-style-align-right\"><img style=\"aspect-ratio:332/71;\" src=\"{{helpAssets}}/User%20Guide/Installation%20%26%20Setup/Desktop%20Installation/Tray%20icon%20%26%20automatic%20startup_image.png\" width=\"332\" height=\"71\"></figure><p>The desktop application has native integration with the system tray on all operating systems.</p><p>The tray icon is enabled by default, but it can be toggled from&nbsp;<a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a>&nbsp;β†’ <em>Desktop</em>.</p><p>The tray icon has the following functionality:</p><ul><li>When clicked, the last window is hidden (minimized to the tray icon). Clicking it again will reveal that window.</li><li>Right clicking reveals the following options:<ul><li>Each window can be individually shown or hidden, identified by their active note.</li><li>New windows can be opened.</li><li>A new note can be created directly, which will be created in the&nbsp;<a class=\"reference-link\" href=\"#root/_help_S0Fos78ZfcY7\">Note Inbox</a>&nbsp;(or&nbsp;<a class=\"reference-link\" href=\"#root/_help_l0tKav7yLHGF\">Day Notes</a>&nbsp;if an inbox is not available).</li><li>Today's day note can be opened.</li><li>Bookmarks and recent notes are displayed in a sub-menu and clicking them navigates to that note.</li><li>Quitting the application.</li></ul></li></ul><h3>Opening a new window from the taskbar</h3><p>A new window can also be opened without the tray icon, by right-clicking the application's icon:</p><ul><li>On Windows, in the taskbar, select <em>Open New Window</em>.</li><li>On Linux, in the dock or application launcher (such as GNOME's or KDE's), select <em>New Window</em>.</li></ul><h3>Closing to system tray</h3><p>This is an option which is not enabled by default and it allows a specific behavior: instead of exiting the application when the last window has been closed, the last window is instead hidden with the tray icon remaining available.</p><p>This option requires the tray icon to be enabled, otherwise it has no effect.</p><h2>Automatic startup</h2><p>Two options control the automatic startup functionality in&nbsp;<a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a>&nbsp;β†’ <em>Startup</em>:</p><ul><li>When <em>Launch on startup</em> is enabled, the application will automatically start up when logging into the current user.<ul><li>Note that on Linux support depends on the desktop environment. Feel free to <a href=\"#root/_help_wy8So3yZZlH9\">report</a> any issues.</li></ul></li><li>If <em>Start minimized to tray</em> is also enabled, the application will start up in the background and can be revealed from the tray icon.<ul><li>This only applies if <em>Launch on startup</em> is enabled, manual starts are not impacted by this option.</li></ul></li></ul><h3>Linux: Flatpak</h3><p>The Flatpak cannot write to the autostart directory itself, so <em>Launch on startup</em> asks the desktop's Background portal instead, which creates <code>~/.config/autostart/org.triliumnotes.Trilium.desktop</code>. If the desktop environment is set to ask before letting applications run in the background, it shows a prompt the first time; denying it leaves <em>Launch on startup</em> without effect, and the permission can be changed later from the system settings.</p><h3>Linux: custom launch command for packagers</h3><p>On Linux, <em>Launch on startup</em> writes a <code>trilium.desktop</code> entry to the user's autostart directory (<code>$XDG_CONFIG_HOME/autostart</code>, usually <code>~/.config/autostart</code>). Its <code>Exec</code> line points to the AppImage when running from one, or to the running executable otherwise.</p><p>Distribution packages that run Trilium on a system-wide Electron (for example <code>electron /usr/lib/trilium/app.asar</code>) cannot rely on the running executable, since it is the bare Electron binary, which starts without Trilium. Such packages can set the <code>TRILIUM_LAUNCH_EXEC</code> environment variable, typically in their wrapper script, to the full command that starts Trilium:</p><pre><code class=\"language-text-x-trilium-auto\">export TRILIUM_LAUNCH_EXEC='electron \"/usr/lib/trilium/app.asar\"'</code></pre><p>The value is written to the <code>Exec</code> line as-is, so any paths containing spaces must already be quoted. When <em>Start minimized to tray</em> is enabled, <code>--start-hidden</code> is appended to it. <code>TRILIUM_LAUNCH_EXEC</code> takes precedence over both the AppImage path and the running executable.</p>",
"_help_hvRfsDr591WP": "<h2>Trilium only shows a blank window</h2><p>Trilium uses Electron which is based on Chromium (the open-source alternative to Google Chrome); in order to improve performance it makes use of <em>GPU acceleration</em>. In some cases, a GPU incompatibility (especially on older models of integrated graphics) can cause nothing to render at all, resulting in a blank window.&nbsp;</p><p>To bypass this, try running Trilium with the following command line argument:</p><pre><code class=\"language-text-x-trilium-auto\">trilium --disable-gpu</code></pre><p>If that doesn't work, try the following commands as well:</p><ul><li><code>trilium --disable-gpu-compositing</code></li><li><code>ELECTRON_OZONE_PLATFORM_HINT=x11 trilium</code> (this one forces the rendering to X11 on Wayland)</li></ul><p>If Trilium renders fine after this, Trilium offers a built-in option to disable GPU acceleration: go to&nbsp;<a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a>&nbsp;β†’ <em>Appearance</em>, look for the <em>Performance</em> section and then uncheck <em>Hardware acceleration (GPU)</em>.</p>",
"_help_WOcw2SLH6tbX": "<p>This guide outlines the steps to install Trilium on your own server. You might consider this option if you want to set up <a href=\"#root/_help_cbkrhQjrkKrh\">synchronization</a> or use Trilium in a browser - accessible from anywhere.</p><h2>Installation Options</h2><p>There are several ways to install Trilium on a server, each with its own advantages:</p><ul><li><strong>Recommended</strong>: <a href=\"#root/_help_rWX5eY045zbE\">Docker Installation</a> - Available for <strong>AMD64</strong> and <strong>ARM</strong> architectures.</li><li><a href=\"#root/_help_3tW6mORuTHnB\">Packaged Server Installation</a></li><li><a href=\"https://www.pikapods.com/pods?run=trilium-next\">PikaPods managed hosting</a></li><li><a href=\"#root/_help_J1Bb6lVlwU5T\">Manual Installation</a></li><li><a href=\"#root/_help_DCmT6e7clMoP\">Kubernetes</a></li><li><a href=\"https://www.cloudron.io/store/com.github.trilium.cloudronapp.html\">Cloudron</a></li><li><a href=\"https://homelabos.com/docs/software/trilium/\">HomelabOS</a></li><li><a href=\"#root/_help_moVgBcoxE3EK\">NixOS Module</a></li></ul><p>The server installation includes both web and <a href=\"#root/_help_RDslemsQ6gCp\">mobile frontends</a>.</p><h2>Configuration</h2><p>After setting up your server installation, you may want to configure settings such as the port or enable <a href=\"#root/_help_l2VkvOwUNfZj\">TLS</a>. Configuration is managed via the Trilium <code>config.ini</code> file, which is located in the <a href=\"#root/_help_tAassRL4RSQL\">data directory</a> by default. To begin customizing your setup, copy the provided <code>config-sample.ini</code> file with default values to <code>config.ini</code>.</p><p>You can also review the <a href=\"#root/_help_Gzjqa934BdH4\">configuration</a> file to provide all <code>config.ini</code> values as environment variables instead.</p><h3>Config Location</h3><p>By default, <code>config.ini</code>, the <a href=\"#root/_help_wX4HbRucYSDD\">database</a>, and other important Trilium data files are stored in the <a href=\"#root/_help_tAassRL4RSQL\">data directory</a>. If you prefer a different location, you can change it by setting the <code>TRILIUM_DATA_DIR</code> environment variable:</p><pre><code class=\"language-text-x-trilium-auto\">export TRILIUM_DATA_DIR=/home/myuser/data/my-trilium-data</code></pre><h3>Disabling Authentication</h3><p>See&nbsp;<a class=\"reference-link\" href=\"#root/_help_0hzsNCP31IAB\">Authentication</a>.</p><h2>Reverse Proxy Setup</h2><p>To configure a reverse proxy for Trilium, you can use either <strong>nginx</strong> or <strong>Apache</strong>. You can also check out the documentation stored in the Reverse proxy folder.</p><div class=\"trilium-tabs\"><section class=\"trilium-tab\"><p class=\"trilium-tab-title\">nginx</p><div class=\"trilium-tab-panel\"><p>Add the following configuration to your <code>nginx</code> setup to proxy requests to Trilium:</p><pre><code class=\"language-text-x-trilium-auto\">location /trilium/ {\n proxy_pass http://127.0.0.1:8080/;\n proxy_http_version 1.1;\n proxy_set_header Upgrade $http_upgrade;\n proxy_set_header Connection 'upgrade';\n proxy_set_header Host $host;\n proxy_cache_bypass $http_upgrade;\n}</code></pre><p>To avoid limiting the size of payloads, include this in the <code>server {}</code> block:</p><pre><code class=\"language-text-x-trilium-auto\"># Set to 0 for unlimited. Default is 1M.\nclient_max_body_size 0;</code></pre></div></section><section class=\"trilium-tab\"><p class=\"trilium-tab-title\">Apache</p><div class=\"trilium-tab-panel\"><p>For an Apache setup, refer to the&nbsp;<a class=\"reference-link\" href=\"#root/_help_fDLvzOx29Pfg\">Apache using Docker</a>&nbsp;guide.</p></div></section></div>",
"_help_3tW6mORuTHnB": "<p>This is essentially Trilium sources + node modules + node.js runtime packaged into one 7z file.</p><h2>Steps</h2><ul><li>SSH into your server</li><li>use <code>wget</code> (or <code>curl</code>) to download latest <code>TriliumNotes-Server-[VERSION]-linux-x64.tar.xz</code> (copy link from <a href=\"https://github.com/TriliumNext/Trilium/releases\">release page</a>, notice <code>-Server</code> suffix) on your server.</li><li>unpack the archive, e.g. using <code>tar -xf -d TriliumNotes-Server-[VERSION]-linux-x64.tar.xz</code></li><li><code>cd trilium-linux-x64-server</code></li><li><code>./trilium.sh</code></li><li>you can open the browser and open http://[your-server-hostname]:8080 and you should see Trilium initialization page</li><li>the console lists the addresses the server can be reached on, so you can also copy one from there</li></ul><p>The problem with above steps is that once you close the SSH connection, the Trilium process is terminated. To avoid that, you have two options:</p><ul><li>Kill it (with e.g. <kbd>Ctrl</kbd> + <kbd>C</kbd>) and run again like this: <code>nohup ./trilium.sh &amp;</code>. (nohup keeps the process running in the background, <code>&amp;</code> runs it in the background)</li><li>Configure systemd to automatically run Trilium in the background on every boot</li></ul><h2>Configure Trilium to auto-run on boot with systemd</h2><ul><li>After downloading, extract and move Trilium:</li></ul><pre><code class=\"language-text-x-trilium-auto\">tar -xvf TriliumNotes-Server-[VERSION]-linux-x64.tar.xz\nsudo mv trilium-linux-x64-server /opt/trilium</code></pre><ul><li>Create the service:</li></ul><pre><code class=\"language-text-x-trilium-auto\">sudo nano /etc/systemd/system/trilium.service</code></pre><ul><li>Paste this into the file (replace the user and group as needed):</li></ul><pre><code class=\"language-text-x-trilium-auto\">[Unit]\nDescription=Trilium Daemon\nAfter=syslog.target network.target\n\n[Service]\nUser=xxx\nGroup=xxx\nType=simple\nExecStart=/opt/trilium/trilium.sh\nWorkingDirectory=/opt/trilium/\n\nTimeoutStopSec=20\n# KillMode=process leads to error, according to https://www.freedesktop.org/software/systemd/man/systemd.kill.html\nRestart=always\n\n[Install]\nWantedBy=multi-user.target</code></pre><ul><li>Save the file (CTRL-S) and exit (CTRL-X)</li><li>Enable and launch the service:</li></ul><pre><code class=\"language-text-x-trilium-auto\">sudo systemctl enable --now -q trilium</code></pre><ul><li>You can now open a browser to http://[your-server-hostname]:8080 and you should see the Trilium initialization page.</li></ul><h2>Simple auto-update for Server</h2><p>The script is available in&nbsp;<a class=\"reference-link\" href=\"#root/_help_ZNAjFcxqHr9V\">Simple auto-update for server</a>.</p><ul><li><p>Run as the same User Trilium runs.</p><ul><li>If you run as <code>root</code> please remove <code>sudo</code> from the commands.</li></ul></li><li><p>Requires <code>jq</code>:</p><pre><code class=\"language-text-x-sh\">apt install jq</code></pre></li></ul><p>It will stop the service above, overwrite everything (expecting no <code>config.ini</code>), and start service. It also creates a version file in the Trilium directory so it updates only with a newer version.</p><h2>Common issues</h2><h3>Outdated glibc</h3><pre><code class=\"language-text-x-trilium-auto\">Error: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by /var/www/virtual/.../node_modules/@mlink/scrypt/build/Release/scrypt.node)\n at Object.Module._extensions..node (module.js:681:18)\n at Module.load (module.js:565:32)\n at tryModuleLoad (module.js:505:12)</code></pre><p>If you get an error like this, you need to either upgrade your glibc (typically by upgrading to up-to-date distribution version) or use some other <a href=\"#root/_help_WOcw2SLH6tbX\">server installation</a> method.</p><h2>TLS</h2><p>Don't forget to <a href=\"#root/_help_l2VkvOwUNfZj\">configure TLS</a>, which is required for secure usage!</p>",
diff --git a/docs/User Guide/User Guide/Installation & Setup/Desktop Installation/Tray icon & automatic startup.md b/docs/User Guide/User Guide/Installation & Setup/Desktop Installation/Tray icon & automatic startup.md
index d299a99e66..0732e181dc 100644
--- a/docs/User Guide/User Guide/Installation & Setup/Desktop Installation/Tray icon & automatic startup.md
+++ b/docs/User Guide/User Guide/Installation & Setup/Desktop Installation/Tray icon & automatic startup.md
@@ -43,6 +43,10 @@ Two options control the automatic startup functionality inΒ <a class="reference-
* If _Start minimized to tray_ is also enabled, the application will start up in the background and can be revealed from the tray icon.
* This only applies if _Launch on startup_ is enabled, manual starts are not impacted by this option.
+### Linux: Flatpak
+
+The Flatpak cannot write to the autostart directory itself, so _Launch on startup_ asks the desktop's Background portal instead, which creates `~/.config/autostart/org.triliumnotes.Trilium.desktop`. If the desktop environment is set to ask before letting applications run in the background, it shows a prompt the first time; denying it leaves _Launch on startup_ without effect, and the permission can be changed later from the system settings.
+
### Linux: custom launch command for packagers
On Linux, _Launch on startup_ writes a `trilium.desktop` entry to the user's autostart directory (`$XDG_CONFIG_HOME/autostart`, usually `~/.config/autostart`). Its `Exec` line points to the AppImage when running from one, or to the running executable otherwise.