@@ -49,14 +49,15 @@ 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 . Cursor ( ( ) => FindExecutable ( "cursor" ) ) ;
56
56
finder . Fleet ( FindJetBrainsFleet ) ;
57
57
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" ) ) ;
60
61
return finder . Founded ;
61
62
}
62
63
@@ -118,7 +119,7 @@ public void OpenWithDefaultEditor(string file)
118
119
}
119
120
}
120
121
121
- private string FindExecutable ( string filename )
122
+ private string FindExecutable ( string filename , string flatpakAppId = null )
122
123
{
123
124
var pathVariable = Environment . GetEnvironmentVariable ( "PATH" ) ?? string . Empty ;
124
125
var paths = pathVariable . Split ( Path . PathSeparator , StringSplitOptions . RemoveEmptyEntries ) ;
@@ -129,6 +130,16 @@ private string FindExecutable(string filename)
129
130
return test ;
130
131
}
131
132
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
+
132
143
return string . Empty ;
133
144
}
134
145
@@ -137,5 +148,33 @@ private string FindJetBrainsFleet()
137
148
var path = $ "{ Environment . GetFolderPath ( Environment . SpecialFolder . LocalApplicationData ) } /JetBrains/Toolbox/apps/fleet/bin/Fleet";
138
149
return File . Exists ( path ) ? path : FindExecutable ( "fleet" ) ;
139
150
}
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
+ }
140
179
}
141
180
}
0 commit comments