Skip to content

Commit 04965f3

Browse files
StarexifyKade-github
authored andcommitted
Add support for opening folders on Linux
1 parent 5d83603 commit 04965f3

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

source/funkin/util/FileUtil.hx

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1180,8 +1180,18 @@ class FileUtil
11801180
// thats why the above comment is there!
11811181
Sys.command('open', [pathFolder]);
11821182
#elseif linux
1183-
// TODO: implement linux
1184-
// some shit with xdg-open :thinking: emoji...
1183+
var exitCode = Sys.command("xdg-open", [pathFolder]);
1184+
if (exitCode == 0) return;
1185+
var fileManagers:Array<String> = ["dolphin", "nautilus", "nemo", "thunar", "caja", "konqueror", "spacefm", "pcmanfm"];
1186+
1187+
for (fm in fileManagers) {
1188+
if (Sys.command("which", [fm]) == 0) {
1189+
exitCode = Sys.command(fm, [pathFolder]);
1190+
if (exitCode == 0) return;
1191+
}
1192+
}
1193+
1194+
trace('No compatible file manager found for Linux.');
11851195
#end
11861196
#else
11871197
throw 'External folder open is not supported on this platform.';
@@ -1207,8 +1217,9 @@ class FileUtil
12071217
#elseif mac
12081218
Sys.command('open', ['-R', path]);
12091219
#elseif linux
1210-
// TODO: unsure of the linux equivalent to opening a folder and then "selecting" a file.
1211-
Sys.command('open', [path]);
1220+
trace('File selection not reliably supported on Linux, opening parent folder instead.');
1221+
path = Path.directory(path);
1222+
openFolder(path);
12121223
#end
12131224
#else
12141225
throw 'External file selection is not supported on this platform.';

0 commit comments

Comments
 (0)