+
    Ki  c                   s    R t ^ RIt^ RIt^ RIt^ RIt^ RIt^ RIHt ^ RIH	t	 ^ RI
HtHt ^ RIHt ^ RIHt ^ RIHtHtHt R R	 ltR
 R ltR R ltR tR tR tR tRR ltR tR tR tR t R t!R t"R t#R t$R# )z&Export lutris games to Steam shortcutsN)Path)format_installer_url)	resourcessystem)logger)vdf)convert_steamid64_to_steamid32get_active_steamid64get_user_data_dirsc                $    V ^8  d   QhR\         /# i   Zreturnstrformat   "?/usr/lib/python3.14/site-packages/lutris/util/steam/shortcut.py__annotate__r      s     9 9 9    c                 s    \        4       w  rV'       g   R# V^ ,          p\        V4      ^8  d&   \        4       pV'       d   \        V4      pWA9   d   Tp\        P
                  P                  WR4      # )z#Return config path for a Steam user Zconfig)r   lenr   r   ospathjoin)ZuserdatapathZuser_idsZuser_idZactive_accountZactive_account32s        r   get_config_pathr      s^    /1LqkG
8}q-/=nM+*77<<x88r   c                r	   r
   r   r   r   r   r   r       s     6 6 6r   c                  sj    \        4       p V '       g   R # \        P                  P                  V R4      # )r   zshortcuts.vdf)r   r   r   r   )config_path    r   get_shortcuts_vdf_pathr       s%    !#K77<<_55r   c                r	   r
   )boolr   r   r   r   r   '   s       r   c                  s     \        \        4       4      #   \         d#   p \        P                  ! R T 4        Rp ? R# Rp ? ii ; i)zFailed to locate vdf file: %sNF)r   r   	Exceptionr   error)exr   r   vdf_file_existsr    '   s8    *,-- 4b9s    A=Ac                s    \         P                  ! RV P                  RR4      4      pV'       g   R# VP                  4       ^ ,          pW1P                  8H  # )z:Test if the game seems to be the one a shortcut refers to.z.*lutris:rungameid/(\d+)LaunchOptionsr   F)reZmatchZgetZgroupsid)ZshortcutgameZid_matchZgame_id   &&  r   
matches_idr&   /   sC    xx3X\\/SU5VWHoo"Gggr   c                 s0   \        4       p V '       d&   \        P                  P                  V 4      '       g   . # \	        V R4      ;_uu_ 4       p\
        P                  ! VP                  4       4      R,          pRRR4       V#   + '       g   i     X# ; i)zReturn all Steam shortcutsrb	shortcutsN)r   r   r   existsopenr   binary_loadsread)shortcut_pathshortcut_filer(   s      r   get_shortcutsr/   8   sk    *,M} = =		mT	"	"m$$]%7%7%9:;G	 
# 
#	"s   ,BB	c                 s:  a   \        4       pV'       g   R # \        ;QJ d-    V 3R lVP                  4        4       F  '       g   K   R# 	  R # ! V 3R lVP                  4        4       4      #   \         d#   p\        P
                  ! RT4        Rp?R # Rp?ii ; i)Fc              3   sP   <"   T F  p\        VS4      '       g   K  Vx  K  	  R # 5i)N)r&   )Z.0sr$   s   & r   Z	<genexpr>Z"shortcut_exists.<locals>.<genexpr>G   s     H0Jq$4G110s   &
