Skip to content

Commit

Permalink
[PR] dylanaraps#2409 from makuhlmann - Added support for Interix (Win…
Browse files Browse the repository at this point in the history
…dows Subsystem for UNIX)

Upstream PR: dylanaraps#2409
Thanks to @makuhlmann

Co-authored-by: makuhlmann <[email protected]>
  • Loading branch information
hykilpikonna and makuhlmann committed Nov 1, 2023
2 parents 91ced42 + ec86933 commit 05bdef9
Showing 1 changed file with 106 additions and 2 deletions.
108 changes: 106 additions & 2 deletions neofetch
Original file line number Diff line number Diff line change
Expand Up @@ -1028,6 +1028,7 @@ get_os() {
AIX) os=AIX ;;
IRIX*) os=IRIX ;;
FreeMiNT) os=FreeMiNT ;;
Interix) os=Interix ;;

Linux|GNU*)
os=Linux
Expand Down Expand Up @@ -1465,6 +1466,10 @@ get_distro() {
FreeMiNT)
distro=FreeMiNT
;;

Interix)
distro="Interix ${kernel_version}"
;;
esac

distro=${distro//Enterprise Server}
Expand Down Expand Up @@ -1772,6 +1777,12 @@ get_model() {
model=$(sysctl -n hw.model)
model=${model/ (_MCH *)}
;;

Interix)
model="$(/dev/fs/C/Windows/System32/wbem/WMIC.exe computersystem get manufacturer,model)"
model="${model/Manufacturer}"
model="${model/Model}"
;;
esac

# Remove dummy OEM info.
Expand Down Expand Up @@ -1847,6 +1858,13 @@ get_kernel() {
return
}

# In Interix the Kernel version is commonly comprised of the host OS build number,
# OS architecture and Interix build number
[[ $os == Interix ]] && {
kernel="$(uname -r) $(uname -m) $(uname -v)"
return
}

case $kernel_shorthand in
on) kernel=$kernel_version ;;
off) kernel="$kernel_name $kernel_version" ;;
Expand Down Expand Up @@ -1903,6 +1921,19 @@ get_uptime() {
s=$((${d:-0}*86400 + ${h:-0}*3600 + ${t%%:*}*60 + ${t#*:}))
;;

Interix)
t="$(LC_ALL=POSIX ps -o etime= -p 0)"
t="${t%%.*}"

[[ $t == *-* ]] && { d=${t%%-*}; t=${t#*-}; }
[[ $t == *:*:* ]] && { h=${t%%:*}; t=${t#*:}; }

h="${h#0}"
t="${t#0}"

s="$((${d:-0}*86400 + ${h:-0}*3600 + ${t%%:*}*60 + ${t#*:}))"
;;

Haiku)
s=$(($(system_time) / 1000000))
;;
Expand Down Expand Up @@ -2001,7 +2032,7 @@ get_packages() {

# OS-specific package managers.
case $os in
Linux|BSD|"iPhone OS"|Solaris|illumos)
Linux|BSD|"iPhone OS"|Solaris|illumos|Interix)
# Package Manager Programs.
has kiss && tot kiss l
has cpt-list && tot cpt-list
Expand Down Expand Up @@ -3142,6 +3173,17 @@ END
cpu="$(awk -F':' '/CPU:/ {printf $2}' /kern/cpuinfo)"
speed="$(awk -F '[:.M]' '/Clocking:/ {printf $2}' /kern/cpuinfo)"
;;

"Interix")
cpu="$(/dev/fs/C/Windows/System32/wbem/WMIC.exe cpu get Name)"
cpu="${cpu/Name}"

speed="$(/dev/fs/C/Windows/System32/wbem/WMIC.exe cpu get CurrentClockSpeed)"
speed="${speed/CurrentClockSpeed}"

cores="$(/dev/fs/C/Windows/System32/wbem/WMIC.exe cpu get NumberOfCores)"
cores="${cores/NumberOfCores}"
;;
esac

# Remove un-needed patterns from cpu output.
Expand Down Expand Up @@ -3387,6 +3429,22 @@ get_gpu() {
done
;;

"Interix")
/dev/fs/C/Windows/System32/wbem/WMIC.exe path Win32_VideoController get caption | while read -r line; do
line=$(trim "$line")

case $line in
*Caption*|'')
continue
;;

*)
prin "${subtitle:+${subtitle}${gpu_name}}" "$line"
;;
esac
done
;;

"Haiku")
gpu="$(listdev | grep -A2 -F 'device Display controller' |\
awk -F':' '/device beef/ {print $2}')"
Expand Down Expand Up @@ -3531,6 +3589,20 @@ get_memory() {
mem_used="$((mem_total - mem_free))"
;;

"Interix")
mem_total="$(/dev/fs/C/Windows/System32/wbem/WMIC.exe computersystem get TotalPhysicalMemory)"
mem_total="${mem_total//[[:space:]]}"
mem_total="${mem_total/TotalPhysicalMemory}"
mem_total="$((mem_total / 1024 / 1024))"

mem_free="$(/dev/fs/C/Windows/System32/wbem/WMIC.exe os get FreePhysicalMemory)"
mem_free="${mem_free//[[:space:]]}"
mem_free="${mem_free/FreePhysicalMemory}"
mem_free="$((mem_free / 1024))"

mem_used="$((mem_total - mem_free))"
;;

esac

[[ "$memory_percent" == "on" ]] && ((mem_perc=mem_used * 100 / mem_total))
Expand Down Expand Up @@ -4961,6 +5033,15 @@ get_battery() {
[[ "$state" == *TRUE* ]] && battery_state="charging"
;;

"Interix")
battery="$(/dev/fs/C/Windows/System32/wbem/WMIC.exe 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="${state/Charging}"
[[ "$state" == *TRUE* ]] && battery_state="charging"
;;

"Haiku")
battery0full="$(awk -F '[^0-9]*' 'NR==2 {print $4}' /dev/power/acpi_battery/0)"
battery0now="$(awk -F '[^0-9]*' 'NR==5 {print $4}' /dev/power/acpi_battery/0)"
Expand Down Expand Up @@ -5021,7 +5102,7 @@ get_local_ip() {
fi
;;

"Windows")
"Windows" | "Interix")
local_ip="$(ipconfig | awk -F ': ' '/IPv4 Address/ {printf $2 ", "}')"
local_ip="${local_ip%\,*}"
;;
Expand Down Expand Up @@ -10195,6 +10276,29 @@ ${c1} |
EOF
;;

