在 Linux 平台通过 fc-match 查询默认字体 (#3922)
This commit is contained in:
@@ -21,6 +21,7 @@ import org.jackhuang.hmcl.java.JavaRuntime;
|
||||
import org.jackhuang.hmcl.task.Schedulers;
|
||||
import org.jackhuang.hmcl.util.Lang;
|
||||
import org.jackhuang.hmcl.util.function.ExceptionalFunction;
|
||||
import org.jackhuang.hmcl.util.io.IOUtils;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.File;
|
||||
@@ -75,6 +76,11 @@ public final class SystemUtils {
|
||||
return managedProcess.getProcess().waitFor();
|
||||
}
|
||||
|
||||
public static String run(String... command) throws Exception {
|
||||
return run(Arrays.asList(command),
|
||||
inputStream -> IOUtils.readFullyAsString(inputStream, OperatingSystem.NATIVE_CHARSET));
|
||||
}
|
||||
|
||||
public static <T> T run(List<String> command, ExceptionalFunction<InputStream, T, ?> convert) throws Exception {
|
||||
File nul = OperatingSystem.CURRENT_OS == OperatingSystem.WINDOWS
|
||||
? new File("NUL")
|
||||
|
||||
@@ -23,7 +23,6 @@ import com.google.gson.JsonObject;
|
||||
import org.jackhuang.hmcl.util.KeyValuePairUtils;
|
||||
import org.jackhuang.hmcl.util.StringUtils;
|
||||
import org.jackhuang.hmcl.util.gson.JsonUtils;
|
||||
import org.jackhuang.hmcl.util.io.IOUtils;
|
||||
import org.jackhuang.hmcl.util.platform.OperatingSystem;
|
||||
import org.jackhuang.hmcl.util.platform.SystemUtils;
|
||||
import org.jackhuang.hmcl.util.platform.hardware.CentralProcessor;
|
||||
@@ -103,8 +102,7 @@ public final class MacOSHardwareDetector extends HardwareDetector {
|
||||
|
||||
String json = null;
|
||||
try {
|
||||
json = SystemUtils.run(Arrays.asList("/usr/sbin/system_profiler", "SPDisplaysDataType", "-json"),
|
||||
inputStream -> IOUtils.readFullyAsString(inputStream, OperatingSystem.NATIVE_CHARSET));
|
||||
json = SystemUtils.run("/usr/sbin/system_profiler", "SPDisplaysDataType", "-json");
|
||||
|
||||
JsonObject object = JsonUtils.GSON.fromJson(json, JsonObject.class);
|
||||
JsonArray spDisplaysDataType = object.getAsJsonArray("SPDisplaysDataType");
|
||||
|
||||
Reference in New Issue
Block a user