Skip to content

Commit 3b3c632

Browse files
committed
fix get device name under linux
1 parent ad53559 commit 3b3c632

File tree

3 files changed

+5
-14
lines changed

3 files changed

+5
-14
lines changed

app/src/main.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ int main(int argc, char* argv[]) {
5656
}
5757
}
5858

59+
std::setlocale(LC_ALL, "C.UTF-8");
5960
// Load cookies and settings
6061
auto& conf = AppConfig::instance();
6162
if (!conf.init()) {

app/src/utils/version.cpp

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -104,19 +104,9 @@ std::string AppVersion::getDeviceName() {
104104
return name.data();
105105
}
106106
#elif defined(__linux__)
107-
static const char* dev_names[] = {
108-
"/sys/devices/virtual/dmi/id/product_name",
109-
"/sys/devices/virtual/dmi/id/board_name",
110-
"/sys/firmware/devicetree/base/model",
111-
};
112-
for (size_t i = 0; i < sizeof(dev_names); i++) {
113-
std::ifstream f(dev_names[i]);
114-
if (f.is_open()) {
115-
std::string name;
116-
std::getline(f, name);
117-
while (!std::isprint(name.back())) name.pop_back();
118-
if (name.size() > 0) return name;
119-
}
107+
char name[256];
108+
if (!gethostname(name, sizeof(name))) {
109+
return name;
120110
}
121111
#endif
122112
return fmt::format("{} for {}", getPackageName(), getPlatform());

app/src/view/mpv_core.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ MPVCore::MPVCore() {
112112
}
113113

114114
void MPVCore::init() {
115-
setlocale(LC_NUMERIC, "C");
115+
std::setlocale(LC_NUMERIC, "C");
116116
#ifdef ANDROID
117117
auto env = static_cast<JNIEnv *>(SDL_AndroidGetJNIEnv());
118118
if (!env->GetJavaVM(&g_vm) && g_vm) av_jni_set_java_vm(g_vm, NULL);

0 commit comments

Comments
 (0)