"Interix"*)
set_colors 1 7 4 0 3
read -rd '' ascii_data <<'EOF'
${c1} .${c3}.
${c1} 75${c3}G!
${c1} ^?PG${c3}&&J.
${c1} :!5GPP${c3}&&&B!
${c1} :YPPPPP${c3}&&&&&Y:
${c1} !5PPPPPP${c3}&&&&&&B!
${c1} :?PPPPPPPP${c3}&&&&&&&&Y~
${c1} !5PPPPPPPPP${c3}###&&&&&&B7
${c1} :?PPPP5555555${c3}B####&&&&&&5:
${c1} ~5PPPP555YJ${c5}7!~7?${c3}5B###&&&&&B?.
${c1} .:JPPPP5555Y${c5}?^....:^?${c3}G####&&&&&5:
${c1} 75PPP555555Y${c5}7:....:^!${c3}5#####&&&&&B7.
${c1} :JPPPP${c2}555555YY?${c5}~::::^~${c2}7YPGBB###${c3}&&&&&5^
${c1}75${c2}GGPPPPPP555555YJ?77??YYYYYY55PPGGB#${c3}&B?
${c2}~!!7JY5PGGBBBBBBBBGGGGGGGBGGGGGP5YJ?7~~~
.::^~7?JYPGBB#BGPYJ?7!7^:.
..:^...
EOF
;;

"januslinux"*|"janus"*|"Ataraxia Linux"*|"Ataraxia"*)
set_colors 4 5 6 2
read -rd '' ascii_data <<'EOF'
Expand Down

0 comments on commit 05bdef9

Please sign in to comment.