+
    }i                         ^ RI t ^ RIt^ RIHt ^ RIHt ^ RIHt ^ RIHt ^ RI	H
t
Ht ^ RIHtHtHt ^ RIHt  ! R	 R
4      tR# )    N)glob)Lock)	randrange)which)ListOptional)CannotExecuteXvfbCannotFindXvfbVirtualDisplayNotSupported)OS_NAMEc                      a  ] tR t^t o RtRV 3R lR lltRt]V 3R lR l4       t]V 3R lR l4       t	R t
V 3R	 lR
 ltR tR t]V 3R lR l4       t]V 3R lR l4       t]V 3R lR l4       t]R 4       tRtV tR# )VirtualDisplayz5
A minimal virtual display implementation for Linux.
c                4   < V ^8  d   QhRS[ S[,          RR/# )   debugreturnN)r   bool)format__classdict__s   "f/Users/ahmad/.openclaw/workspace/my-crawler/.venv/lib/python3.14/site-packages/camoufox/virtdisplay.py__annotate__VirtualDisplay.__annotate__   s      htn      c                L    Wn         RV n        RV n        \        4       V n        R# )z>
Constructor for the VirtualDisplay class (singleton object).
N)r   proc_displayr   _lock)selfr   s   &&r   __init__VirtualDisplay.__init__   s      
04	'+V
r   c                    < V ^8  d   QhRS[ /# r   r   str)r   r   s   "r   r   r   2   s     	 	3 	r   c                    \        R4      pV'       g   \        R4      h\        P                  ! V\        P                  4      '       g   \        RV 24      hV# )z%
Get the path to the xvfb executable
Xvfbz)Please install Xvfb to use headless mode.z*I do not have permission to execute Xvfb: )r   r
   osaccessX_OKr	   )r   paths   & r   	xvfb_pathVirtualDisplay.xvfb_path1   sK    
 V} !LMMyyrww''#&PQUPV$WXXr   c                0   < V ^8  d   QhRS[ S[,          /# r"   r   r$   )r   r   s   "r   r   r   >   s     E E$s) Er   c                P    V P                   RV P                   2.V P                  O# )z
Get the xvfb command
:)r+   display	xvfb_argsr   s   &r   xvfb_cmdVirtualDisplay.xvfb_cmd=   s'    
 !DLL> 2DT^^DDr   c                L   V P                   '       d&   \        RRP                  V P                  4      4       \        P
                  ! V P                  V P                   '       d   RM\        P                  V P                   '       d   RM\        P                  R7      V n        R# )z
Spawn a detatched process
zStarting virtual display: N)stdoutstderr)r   printjoinr4   
subprocessPopenDEVNULLr   r3   s   &r   execute_xvfbVirtualDisplay.execute_xvfbD   sd     :::-sxx/FG$$MM:::4:+=+=:::4:+=+=
	r   c                    < V ^8  d   QhRS[ /# r"   r#   )r   r   s   "r   r   r   P   s     & &S &r   c                8   V P                  4        V P                  ;_uu_ 4        V P                  f   V P                  4        M*V P                  '       d   \        RV P                   24       RV P                   2uuRRR4       #   + '       g   i     R# ; i)
Get the display number
NzUsing virtual display: r0   )assert_linuxr   r   r?   r   r:   r1   r3   s   &r   getVirtualDisplay.getP   sf     	ZZZyy !!#/~>?t||n% ZZZs   1B&BB	c                H   V P                   ;_uu_ 4        V P                  '       d_   V P                  P                  4       fC   V P                  '       d   \	        RV P
                  4       V P                  P                  4        RRR4       R#   + '       g   i     R# ; i)z
Terminate the xvfb process
NzTerminating virtual display:)r   r   pollr   r:   r1   	terminater3   s   &r   killVirtualDisplay.kill]   sZ     ZZZyyyTYY^^-5:::8$,,G		##%	 ZZZs   A B0BB!	c                &    V P                  4        R# )z+
Kill and delete the VirtualDisplay object
N)rJ   r3   s   &r   __del__VirtualDisplay.__del__g   s     			r   c                0   < V ^8  d   QhRS[ S[,          /# r"   r.   )r   r   s   "r   r   r   n   s     	< 	<T#Y 	<r   c                 8   \         P                  P                  RR4      p  \        \         P                  P                  V R4      4      pT Uu. uF,  p\         P                  P                  T4      '       g   K*  TNK.  	  up#   \         d    . u # i ; iu upi )z 
Get list of lock files in /tmp
TMPDIRz/tmpz.X*-lock)r'   environrE   r   r*   r;   FileNotFoundErrorisfile)tmpd
lock_filesps      r   _get_lock_filesVirtualDisplay._get_lock_filesm   sv    
 zz~~h/	bggll4<=J &;:a)::;; ! 	I	;s   )B 'B;BBBc                    < V ^8  d   QhRS[ /# r"   int)r   r   s   "r   r   r   z   s     A A3 Ar   c                     \        \        R \        P                  4       4      4      p V '       d'   \	        ^c\	        V 4      \        ^^4      ,           4      # ^c# )z
Search for free display
c                 p    \        V P                  R 4      ^,          P                  R4      ^ ,          4      # )X-)r\   split)xs   &r   <lambda>.VirtualDisplay._free_display.<locals>.<lambda>   s%    #aggcl1o33C8;<r   )listmapr   rX   maxr   )lss    r   _free_displayVirtualDisplay._free_displayy   sH    
 <n>\>\>^_
 79s2s2w1b!112@b@r   c                    < V ^8  d   QhRS[ /# r"   r[   )r   r   s   "r   r   r      s       r   c                `    V P                   f   V P                  4       V n         V P                   # )rC   )r   ri   r3   s   &r   r1   VirtualDisplay.display   s(    
 ==  ..0DM}}r   c                 2    \         R8w  d   \        R4      hR# )z%
Assert that the current OS is Linux
linz+Virtual display is only supported on Linux.N)r   r    r   r   rD   VirtualDisplay.assert_linux   s    
 e,-Z[[ r   )r   r   r   r   N)F)z-screen01x1x24z-acz	-nolistentcp
-extensionRENDERz
+extensionGLXru   	COMPOSITEru   XVideoru   zXVideo-MotionCompensationru   XINERAMAz-shmemz-fpz	built-insz	-nocursorz-br)__name__
__module____qualname____firstlineno____doc__r   r2   propertyr+   r4   r?   rE   rJ   rM   staticmethodrX   ri   r1   rD   __static_attributes____classdictcell__)r   s   @r   r   r      s      I$ 	 	 E E

& && 	< 	< A A   \ \r   r   )r'   r<   r   multiprocessingr   randomr   shutilr   typingr   r   camoufox.exceptionsr	   r
   r   camoufox.pkgmanr   r   rp   r   r   <module>r      s7    	       ! 
 $A\ A\r   