@@ -49,13 +49,14 @@ 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 . Fleet ( FindJetBrainsFleet ) ;
5656 finder . FindJetBrainsFromToolbox ( ( ) => $ "{ Environment . GetFolderPath ( Environment . SpecialFolder . LocalApplicationData ) } /JetBrains/Toolbox") ;
57- finder . SublimeText ( ( ) => FindExecutable ( "subl" ) ) ;
58- finder . Zed ( ( ) => FindExecutable ( "zeditor" ) ) ;
57+ FindJetBrainsFromFlatpak ( finder ) ;
58+ finder . SublimeText ( ( ) => FindExecutable ( "subl" , "com.sublimetext.three" ) ) ;
59+ finder . Zed ( ( ) => FindExecutable ( "zeditor" , "dev.zed.Zed" ) ) ;
5960 return finder . Founded ;
6061 }
6162
@@ -117,7 +118,7 @@ public void OpenWithDefaultEditor(string file)
117118 }
118119 }
119120
120- private string FindExecutable ( string filename )
121+ private string FindExecutable ( string filename , string flatpakAppId = null )
121122 {
122123 var pathVariable = Environment . GetEnvironmentVariable ( "PATH" ) ?? string . Empty ;
123124 var paths = pathVariable . Split ( Path . PathSeparator , StringSplitOptions . RemoveEmptyEntries ) ;
@@ -128,6 +129,17 @@ private string FindExecutable(string filename)
128129 return test ;
129130 }
130131
132+ if ( flatpakAppId != null )
133+ {
134+ var userBin = Path . Combine ( Environment . GetFolderPath ( Environment . SpecialFolder . LocalApplicationData ) , "flatpak/exports/bin" ) ;
135+ foreach ( var path in new [ ] { "/var/lib/flatpak/exports/bin" , userBin } )
136+ {
137+ var test = Path . Combine ( path , flatpakAppId ) ;
138+ if ( File . Exists ( test ) )
139+ return test ;
140+ }
141+ }
142+
131143 return string . Empty ;
132144 }
133145
@@ -136,5 +148,33 @@ private string FindJetBrainsFleet()
136148 var path = $ "{ Environment . GetFolderPath ( Environment . SpecialFolder . LocalApplicationData ) } /JetBrains/Toolbox/apps/fleet/bin/Fleet";
137149 return File . Exists ( path ) ? path : FindExecutable ( "fleet" ) ;
138150 }
151+
152+ private static void FindJetBrainsFromFlatpak ( Models . ExternalToolsFinder finder )
153+ {
154+ var userBin = Path . Combine ( Environment . GetFolderPath ( Environment . SpecialFolder . LocalApplicationData ) , "flatpak/exports/bin" ) ;
155+ foreach ( var path in new [ ] { "/var/lib/flatpak/exports/bin" , userBin } )
156+ {
157+ if ( Directory . Exists ( path ) )
158+ {
159+ foreach ( var file in Directory . GetFiles ( path , "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+ }
139179 }
140180}
0 commit comments