From 796d585f9c4aeab96490f2554dd3038fef464384 Mon Sep 17 00:00:00 2001 From: crowplexus <45212377+crowplexus@users.noreply.github.com> Date: Sun, 3 Nov 2024 09:01:56 -0400 Subject: [PATCH] fix xdg-open in NixOS (#426) since `/usr/bin/xdg-open` isn't an actual path in NixOS, it's actually BETTER to just invoke `xdg-open` without the full path --- source/funkin/backend/utils/CoolUtil.hx | 5 ++++- source/lime/system/System.hx | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/source/funkin/backend/utils/CoolUtil.hx b/source/funkin/backend/utils/CoolUtil.hx index 9fd7f3c52..3b8fff3d8 100644 --- a/source/funkin/backend/utils/CoolUtil.hx +++ b/source/funkin/backend/utils/CoolUtil.hx @@ -706,7 +706,10 @@ class CoolUtil */ @:noUsing public static inline function openURL(url:String) { #if linux - Sys.command('/usr/bin/xdg-open', [url]); + // generally `xdg-open` should work in every distro + var cmd = Sys.command("xdg-open", [url]); + // run old command JUST IN CASE it fails, which it shouldn't + if (cmd != 0) cmd = Sys.command("/usr/bin/xdg-open", [url]); #else FlxG.openURL(url); #end diff --git a/source/lime/system/System.hx b/source/lime/system/System.hx index 345996156..604bcdce7 100644 --- a/source/lime/system/System.hx +++ b/source/lime/system/System.hx @@ -304,7 +304,10 @@ class System #elseif mac Sys.command("/usr/bin/open", [path]); #elseif linux - Sys.command("/usr/bin/xdg-open", [path, "&"]); + // generally `xdg-open` should work in every distro + var cmd = Sys.command("xdg-open", [path, "&"]); + // run old command JUST IN CASE it fails, which it shouldn't + if (cmd != 0) cmd = Sys.command("/usr/bin/xdg-open", [path, "&"]); #elseif (js && html5) Browser.window.open(path, "_blank"); #elseif flash