@@ -49,14 +49,15 @@ public string FindTerminal(Models.ShellOrTerminal shell)
4949 public List < Models . ExternalTool > FindExternalTools ( )
5050 {
5151 var finder = new Models . ExternalToolsFinder ( ) ;
52- finder . VSCode ( ( ) => FindExecutable ( "code" ) ) ;
53- finder . VSCodeInsiders ( ( ) => FindExecutable ( "code-insiders" ) ) ;
54- finder . VSCodium ( ( ) => FindExecutable ( "codium" ) ) ;
52+ finder . VSCode ( ( ) => FindExecutable ( "code" , "com.visualstudio.code" ) ) ;
53+ finder . VSCodeInsiders ( ( ) => FindExecutable ( "code-insiders" , "com.vscodium.codium-insiders" ) ) ;
54+ finder . VSCodium ( ( ) => FindExecutable ( "codium" , "com.vscodium.codium" ) ) ;
5555 finder . Cursor ( ( ) => FindExecutable ( "cursor" ) ) ;
5656 finder . Fleet ( FindJetBrainsFleet ) ;
5757 finder . FindJetBrainsFromToolbox ( ( ) => $ "{ Environment . GetFolderPath ( Environment . SpecialFolder . LocalApplicationData ) } /JetBrains/Toolbox") ;
58- finder . SublimeText ( ( ) => FindExecutable ( "subl" ) ) ;
59- finder . Zed ( ( ) => FindExecutable ( "zeditor" ) ) ;
58+ FindJetBrainsFromFlatpak ( finder ) ;
59+ finder . SublimeText ( ( ) => FindExecutable ( "subl" , "com.sublimetext.three" ) ) ;
60+ finder . Zed ( ( ) => FindExecutable ( "zeditor" , "dev.zed.Zed" ) ) ;
6061 return finder . Founded ;
6162 }
6263
@@ -118,7 +119,7 @@ public void OpenWithDefaultEditor(string file)
118119 }
119120 }
120121
121- private string FindExecutable ( string filename )
122+ private string FindExecutable ( string filename , string flatpakAppId = null )
122123 {
123124 var pathVariable = Environment . GetEnvironmentVariable ( "PATH" ) ?? string . Empty ;
124125 var paths = pathVariable . Split ( Path . PathSeparator , StringSplitOptions . RemoveEmptyEntries ) ;
@@ -129,6 +130,16 @@ private string FindExecutable(string filename)
129130 return test ;
130131 }
131132
133+ if ( flatpakAppId != null )
134+ {
135+ foreach ( var path in new [ ] { "/var/lib" , Environment . GetFolderPath ( Environment . SpecialFolder . LocalApplicationData ) } )
136+ {
137+ var test = Path . Combine ( path , "flatpak/exports/bin" , flatpakAppId ) ;
138+ if ( File . Exists ( test ) )
139+ return test ;
140+ }
141+ }
142+
132143 return string . Empty ;
133144 }
134145
@@ -137,5 +148,33 @@ private string FindJetBrainsFleet()
137148 var path = $ "{ Environment . GetFolderPath ( Environment . SpecialFolder . LocalApplicationData ) } /JetBrains/Toolbox/apps/fleet/bin/Fleet";
138149 return File . Exists ( path ) ? path : FindExecutable ( "fleet" ) ;
139150 }
151+
152+ private static void FindJetBrainsFromFlatpak ( Models . ExternalToolsFinder finder )
153+ {
154+ foreach ( var basePath in new [ ] { "/var/lib" , Environment . GetFolderPath ( Environment . SpecialFolder . LocalApplicationData ) } )
155+ {
156+ var binPath = Path . Combine ( basePath , "flatpak/exports/bin" ) ;
157+ if ( Directory . Exists ( binPath ) )
158+ {
159+ foreach ( var file in Directory . GetFiles ( binPath , "com.jetbrains.*" ) )
160+ {
161+ var fileName = Path . GetFileName ( file ) ;
162+ var appName = fileName [ 14 ..] . Replace ( "-" , " " ) ;
163+ var icon = new string ( Array . FindAll ( fileName . ToCharArray ( ) , char . IsUpper ) ) ;
164+ if ( icon . Length > 2 )
165+ icon = icon [ ..2 ] ;
166+ icon = icon switch
167+ {
168+ "DG" => "DB" , // DataGrip
169+ "GL" => "GO" , // GoLand
170+ "IJ" => "JB" , // IntelliJ
171+ "R" => "RD" , // Rider
172+ _ => icon
173+ } ;
174+ finder . Founded . Add ( new Models . ExternalTool ( appName , "JetBrains/" + icon , file ) ) ;
175+ }
176+ }
177+ }
178+ }
140179 }
141180}
0 commit comments