Skip to content

Commit 05bdef9

Browse files
[PR] dylanaraps/neofetch#2409 from makuhlmann - Added support for Interix (Windows Subsystem for UNIX)
Upstream PR: dylanaraps/neofetch#2409 Thanks to @makuhlmann Co-authored-by: makuhlmann <[email protected]>
2 parents 91ced42 + ec86933 commit 05bdef9

File tree

1 file changed

+106
-2
lines changed

1 file changed

+106
-2
lines changed

neofetch

Lines changed: 106 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1028,6 +1028,7 @@ get_os() {
10281028
AIX) os=AIX ;;
10291029
IRIX*) os=IRIX ;;
10301030
FreeMiNT) os=FreeMiNT ;;
1031+
Interix) os=Interix ;;
10311032

10321033
Linux|GNU*)
10331034
os=Linux
@@ -1465,6 +1466,10 @@ get_distro() {
14651466
FreeMiNT)
14661467
distro=FreeMiNT
14671468
;;
1469+
1470+
Interix)
1471+
distro="Interix ${kernel_version}"
1472+
;;
14681473
esac
14691474

14701475
distro=${distro//Enterprise Server}
@@ -1772,6 +1777,12 @@ get_model() {
17721777
model=$(sysctl -n hw.model)
17731778
model=${model/ (_MCH *)}
17741779
;;
1780+
1781+
Interix)
1782+
model="$(/dev/fs/C/Windows/System32/wbem/WMIC.exe computersystem get manufacturer,model)"
1783+
model="${model/Manufacturer}"
1784+
model="${model/Model}"
1785+
;;
17751786
esac
17761787

17771788
# Remove dummy OEM info.
@@ -1847,6 +1858,13 @@ get_kernel() {
18471858
return
18481859
}
18491860

1861+
# In Interix the Kernel version is commonly comprised of the host OS build number,
1862+
# OS architecture and Interix build number
1863+
[[ $os == Interix ]] && {
1864+
kernel="$(uname -r) $(uname -m) $(uname -v)"
1865+
return
1866+
}
1867+
18501868
case $kernel_shorthand in
18511869
on) kernel=$kernel_version ;;
18521870
off) kernel="$kernel_name $kernel_version" ;;
@@ -1903,6 +1921,19 @@ get_uptime() {
19031921
s=$((${d:-0}*86400 + ${h:-0}*3600 + ${t%%:*}*60 + ${t#*:}))
19041922
;;
19051923

1924+
Interix)
1925+
t="$(LC_ALL=POSIX ps -o etime= -p 0)"
1926+
t="${t%%.*}"
1927+
1928+
[[ $t == *-* ]] && { d=${t%%-*}; t=${t#*-}; }
1929+
[[ $t == *:*:* ]] && { h=${t%%:*}; t=${t#*:}; }
1930+
1931+
h="${h#0}"
1932+
t="${t#0}"
1933+
1934+
s="$((${d:-0}*86400 + ${h:-0}*3600 + ${t%%:*}*60 + ${t#*:}))"
1935+
;;
1936+
19061937
Haiku)
19071938
s=$(($(system_time) / 1000000))
19081939
;;
@@ -2001,7 +2032,7 @@ get_packages() {
20012032

20022033
# OS-specific package managers.
20032034
case $os in
2004-
Linux|BSD|"iPhone OS"|Solaris|illumos)
2035+
Linux|BSD|"iPhone OS"|Solaris|illumos|Interix)
20052036
# Package Manager Programs.
20062037
has kiss && tot kiss l
20072038
has cpt-list && tot cpt-list
@@ -3142,6 +3173,17 @@ END
31423173
cpu="$(awk -F':' '/CPU:/ {printf $2}' /kern/cpuinfo)"
31433174
speed="$(awk -F '[:.M]' '/Clocking:/ {printf $2}' /kern/cpuinfo)"
31443175
;;
3176+
3177+
"Interix")
3178+
cpu="$(/dev/fs/C/Windows/System32/wbem/WMIC.exe cpu get Name)"
3179+
cpu="${cpu/Name}"
3180+
3181+
speed="$(/dev/fs/C/Windows/System32/wbem/WMIC.exe cpu get CurrentClockSpeed)"
3182+
speed="${speed/CurrentClockSpeed}"
3183+
3184+
cores="$(/dev/fs/C/Windows/System32/wbem/WMIC.exe cpu get NumberOfCores)"
3185+
cores="${cores/NumberOfCores}"
3186+
;;
31453187
esac
31463188

31473189
# Remove un-needed patterns from cpu output.
@@ -3387,6 +3429,22 @@ get_gpu() {
33873429
done
33883430
;;
33893431

3432+
"Interix")
3433+
/dev/fs/C/Windows/System32/wbem/WMIC.exe path Win32_VideoController get caption | while read -r line; do
3434+
line=$(trim "$line")
3435+
3436+
case $line in
3437+
*Caption*|'')
3438+
continue
3439+
;;
3440+
3441+
*)
3442+
prin "${subtitle:+${subtitle}${gpu_name}}" "$line"
3443+
;;
3444+
esac
3445+
done
3446+
;;
3447+
33903448
"Haiku")
33913449
gpu="$(listdev | grep -A2 -F 'device Display controller' |\
33923450
awk -F':' '/device beef/ {print $2}')"
@@ -3531,6 +3589,20 @@ get_memory() {
35313589
mem_used="$((mem_total - mem_free))"
35323590
;;
35333591

3592+
"Interix")
3593+
mem_total="$(/dev/fs/C/Windows/System32/wbem/WMIC.exe computersystem get TotalPhysicalMemory)"
3594+
mem_total="${mem_total//[[:space:]]}"
3595+
mem_total="${mem_total/TotalPhysicalMemory}"
3596+
mem_total="$((mem_total / 1024 / 1024))"
3597+
3598+
mem_free="$(/dev/fs/C/Windows/System32/wbem/WMIC.exe os get FreePhysicalMemory)"
3599+
mem_free="${mem_free//[[:space:]]}"
3600+
mem_free="${mem_free/FreePhysicalMemory}"
3601+
mem_free="$((mem_free / 1024))"
3602+
3603+
mem_used="$((mem_total - mem_free))"
3604+
;;
3605+
35343606
esac
35353607

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

