fix neowofetch hardware detection on Interix if %WINDIR% isn't C:\Windows (#507)

* fix neowofetch failing to fetch system specs on Interix with a non-standard %WINDIR%

* fix memory being divided by 1024 too many times on Interix by neowofetch

* [F] Fix shell quoting

---------

Co-authored-by: Azalea <noreply@aza.moe>
This commit is contained in:
Rock Pie 2026-05-27 18:25:31 +01:00 committed by GitHub
parent 1890bb8f03
commit 44a0c28853
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1870,7 +1870,10 @@ get_model() {
;;
Interix)
model="$(/dev/fs/C/Windows/System32/wbem/WMIC.exe computersystem get manufacturer,model)"
local wmic_path
wmic_path="$(winpath2unix "$WINDIR")/System32/wbem/WMIC.exe"
model="$("$wmic_path" computersystem get manufacturer,model)"
model="${model/Manufacturer}"
model="${model/Model}"
;;
@ -3371,13 +3374,16 @@ END
;;
"Interix")
cpu="$(/dev/fs/C/Windows/System32/wbem/WMIC.exe cpu get Name)"
local wmic_path
wmic_path="$(winpath2unix "$WINDIR")/System32/wbem/WMIC.exe"
cpu="$("$wmic_path" cpu get Name)"
cpu="${cpu/Name}"
speed="$(/dev/fs/C/Windows/System32/wbem/WMIC.exe cpu get CurrentClockSpeed)"
speed="$("$wmic_path" cpu get CurrentClockSpeed)"
speed="${speed/CurrentClockSpeed}"
cores="$(/dev/fs/C/Windows/System32/wbem/WMIC.exe cpu get NumberOfCores)"
cores="$("$wmic_path" cpu get NumberOfCores)"
cores="${cores/NumberOfCores}"
;;
@ -3629,7 +3635,10 @@ get_gpu() {
;;
"Interix")
/dev/fs/C/Windows/System32/wbem/WMIC.exe path Win32_VideoController get caption | while read -r line; do
local wmic_path
wmic_path="$(winpath2unix "$WINDIR")/System32/wbem/WMIC.exe"
"$wmic_path" path Win32_VideoController get caption | while read -r line; do
line=$(trim "$line")
case $line in
@ -3795,15 +3804,17 @@ get_memory() {
;;
"Interix")
mem_total="$(/dev/fs/C/Windows/System32/wbem/WMIC.exe computersystem get TotalPhysicalMemory)"
local wmic_path
wmic_path="$(winpath2unix "$WINDIR")/System32/wbem/WMIC.exe"
mem_total="$("$wmic_path" computersystem get TotalPhysicalMemory)"
mem_total="${mem_total//[[:space:]]}"
mem_total="${mem_total/TotalPhysicalMemory}"
mem_total="$((mem_total / 1024 / 1024))"
mem_total="$((mem_total / 1024))"
mem_free="$(/dev/fs/C/Windows/System32/wbem/WMIC.exe os get FreePhysicalMemory)"
mem_free="$("$wmic_path" os get FreePhysicalMemory)"
mem_free="${mem_free//[[:space:]]}"
mem_free="${mem_free/FreePhysicalMemory}"
mem_free="$((mem_free / 1024))"
mem_used="$((mem_total - mem_free))"
;;
@ -5277,10 +5288,13 @@ get_battery() {
;;
"Interix")
battery="$(/dev/fs/C/Windows/System32/wbem/WMIC.exe Path Win32_Battery get EstimatedChargeRemaining)"
local wmic_path
wmic_path="$(winpath2unix "$WINDIR")/System32/wbem/WMIC.exe"
battery="$("$wmic_path" Path Win32_Battery get EstimatedChargeRemaining)"
battery="${battery/EstimatedChargeRemaining}"
battery="$(trim "$battery")%"
state="$(/dev/fs/C/Windows/System32/wbem/WMIC.exe /NameSpace:'\\root\WMI' Path BatteryStatus get Charging)"
state="$("$wmic_path" /NameSpace:'\\root\WMI' Path BatteryStatus get Charging)"
state="${state/Charging}"
[[ "$state" == *TRUE* ]] && battery_state="charging"
;;