diff --git a/src/main/index.ts b/src/main/index.ts index b61cde0ea..0249bf718 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -1,7 +1,37 @@ +import { execFileSync } from 'node:child_process'; + import { app } from 'electron'; import log from 'electron-log'; import { menubar } from 'menubar'; +// On Linux tiling WMs (Hyprland, Sway, i3, etc.), Electron fails to detect the +// correct password storage backend because XDG_CURRENT_DESKTOP doesn't match a +// known DE. Query D-Bus for an active Secret Service provider and, if found, tell +// Electron to use gnome-libsecret so safeStorage works correctly. +if ( + process.platform === 'linux' && + !app.commandLine.hasSwitch('password-store') +) { + try { + execFileSync( + 'dbus-send', + [ + '--session', + '--dest=org.freedesktop.DBus', + '--type=method_call', + '--print-reply', + '/org/freedesktop/DBus', + 'org.freedesktop.DBus.GetNameOwner', + 'string:org.freedesktop.secrets', + ], + { timeout: 2000, stdio: 'ignore' }, + ); + app.commandLine.appendSwitch('password-store', 'gnome-libsecret'); + } catch { + // D-Bus not available or no Secret Service provider — let Electron fall back + } +} + import { Paths, WindowConfig } from './config'; import { registerAppHandlers,