+
    Ki   c                   s    R 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
 ^ RIHt ^ RIHt ^ RIHt ^ RIHt R	 tR
 tRR ltRR ltR tR tR tR tRR ltR# )zXDG shortcuts handlingN)dedent)GLib)format_installer_url)	CACHE_DIR)system)LINUX_SYSTEM)loggerc                  s@    \         P                  ! 4       '       d   R # R# )zflatpak run net.lutris.LutrisZlutris)r   
is_flatpak     =/usr/lib/python3.14/site-packages/lutris/util/xdgshortcuts.pyget_lutris_executabler      s      .r	   c                sB   R\         P                  P                  R\         P                  P                  R\         P                  P                  R\         P                  P
                  R\         P                  P                  R\         P                  P                  R\         P                  P                  /pV P                  4       p W9  d7   \        V R,           R	P                  VP                  4       4      ,           4      h\         P                  ! W,          4      # )
z)Return the path for specific user foldersZDESKTOPZMUSICZPICTURESZVIDEOSZ	DOCUMENTSZ	DOWNLOADSZ	TEMPLATESz2 not supported. Only those folders are supported: z, )r   UserDirectoryDIRECTORY_DESKTOPZDIRECTORY_MUSICZDIRECTORY_PICTURESZDIRECTORY_VIDEOSZDIRECTORY_DOCUMENTSZDIRECTORY_DOWNLOADZDIRECTORY_TEMPLATESZupperZ
ValueErrorjoinZkeysget_user_special_dir)Z	directoryZspecial_dirs   & r
   get_xdg_entryr      s     	4%%77##33D&&99$$$55T'';;T''::T'';;K !I#LLtyyYdYiYiYkOll
 	
 $$[%;<<r	   c                s    V'       dw   RP                  W4      RP                  W4      RP                  V 4      3 F@  p\        P                  ! \        P                  P                  W#4      4      '       g   K>  Vu # 	  RP                  W4      # )z*Return the filename for .desktop shortcutsznet.lutris.{}-{}.desktopz{}-{}.desktopz
{}.desktop)formatr   path_existsospathr   )	game_sluggame_idbase_dirr   s   &&& r
   get_xdg_basenamer   +   su     '--iA""96	*
D
 !!"'',,x">??
 &,,Y@@r	   c                s   \         P                  ! \         P                  P                  4      p\	        4       p\        RRRVRV/4      pV R\        P                  ! V4       2P                  RR4      p	\        P                  ! 4       '       d   RMR	p
\        R
P                  VRV  2W4      4      p\        W4      p\        P                  P!                  \"        V4      p\%        VRRR7      ;_uu_ 4       pVP'                  V4       VP)                  4        RRR4       \        P*                  ! V\,        P.                  \,        P0                  ,          \,        P2                  ,          \,        P4                  ,          4       V'       de   \        P6                  ! VRR7       \        P                  P!                  Wl4      p\8        P:                  ! RV4       \<        P>                  ! W4       V'       d   \        P                  ! 4       '       d    \        P                  PA                  R4      M\         PB                  ! 4       p\        P                  P!                  VR4      p\        P6                  ! VRR7       \        P                  P!                  VV4      p\8        P:                  ! RV4       \<        P>                  ! W4       \        PD                  ! V4       R#   + '       g   i     EL; i)zCreate a .desktop file.ZactionZ	rungameidr   launch_config_nameZ Z%z%%Z zTryExec=lutrisz
        [Desktop Entry]
        Type=Application
        Name={}
        Icon={}
        Exec=env LUTRIS_SKIP_INIT=1 {}
        Categories=Game
        {}
        Zlutris_Zwzutf-8)ZencodingNT)Zexist_okzCreating Desktop icon in %sz~/.local/shareapplicationszCreating menu launcher in %s)#r   r   r   r   r   r   shlexZquoteZreplacer   r   r    r   r   r   r   r   r   ZopenZwriteZcloseZchmodstatZS_IREADZS_IWRITEZS_IRGRPZS_IWGRPZmakedirsr   ZdebugshutilZcopyZ
expanduserget_user_data_dirremove)r   r   Z	game_namer   desktopmenudesktop_dirZlutris_executableZurlZcommandZtry_execZlauncher_contentZlauncher_filenameZtmp_launcher_pathZtmp_launcherlauncher_pathZuser_dir	menu_paths   &&&&&&            r
   create_launcherr%   ;   s   ++D,>,>,P,PQK-/
+{GMacuv
wC ##1U[[%5$67??TJG!,,..r4DH	 F9	{3WG
 )<Y0AB	w	7	7<+, 
8 HHt}}$t||3dllB
 
K$/[D2MB%5;G;R;R;T;T277%%&67Z^ZpZpZrGGLL>:	
I-Y0AB3]C%5II ) 
8	7	7s   8"K&&K7	c           	     s    \         P                  ! \         P                  P                  4      p\        P
                  P                  V\        WVR7      4      # )zReturn the path of a XDG game launcher.
When legacy is set, it will return the old path with only the slug,
otherwise it will return the path with slug + id
r   )r   r   r   r   r   r   r   r   )r   r   r"      && r
   get_launcher_pathr(   m   s>    
 ++D,>,>,P,PQK77<<%5iS^%_``r	   c           	     s    \         P                  P                  \        P                  ! 4       R4      p\         P                  P                  V\        WVR7      4      # )zPReturn the path to a XDG menu launcher, prioritizing legacy paths if
they exist
r   r&   )r   r   r   r   r   r   )r   r   Zmenu_dirr'   r
   get_menu_launcher_pathr)   w   s?     ww||D224nEH77<<"29PX"YZZr	   c                @    \         P                  ! \        W4      4      # )z;Return True if there is an existing desktop icon for a game)r   r   r(   r   r      &&r
   desktop_launcher_existsr-      s    /	CDDr	   c                r*   )zEReturn True if there is an existing application menu entry for a game)r   r   r)   r+   r,   r
   menu_launcher_existsr.      s    4YHIIr	   c                s"   V'       d>   \        W4      p\        P                  ! V4      '       d   \        P                  ! V4       V'       dB   \        W4      p\        P                  ! V4      '       d   \        P                  ! V4       R# R# R# )zRemove existing .desktop file.N)r(   r   r   r   r   r)   )r   r   r    r!   r#   r$   s   &&&&  r
   remove_launcherr/      s`    ))=m,,IIm$*9>	i((IIi  ) r	   )N)NFF)FF)Z__doc__r   r   r   r   Ztextwrapr    Zgi.repositoryr   Z
lutris.apir   Zlutris.settingsr   Zlutris.utilr   Zlutris.util.linuxr   Zlutris.util.logr   r   r   r   r%   r(   r)   r-   r.   r/   r   r	   r
   <module>r0      s\     	      + %  * "=&A /!da[E
J

!r	   