@@ -49,13 +49,14 @@ public string FindTerminal(Models.ShellOrTerminal shell)
49
49
public List < Models . ExternalTool > FindExternalTools ( )
50
50
{
51
51
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" ) ) ;
55
55
finder . Fleet ( FindJetBrainsFleet ) ;
56
56
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" ) ) ;
59
60
return finder . Founded ;
60
61
}
61
62
@@ -117,7 +118,7 @@ public void OpenWithDefaultEditor(string file)
117
118
}
118
119
}
119
120
120
- private string FindExecutable ( string filename )
121
+ private string FindExecutable ( string filename , string flatpakAppId = null )
121
122
{
122
123
var pathVariable = Environment . GetEnvironmentVariable ( "PATH" ) ?? string . Empty ;
123
124
var paths = pathVariable . Split ( Path . PathSeparator , StringSplitOptions . RemoveEmptyEntries ) ;
@@ -128,6 +129,16 @@ private string FindExecutable(string filename)
128
129
return test ;
129
130
}
130
131
132
+ if ( flatpakAppId != null )
133
+ {
134
+ foreach ( var path in new [ ] { "/var/lib" , Environment . GetFolderPath ( Environment . SpecialFolder . LocalApplicationData ) } )
135
+ {
136
+ var test = Path . Combine ( path , "flatpak/exports/bin" , flatpakAppId ) ;
137
+ if ( File . Exists ( test ) )
138
+ return test ;
139
+ }
140
+ }
141
+
131
142
return string . Empty ;
132
143
}
133
144
@@ -136,5 +147,33 @@ private string FindJetBrainsFleet()
136
147
var path = $ "{ Environment . GetFolderPath ( Environment . SpecialFolder . LocalApplicationData ) } /JetBrains/Toolbox/apps/fleet/bin/Fleet";
137
148
return File . Exists ( path ) ? path : FindExecutable ( "fleet" ) ;
138
149
}
150
+
151
+ private static void FindJetBrainsFromFlatpak ( Models . ExternalToolsFinder finder )
152
+ {
153
+ foreach ( var basePath in new [ ] { "/var/lib" , Environment . GetFolderPath ( Environment . SpecialFolder . LocalApplicationData ) } )
154
+ {
155
+ var binPath = Path . Combine ( basePath , "flatpak/exports/bin" ) ;
156
+ if ( Directory . Exists ( binPath ) )
157
+ {
158
+ foreach ( var file in Directory . GetFiles ( binPath , "com.jetbrains.*" ) )
159
+ {
160
+ var fileName = Path . GetFileName ( file ) ;
161
+ var appName = fileName [ 14 ..] . Replace ( "-" , " " ) ;
162
+ var icon = new string ( Array . FindAll ( fileName . ToCharArray ( ) , char . IsUpper ) ) ;
163
+ if ( icon . Length > 2 )
164
+ icon = icon [ ..2 ] ;
165
+ icon = icon switch
166
+ {
167
+ "DG" => "DB" , // DataGrip
168
+ "GL" => "GO" , // GoLand
169
+ "IJ" => "JB" , // IntelliJ
170
+ "R" => "RD" , // Rider
171
+ _ => icon
172
+ } ;
173
+ finder . Founded . Add ( new Models . ExternalTool ( appName , "JetBrains/" + icon , file ) ) ;
174
+ }
175
+ }
176
+ }
177
+ }
139
178
}
140
179
}
0 commit comments