5036+
"Interix")
5037+
battery="$(/dev/fs/C/Windows/System32/wbem/WMIC.exe Path Win32_Battery get EstimatedChargeRemaining)"
5038+
battery="${battery/EstimatedChargeRemaining}"
5039+
battery="$(trim "$battery")%"
5040+
state="$(/dev/fs/C/Windows/System32/wbem/WMIC.exe /NameSpace:'\\root\WMI' Path BatteryStatus get Charging)"
5041+
state="${state/Charging}"
5042+
[[ "$state" == *TRUE* ]] && battery_state="charging"
5043+
;;
5044+
49645045
"Haiku")
49655046
battery0full="$(awk -F '[^0-9]*' 'NR==2 {print $4}' /dev/power/acpi_battery/0)"
49665047
battery0now="$(awk -F '[^0-9]*' 'NR==5 {print $4}' /dev/power/acpi_battery/0)"
@@ -5021,7 +5102,7 @@ get_local_ip() {
50215102
fi
50225103
;;
50235104

5024-
"Windows")
5105+
"Windows" | "Interix")
50255106
local_ip="$(ipconfig | awk -F ': ' '/IPv4 Address/ {printf $2 ", "}')"
50265107
local_ip="${local_ip%\,*}"
50275108
;;
@@ -10195,6 +10276,29 @@ ${c1} |
1019510276
EOF
1019610277
;;
1019710278

10279+
"Interix"*)
10280+
set_colors 1 7 4 0 3
10281+
read -rd '' ascii_data <<'EOF'
10282+
${c1} .${c3}.
10283+
${c1} 75${c3}G!
10284+
${c1} ^?PG${c3}&&J.
10285+
${c1} :!5GPP${c3}&&&B!
10286+
${c1} :YPPPPP${c3}&&&&&Y:
10287+
${c1} !5PPPPPP${c3}&&&&&&B!
10288+
${c1} :?PPPPPPPP${c3}&&&&&&&&Y~
10289+
${c1} !5PPPPPPPPP${c3}###&&&&&&B7
10290+
${c1} :?PPPP5555555${c3}B####&&&&&&5:
10291+
${c1} ~5PPPP555YJ${c5}7!~7?${c3}5B###&&&&&B?.
10292+
${c1} .:JPPPP5555Y${c5}?^....:^?${c3}G####&&&&&5:
10293+
${c1} 75PPP555555Y${c5}7:....:^!${c3}5#####&&&&&B7.
10294+
${c1} :JPPPP${c2}555555YY?${c5}~::::^~${c2}7YPGBB###${c3}&&&&&5^
10295+
${c1}75${c2}GGPPPPPP555555YJ?77??YYYYYY55PPGGB#${c3}&B?
10296+
${c2}~!!7JY5PGGBBBBBBBBGGGGGGGBGGGGGP5YJ?7~~~
10297+
.::^~7?JYPGBB#BGPYJ?7!7^:.
10298+
..:^...
10299+
EOF
10300+
;;
10301+
1019810302
"januslinux"*|"janus"*|"Ataraxia Linux"*|"Ataraxia"*)
1019910303
set_colors 4 5 6 2
1020010304
read -rd '' ascii_data <<'EOF'

0 commit comments

Comments
 (0)