&Tz$Failed to read shortcut vdf file: %sN)r/   Zanyvaluesr   r   r   )r$   r(   r   s   f  r   shortcut_existsr2   B   sr    !O	sHi..0HssHsHsHi..0HHH ;R@s3   A- 
A- "A- A- 
A- A- -B8BBc                 s     V P                   R 8H  # )Zsteam)Zrunner_namer$      &r   is_steam_gamer5   M   s    w&&r   c                 s`   \        V 4      '       d   \        P                  ! R 4       R# \        P                  ! RV 4       \	        4       p\
        P                  P                  V4      '       dX   \        VR4      ;_uu_ 4       p\        P                  ! VP                  4       4      R,          P                  4       pRRR4       M. pV'       d   \        X4      \        W4      .,           pM\        X4      \        W4      .,           pR\!        V4       UUu/ uF  w  rg\#        V4      VbK  	  upp/p\        VR4      ;_uu_ 4       pVP%                  \        P&                  ! V4      4       RRR4       \)        V 4       R#   + '       g   i     L; iu uppi   + '       g   i     L6; i)z$Not updating shortcut for Steam gameNzCreating Steam shortcut for %sr'   r(   wb)r5   r   Zwarninginfor   r   r   r)   r*   r   r+   r,   r1   Zlistgenerate_standalone_shortcutgenerate_shortcut	enumerater   writebinary_dumpsset_artwork)	r$   launch_config_nameZ
standaloner-   r.   r(   indexelemupdated_shortcutss	   &&&      r   create_shortcutrB   Q   s5   T=>
KK0$7*,M	ww~~m$$-&&-((););)=>{KRRTI '& 	O'CD']&^^	O'8'R&SS	$9U^K_&`K_KEs5z4'7K_&`a	mT	"	"mC,,->?@ 
# '& 'a	"	"s   :FF	&FF	F-	c                 s   \         P                  ! R V 4       \        4       pV'       d&   \        P                  P                  V4      '       g   R# \        VR4      ;_uu_ 4       p\        P                  ! VP                  4       4      R,          P                  4       pRRR4       X Uu. uF  p\        W@4      '       d   K  VNK  	  pp\        V4      \        V4      8X  d   R# R\        V4       UUu/ uF  w  rg\        V4      VbK  	  upp/p\        VR4      ;_uu_ 4       pVP                  \        P                   ! V4      4       RRR4       R#   + '       g   i     L; iu upi u uppi   + '       g   i     R# ; i)zRemoving Steam shortcut for %sNr'   r(   r6   )r   r7   r   r   r   r)   r*   r   r+   r,   r1   r&   r   r:   r   r;   r<   )	r$   r-   r.   r(   r0   Zother_shortcutsr?   r@   rA   s	   &        r   remove_shortcutrC   h   s   
KK0$7*,M} = =	mT	"	"m$$]%7%7%9:;GNNP	 
#"+G)Q:a3Fqq)OG
9~_--$9UdKe&fKeKEs5z4'7Ke&fg	mT	"	"mC,,->?@ 
#	" 
#	"G 'g	"	"	"s*   %:E+E(E(5E-%&E3E%	3F	c                 s   \         P                  ! R 4      pVR8X  d   RpRV R2pRP                  W P                  .4      p\        P
                  ! \        P                  VR4      4      R,          pV^ ,          R,          # )lutris/app/bin/lutris/usr/bin/flatpak"r   zutf-8l        i   )shutilwhichr   namebinasciiZcrc32r   Zencode)r$   lutris_binaryZexeZ	unique_idZtops   &    r   generate_preliminary_idrM   x   sn    LL*M))*m_A
Cii()I
..Iw7
8:
EC2I##r   c                 s8    \        \        V 4      ^ ,	          4      # )    )r   rM   r3   r4   r   generate_appidrO      s    &t,233r   c                 s4    \        V 4      ^ ,	          R,
          # )rN   l        )rM   r3   r4   r   generate_shortcut_idrP      s    #D)R/;>>r   c                 sn   R p\        RRRV P                  RV/4      p\        P                  ! V4      p\	        4       '       d   RpRV,           pR\        V 4      RV P                  R	R
V R
2RR
\        P                  ! 4        R
2R\        P                  ! V P                  4      RVR^ R^R^R^ R^ R^ R^ /# )rD   action	rungameid	game_slugr>   rF   run net.lutris.Lutris appidAppNameExerG   StartDiriconr!   IsHiddenAllowDesktopConfigAllowOverlayOpenVRDevkitDevkitOverrideAppIDLastPlayTime)r   r#   shlexquoteis_flatpak_lutrisrP   rJ   r    homer   get_icon_pathslugr$   r>   rL   Zlaunch_optionsr%   r   r9   r9      s    M)	;TWW6JL^_N [[0N*1NB%d+499=/#a		}A&	''		2Aa!!q r   c                 s   \         P                  ! R 4      p\        RRRV P                  RV/4      p\        P
                  ! V4      pVR8X  d   RpRV,           pR\        V 4      R	V P                  R
R\        P                  ! 4       : RV P                   R2RR\        P                  ! 4       : R2R\        P                  ! V P                  4      RVR^ R^R^R^ R^ R^ R^ /# )rD   rQ   rR   rS   r>   rE   rF   rT   rU   rV   rW   rG   z"/.local/share/applications/lutris-z.sh"rX   z/.local/share/applications/"rY   r!   rZ   r[   r\   r]   r^   r_   r`   )rH   rI   r   r#   ra   rb   rP   rJ   r    rd   rf   r   re   rg   r%   r   r8   r8      s    LL*M)	;TWW6JL^_N [[0N))*1NB 	%d+499499;/!CDII;dSa		&BC	''		2Aa!!q r   c                  s4    \         P                  ! R 4      R8H  # )rD   rE   )rH   rI    r   r   rc   rc      s    <<!%666r   c                 s^   \        4       pV'       g   R # \        P                  P                  VR4      p\        P                  P	                  V4      '       g   \        P
                  ! V4       \        V 4      p\        P                  ! V P                  4      p\        P                  ! V P                  4      p\        P                  ! V P                  4      pRV\        P                  P                  VRP                  V4      4      3RV\        P                  P                  VRP                  V4      4      3RV\        P                  P                  VRP                  V4      4      3RV\        P                  P                  VR	P                  V4      4      3.pV FU  w  rp
\        P                  ! V
R
R7      '       d   K&   \        P                   ! W4       \"        P$                  ! RWV
4       KW  	  R #   \&         d$   p\"        P(                  ! RYY4        R p?K  R p?ii ; i)NZgridzgrid horizontalz{}.jpgzgrid verticalz{}p.jpgZheroz{}_hero.jpgrY   z{}_icon.jpgT)Zexclude_emptyzCopied %s %s asset to %sz$Failed to copy %s %s asset to %s: %s)r   r   r   r   r)   ZmakedirsrO   r   Zget_cover_pathrf   Zget_banner_pathre   r   r   Zpath_existsrH   Zcopyfiler   ZdebugZFileNotFoundErrorr   )r$   r   Zartwork_pathZshortcut_idZsource_coverZsource_bannerZsource_iconZassetsrJ   ZsourceZtargetr   s   &           r   r=   r=      s   !#K77<<V4L77>>,''
L! &K++DII6L--dii8M))$))4K	M277<<hooVaFb+cd	,\9CSCST_C`(ab	\=;O;OP[;\ ]^	bggll<9M9Mk9Z[\	F !'f!!&==]/7VL	 !'
 % ]CTQW\\]s   
.G>>H,	H''H,)NF)%Z__doc__rK   r   r"   ra   rH   Zpathlibr    Z
lutris.apir   Zlutris.utilr   r   Zlutris.util.logr   Zlutris.util.steamr   Zlutris.util.steam.configr   r   r   r   r   r    r&   r/   r2   r5   rB   rC   rM   rO   rP   r9   r8   rc   r=   rh   r   r   <module>ri      s~    ,  	 	    + ) " ! m m96'.A $4?:<7]r   