@@ -9,6 +9,7 @@ import * as Crypto from "effect/Crypto";
99import * as ElectronApp from "../electron/ElectronApp.ts" ;
1010import * as ElectronDialog from "../electron/ElectronDialog.ts" ;
1111import * as ElectronProtocol from "../electron/ElectronProtocol.ts" ;
12+ import * as ElectronSafeStorage from "../electron/ElectronSafeStorage.ts" ;
1213import { installDesktopIpcHandlers } from "../ipc/DesktopIpcHandlers.ts" ;
1314import * as DesktopAppIdentity from "./DesktopAppIdentity.ts" ;
1415import * as DesktopClerk from "./DesktopClerk.ts" ;
@@ -17,6 +18,7 @@ import * as DesktopBackendManager from "../backend/DesktopBackendManager.ts";
1718import * as DesktopEnvironment from "./DesktopEnvironment.ts" ;
1819import * as DesktopLifecycle from "./DesktopLifecycle.ts" ;
1920import * as DesktopObservability from "./DesktopObservability.ts" ;
21+ import * as DesktopPreReadyPlatform from "./DesktopPreReadyPlatform.ts" ;
2022import * as DesktopShutdown from "./DesktopShutdown.ts" ;
2123import * as DesktopServerExposure from "../backend/DesktopServerExposure.ts" ;
2224import * as DesktopAppSettings from "../settings/DesktopAppSettings.ts" ;
@@ -206,17 +208,45 @@ const startup = Effect.gen(function* () {
206208 const clerk = yield * DesktopClerk . DesktopClerk ;
207209 const shellEnvironment = yield * DesktopShellEnvironment . DesktopShellEnvironment ;
208210 const desktopSettings = yield * DesktopAppSettings . DesktopAppSettings ;
211+ const preReadyElectronOptions = yield * DesktopPreReadyPlatform . DesktopPreReadyElectronOptions ;
212+ const safeStorage = yield * ElectronSafeStorage . ElectronSafeStorage ;
209213 const updates = yield * DesktopUpdates . DesktopUpdates ;
210214 const environment = yield * DesktopEnvironment . DesktopEnvironment ;
211215
212216 yield * shellEnvironment . installIntoProcess ;
217+ const hasCommandLinePasswordStore =
218+ preReadyElectronOptions . linuxPasswordStoreCommandLine !== null ;
219+ const linuxElectronOptions =
220+ environment . platform === "linux" && ! hasCommandLinePasswordStore
221+ ? DesktopPreReadyPlatform . resolveEarlyLinuxElectronOptionsFromProcess ( )
222+ : preReadyElectronOptions . linux ;
223+ if ( linuxElectronOptions !== null && ! hasCommandLinePasswordStore ) {
224+ if (
225+ linuxElectronOptions . passwordStore !== null ||
226+ preReadyElectronOptions . linux ?. passwordStore !== null
227+ ) {
228+ yield * electronApp . removeCommandLineSwitch ( "password-store" ) ;
229+ }
230+ if ( linuxElectronOptions . passwordStore !== null ) {
231+ yield * electronApp . appendCommandLineSwitch (
232+ "password-store" ,
233+ linuxElectronOptions . passwordStore ,
234+ ) ;
235+ }
236+ }
213237 const userDataPath = yield * appIdentity . resolveUserDataPath ;
214238 yield * electronApp . setPath ( "userData" , userDataPath ) ;
215239 yield * logStartupInfo ( "runtime logging configured" , { logDir : environment . logDir } ) ;
216240 yield * desktopSettings . load ;
217241
218- if ( environment . platform === "linux" ) {
219- yield * electronApp . appendCommandLineSwitch ( "class" , environment . linuxWmClass ) ;
242+ if ( linuxElectronOptions !== null ) {
243+ yield * logStartupInfo ( "linux password store configured" , {
244+ passwordStore : hasCommandLinePasswordStore
245+ ? "command-line"
246+ : ( linuxElectronOptions . passwordStore ?? "electron-default" ) ,
247+ xdgCurrentDesktop : process . env . XDG_CURRENT_DESKTOP ?? null ,
248+ xdgSessionDesktop : process . env . XDG_SESSION_DESKTOP ?? null ,
249+ } ) ;
220250 }
221251
222252 yield * appIdentity . configure ;
@@ -228,6 +258,12 @@ const startup = Effect.gen(function* () {
228258 Effect . catchCause ( ( cause ) => fatalStartupCause ( "whenReady" , cause ) ) ,
229259 ) ;
230260 yield * logStartupInfo ( "app ready" ) ;
261+ if ( environment . platform === "linux" ) {
262+ const selectedBackend = yield * safeStorage . selectedStorageBackend ;
263+ yield * logStartupInfo ( "safe storage ready" , {
264+ backend : Option . getOrElse ( selectedBackend , ( ) => "unknown" ) ,
265+ } ) ;
266+ }
231267 yield * appIdentity . configure ;
232268 yield * applicationMenu . configure ;
233269 yield * updates . configure ;
0 commit comments