diff options
author | 諏訪子 <suwako@076.moe> | 2024-06-22 05:09:45 +0900 |
---|---|---|
committer | 諏訪子 <suwako@076.moe> | 2024-06-22 05:09:45 +0900 |
commit | bd0c69acc7f77c774ce21a990d186a8a249f2633 (patch) | |
tree | 94b2be19f43108109a13df41653f217d5672c4b5 | |
parent | 17341db8b3d73193e0b4ac8ae0c2a984d4ce10e7 (diff) | |
parent | 5518c6e98d218d72889160458a3b577007f5e131 (diff) |
Merge branch 'master' of gitler.moe:suwako/farfetch
-rw-r--r-- | src/cpu.c | 32 | ||||
-rw-r--r-- | src/host.c | 4 |
2 files changed, 9 insertions, 27 deletions
@@ -20,36 +20,18 @@ const char *display_cpu() { "sed 's/(r)//g; s/ CPU//; s/^ *//; s/ $//' | awk '{$1=$1};1' && " "echo \" (\" && psrinfo -p && echo \" core)\""); #elif defined(__linux__) - char buf[20]; - long int val; - double fmt; - FILE *fp = fopen("/sys/devices/system/cpu/cpu0/cpufreq/bios_limit", "r"); - if (fp == NULL) { - fp = fopen("/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq", "r"); - } - - if (fp == NULL) { - perror("失敗"); - return NULL; - } - - if (fgets(buf, sizeof(buf), fp) != NULL) { - val = strtol(buf, NULL, 10); - fmt = val / 1000000.0; - printf("%.2f", fmt); - } else { - perror("失敗"); - fclose(fp); - return NULL; - } - - fclose(fp); - return run_command_s("cat /proc/cpuinfo | awk -F '\\\\s*: | @' " "'/model name|Hardware|Processor|^cpu model|chip type|^cpu type/ { " "cpu=$2; if ($1 == \"Hardware\") exit } END { print cpu }' | " "sed 's/(R)//' | sed 's/(TM)//' | sed 's/CPU //' | sed 's/ Processor//' | " "sed 's/ [0-9]-Core//' && echo \" @ \" && " + "if [ \"$(LC_ALL=C cat /sys/devices/system/cpu/cpu0/cpufreq/bios_limit 2>&1)\"" + " != \"cat: /sys/devices/system/cpu/cpu0/cpufreq/bios_limit: " + "No such file or directory\" ]; then " + "cat /sys/devices/system/cpu/cpu0/cpufreq/bios_limit | " + "awk '{printf \"%.2f\", $1/1000000}'; else " + "cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq | " + "awk '{printf \"%.2f\", $1/1000000}'; fi && " "echo \"GHz (\" && nproc && echo \" core)\""); #endif return NULL; @@ -106,12 +106,12 @@ void display_host_model() { cmd1 = "getprop ro.product.brand"; cmd2 = "getprop ro.product.model"; } else if ( - access("/sys/devices/virtual/dmi/id/product_name", F_OK) != -1 || + access("/sys/devices/virtual/dmi/id/product_name", F_OK) != -1 && access("/sys/devices/virtual/dmi/id/product_version", F_OK) != 1 ) { cmd1 = "cat /sys/devices/virtual/dmi/id/product_name"; cmd2 = "cat /sys/devices/virtual/dmi/id/product_version"; - } else if (access("/sys/firmware/base/model", F_OK) != -1) { + } else if (access("/sys/firmware/devicetree/base/model", F_OK) != -1) { cmd1 = "cat /sys/firmware/devicetree/base/model"; } else if (access("/tmp/sysinfo/model", F_OK) != 1) { cmd1 = "cat /tmp/sysinfo/model"; |