@@ -7,7 +7,7 @@ import * as NodeURL from "node:url";
77import * as Schema from "effect/Schema" ;
88import type { DesktopCaptureHelperState } from "@t3tools/contracts" ;
99import type { LinuxWindowSnapshot } from "./LinuxSnapShot.ts" ;
10- import { readPortalPng } from "./linuxCaptureSession.ts" ;
10+ import { CaptureSetupRequiredError , readPortalPng } from "./linuxCaptureSession.ts" ;
1111import { startNativeCaptureFeedback } from "./NativeCaptureFeedback.ts" ;
1212import { HYPRLAND_CAPTURE_ACTION } from "./linuxCaptureSession.ts" ;
1313export { isHyprlandCaptureSession } from "./linuxCaptureSession.ts" ;
@@ -167,9 +167,15 @@ export async function captureHyprlandWindow(
167167 paths : HyprlandCapturePaths ,
168168 options ?: { readonly flash : boolean ; readonly animate : boolean } ,
169169) : Promise < LinuxWindowSnapshot > {
170- const state = await new HyprlandCaptureSetup ( paths ) . state ( ) ;
171- if ( state . status !== "ready" )
172- throw new Error ( `${ state . message } Open Settings → SnapShots to continue setup.` ) ;
170+ const setup = new HyprlandCaptureSetup ( paths ) ;
171+ let state = await setup . state ( ) ;
172+ if ( state . status === "update-required" ) {
173+ await setup . perform ( "install-hyprland-helper" ) . catch ( ( cause : unknown ) => {
174+ throw new CaptureSetupRequiredError ( state . message , { cause } ) ;
175+ } ) ;
176+ state = await setup . state ( ) ;
177+ }
178+ if ( state . status !== "ready" ) throw new CaptureSetupRequiredError ( state . message ) ;
173179 const executable = hyprlandCaptureExecutable ( paths ) ;
174180 const directory = await NodeFSP . mkdtemp ( NodePath . join ( NodeOS . tmpdir ( ) , "t3-hyprland-capture-" ) ) ;
175181 const cleanup = ( ) => NodeFSP . rm ( directory , { recursive : true , force : true } ) ;
0 commit comments