From 44a0c28853d0f90b8751ccf2a2acd70eaa970dde Mon Sep 17 00:00:00 2001 From: Rock Pie Date: Wed, 27 May 2026 18:25:31 +0100 Subject: [PATCH] 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 --- neofetch | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/neofetch b/neofetch index 408aca8f..e25563ea 100755 --- a/neofetch +++ b/neofetch @@ -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" ;;