@@ -176,8 +176,9 @@ uptime_shorthand="on"
176
176
# off: '1801MiB / 7881MiB'
177
177
memory_percent="off"
178
178
179
- # Change memory output unit.
179
+ # Change memory output unit & precision .
180
180
#
181
+ # unit
181
182
# Default: 'mib'
182
183
# Values: 'kib', 'mib', 'gib'
183
184
# Flag: --memory_unit
@@ -186,8 +187,13 @@ memory_percent="off"
186
187
# kib '1020928KiB / 7117824KiB'
187
188
# mib '1042MiB / 6951MiB'
188
189
# gib: ' 0.98GiB / 6.79GiB'
190
+ #
191
+ # precision
192
+ # Default: '2'
193
+ # Values: integer ≥ 0
194
+ # Flag: --memory_precision
189
195
memory_unit="gib"
190
-
196
+ mem_precision=2
191
197
192
198
# Packages
193
199
@@ -3095,30 +3101,13 @@ get_memory() {
3095
3101
;;
3096
3102
3097
3103
" Mac OS X" | " macOS" | " iPhone OS" )
3098
- if [[ $osx_version == 10.[4-5]* ]]; then
3099
- mem_total=" $( system_profiler SPHardwareDataType | grep Memory:) "
3100
- mem_total=" ${mem_total/ Memory\: / } "
3101
- mem_total=" ${mem_total/ MB/ } "
3102
-
3103
- mem_used=" $( vm_stat | grep Pages\ active:) "
3104
- mem_used=" ${mem_used/ Pages active\: / } "
3105
- mem_used=" ${mem_used/ \. / } "
3106
-
3107
- pages_inactive=$( vm_stat | grep " Pages inactive" )
3108
- pages_inactive=${pages_inactive/ Pages inactive\: / }
3109
- pages_inactive=${pages_inactive/ \. / }
3110
-
3111
- mem_used=$(( mem_used + pages_inactive))
3112
- mem_used=$(( mem_used * 4096 / 1048576 ))
3113
- else
3114
- hw_pagesize=" $( sysctl -n hw.pagesize) "
3115
- mem_total=" $(( $(sysctl - n hw.memsize) / 1024 / 1024 )) "
3116
- pages_app=" $(( $(sysctl - n vm.page_pageable_internal_count) - $(sysctl - n vm.page_purgeable_count)) )"
3117
- pages_wired=" $( vm_stat | awk ' / wired/ { print $4 }' ) "
3118
- pages_compressed=" $( vm_stat | awk ' / occupied/ { printf $5 }' ) "
3119
- pages_compressed=" ${pages_compressed:- 0} "
3120
- mem_used=" $(( (pages_app + ${pages_wired// .} + ${pages_compressed// .} ) * hw_pagesize / 1024 / 1024 )) "
3121
- fi
3104
+ hw_pagesize=" $( sysctl -n hw.pagesize) "
3105
+ mem_total=" $(( $(sysctl - n hw.memsize) / 1024 / 1024 )) "
3106
+ pages_app=" $(( $(sysctl - n vm.page_pageable_internal_count) - $(sysctl - n vm.page_purgeable_count)) )"
3107
+ pages_wired=" $( vm_stat | awk ' / wired/ { print $4 }' ) "
3108
+ pages_compressed=" $( vm_stat | awk ' / occupied/ { printf $5 }' ) "
3109
+ pages_compressed=" ${pages_compressed:- 0} "
3110
+ mem_used=" $(( (pages_app + ${pages_wired// .} + ${pages_compressed// .} ) * hw_pagesize / 1024 / 1024 )) "
3122
3111
;;
3123
3112
3124
3113
" BSD" | " MINIX" | " ravynOS" )
@@ -3209,6 +3198,11 @@ get_memory() {
3209
3198
3210
3199
[[ " $memory_percent " == " on" ]] && (( mem_perc= mem_used * 100 / mem_total))
3211
3200
3201
+ memory_unit_divider=1
3202
+ memory_unit_multiplier=1
3203
+ mu_mb=" $mem_used "
3204
+ mt_mb=" $mem_total "
3205
+
3212
3206
case $memory_unit in
3213
3207
gib)
3214
3208
mem_used=$( awk ' {printf "%.1f", $1 / $2}' <<< " $mem_used 1024" )
@@ -3223,13 +3217,25 @@ get_memory() {
3223
3217
;;
3224
3218
esac
3225
3219
3220
+ if test " $memory_unit_divider " -ge 1; then
3221
+ printf -v mem_used " %'.*f" \
3222
+ " ${mem_precision} " \
3223
+ $(( mem_used / memory_unit_divider)) .$(( mem_used % memory_unit_divider))
3224
+ printf -v mem_total " %'.*f" \
3225
+ " ${mem_precision} " \
3226
+ $(( mem_total / memory_unit_divider)) .$(( mem_total % memory_unit_divider))
3227
+ elif test " $memory_unit_multiplier " -ge 1; then
3228
+ mem_used=$(( mem_used * memory_unit_multiplier))
3229
+ mem_total=$(( mem_total * memory_unit_multiplier))
3230
+ fi
3231
+
3226
3232
memory=" ${mem_used} ${mem_label:- MiB} / ${mem_total} ${mem_label:- MiB} ${mem_perc: +(${mem_perc} % )} "
3227
3233
3228
3234
# Bars.
3229
3235
case $memory_display in
3230
- " bar" ) memory=" $( bar " ${mem_used } " " ${mem_total } " ) " ;;
3231
- " infobar" ) memory=" ${memory} $( bar " ${mem_used } " " ${mem_total } " ) " ;;
3232
- " barinfo" ) memory=" $( bar " ${mem_used } " " ${mem_total } " ) ${info_color} ${memory} " ;;
3236
+ " bar" ) memory=" $( bar " ${mu_mb } " " ${mt_mb } " ) " ;;
3237
+ " infobar" ) memory=" ${memory} $( bar " ${mu_mb } " " ${mt_mb } " ) " ;;
3238
+ " barinfo" ) memory=" $( bar " ${mu_mb } " " ${mt_mb } " ) ${info_color} ${memory} " ;;
3233
3239
esac
3234
3240
}
3235
3241
@@ -5698,7 +5704,7 @@ INFO:
5698
5704
5699
5705
This can be used in bars and scripts like so:
5700
5706
5701
- memory=\"\$ (neofetch memory)\" ; memory=\"\$ {memory##*: }\"
5707
+ memory=\"\$ (unifetch memory)\" ; memory=\"\$ {memory##*: }\"
5702
5708
5703
5709
For multiple outputs at once (each line of info in an array):
5704
5710
@@ -5788,7 +5794,9 @@ INFO:
5788
5794
--song_format format Print the song data in a specific format (see config file).
5789
5795
--song_shorthand on/off Print the Artist/Album/Title on separate lines.
5790
5796
--memory_percent on/off Display memory percentage.
5791
- --memory_unit kib/mib/gib Memory output unit.
5797
+ --memory_unit kib/mib/gib/tib
5798
+ Memory output unit.
5799
+ --memory_precision integer Change memory output precision. (≥0, default=2)
5792
5800
--music_player player-name Manually specify a player to use.
5793
5801
Available values are listed in the config file
5794
5802
@@ -5856,56 +5864,42 @@ ASCII:
5856
5864
--ascii_colors x x x x x x Colors to print the ascii art
5857
5865
--ascii_distro distro Which Distro's ascii art to print
5858
5866
5859
- NOTE: AIX, AlmaLinux, Alpine, Alter, Amazon, AmogOS, Anarchy,
5860
- Android, Antergos, antiX, AOSC OS, AOSC OS/Retro, Aperio GNU/Linux,
5861
- Apricity, Arch, ArchBox, Archcraft, ARCHlabs, ArchMerge, ArchStrike,
5862
- ArcoLinux, Artix, Arya, Asahi, AsteroidOS, astOS, Bedrock, BigLinux,
5863
- Bitrig, BlackArch, blackPanther, BLAG, BlankOn, BlueLight, Bodhi,
5864
- bonsai, BSD, BunsenLabs, Cachy OS, Calculate, CalinixOS, Carbs, CBL-
5865
- Mariner, CelOS, Center, CentOS, Chakra, ChaletOS, Chapeau,
5866
- ChonkySealOS, Chrom, Cleanjaro, Clear Linux OS, ClearOS, Clover,
5867
- Cobalt Linux, Condres, Container Linux by CoreOS, CRUX, Crystal Linux,
5868
- Cucumber, CutefishOS, CyberOS, dahlia, DarkOs, Darwin, Debian, Deepin, DesaOS,
5869
- Devuan, DracOS, DragonFly, Drauger, Droidian, Elementary, Elive, EncryptOS,
5870
- EndeavourOS, Endless, Enso, EuroLinux, Exherbo, Exodia Predator OS,
5871
- Fedora, Feren, Finnix, FreeBSD, FreeMiNT, Frugalware, Funtoo,
5872
- GalliumOS, Garuda, Gentoo, GhostBSD, glaucus, gNewSense, GNOME, GNU,
5873
- GoboLinux, GrapheneOS, Grombyang, Guix, Haiku, HarDClanZ, Hash,
5874
- Huayra, HydroOS, Hyperbola, iglunix, instantOS, IRIX, Itc,
5875
- januslinux, Kaisen, Kali, Kamuriki, KaOS, KDE, Kibojoe, Kogaion, Korora,
5876
- KrassOS, KSLinux, Kubuntu, LangitKetujuh, LaxerOS, LEDE, LibreELEC,
5877
- Linspire, Linux, Linux Lite, Linux Mint, Linux Mint Old, Live Raizo,
5878
- LMDE, Lubuntu, Lunar, mac, Mageia, MagpieOS, Mandriva, Manjaro,
5879
- MassOS, MatuusOS, Maui, Mer, Minix, MIRACLE LINUX, MX, Namib,
5880
- Neptune, NetBSD, Netrunner, Nitrux, NixOS, NNLinux, NomadBSD, Nurunner,
5881
- NuTyX, Obarun, OBRevenge, Open Source Media Center, OpenBSD,
5882
- openEuler, OpenIndiana, openmamba, OpenMandriva, OpenStage,
5883
- openSUSE, openSUSE Leap, openSUSE Tumbleweed, OpenWrt, OPNsense,
5884
- Oracle, orchid, OS Elbrus, PacBSD, Parabola, parch, Pardus, Parrot,
5885
- Parsix, PCBSD, PCLinuxOS, pearOS, Pengwin, Pentoo, Peppermint, Pisi,
5886
- PNM Linux, Pop!_OS, Porteus, PostMarketOS, Profelis SambaBOX,
5887
- Proxmox, PuffOS, Puppy, PureOS, Q4OS, Qubes, Qubyt, Quibian, Radix,
5888
- Raspbian, ravynOS, Reborn OS, Red Star, Redcore, Redhat, Refracted
5889
- Devuan, Regata, Regolith, rocky, Rosa, Sabayon, sabotage, Sailfish,
5890
- SalentOS, Scientific, semc, Septor, Serene, SharkLinux, ShastraOS,
5891
- Siduction, SkiffOS, Slackware, SliTaz, SmartOS, Soda, Solus, Source
5892
- Mage, Sparky, Star, SteamOS, Sulin, SunOS, SwagArch, t2, Tails,
5893
- TeArch, TorizonCore, Trisquel, Twister, Ubuntu, Ubuntu Budgie,
5894
- Ubuntu Cinnamon, Ubuntu Kylin, Ubuntu MATE, Ubuntu Studio, Ubuntu
5895
- Sway, Ubuntu Touch, Ubuntu-GNOME, ubuntu_old02, Ultramarine Linux,
5896
- Univalent, Univention, Uos, uwuntu, Venom, VNux, Void, VzLinux, wii-
5897
- linux-ngx, Windows, Windows 10, Windows 11, XFerience, Xubuntu,
5867
+ NOTE: AIX, AlmaLinux, Alpine, Alter, Amazon, AmogOS, Anarchy, Android, Antergos, antiX, AOSC OS,
5868
+ AOSC OS/Retro, Aperio GNU/Linux, Apricity, Arch, ArchBox, Archcraft, ARCHlabs, ArchMerge,
5869
+ ArchStrike, ArcoLinux, Artix, Arya, Asahi, AsteroidOS, astOS, Bedrock, BigLinux, Bitrig,
5870
+ BlackArch, blackPanther, BLAG, BlankOn, BlueLight, Bodhi, bonsai, BSD, BunsenLabs, Cachy OS,
5871
+ Calculate, CalinixOS, Carbs, CBL-Mariner, CelOS, Center, CentOS, Chakra, ChaletOS, Chapeau,
5872
+ ChonkySealOS, Chrom, Cleanjaro, Clear Linux OS, ClearOS, Clover, Cobalt Linux, Condres,
5873
+ Container Linux by CoreOS, CRUX, Crystal Linux, Cucumber, CutefishOS, CyberOS, dahlia, DarkOs, Darwin,
5874
+ Debian, Deepin, DesaOS, Devuan, DracOS, DragonFly, Drauger, Elementary, Elive, EncryptOS, EndeavourOS,
5875
+ Endless, Enso, EuroLinux, Exherbo, Exodia Predator OS, Fedora, Feren, Finnix, FreeBSD, FreeMiNT,
5876
+ Frugalware, Funtoo, GalliumOS, Garuda, Gentoo, GhostBSD, glaucus, gNewSense, GNOME, GNU,
5877
+ GoboLinux, GrapheneOS, Grombyang, Guix, Haiku, HarDClanZ, Hash, Huayra, HydroOS, Hyperbola,
5878
+ iglunix, instantOS, IRIX, Itc, januslinux, Kaisen, Kali, Kamuriki, KaOS, KDE, Kibojoe, Kogaion, Korora,
5879
+ KrassOS, KSLinux, Kubuntu, LangitKetujuh, LaxerOS, LEDE, LibreELEC, Linspire, Linux, Linux Lite,
5880
+ Linux Mint, Linux Mint Old, Live Raizo, LMDE, Lubuntu, Lunar, mac, Mageia, MagpieOS, Mandriva,
5881
+ Manjaro, MassOS, MatuusOS, Maui, Mer, Minix, MIRACLE LINUX, MX, Namib, Neptune, NetBSD, Netrunner,
5882
+ Nitrux, NixOS, NNLinux, NomadBSD, Nurunner, NuTyX, Obarun, OBRevenge, Open Source Media Center,
5883
+ OpenBSD, openEuler, OpenIndiana, openmamba, OpenMandriva, OpenStage, openSUSE, openSUSE Leap, openSUSE
5884
+ Tumbleweed, OpenWrt, OPNsense, Oracle, orchid, OS Elbrus, PacBSD, Parabola, parch, Pardus, Parrot,
5885
+ Parsix, PCBSD, PCLinuxOS, pearOS, Pengwin, Pentoo, Peppermint, Pisi, PNM Linux, Pop!_OS, Porteus,
5886
+ PostMarketOS, Profelis SambaBOX, Proxmox, PuffOS, Puppy, PureOS, Q4OS, Qubes, Qubyt, Quibian,
5887
+ Radix, Raspbian, ravynOS, Reborn OS, Red Star, Redcore, Redhat, Refracted Devuan, Regata,
5888
+ Regolith, rocky, Rosa, Sabayon, sabotage, Sailfish, SalentOS, Scientific, semc, Septor, Serene,
5889
+ SharkLinux, ShastraOS, Siduction, SkiffOS, Slackware, SliTaz, SmartOS, Soda, Solus, Source Mage,
5890
+ Sparky, Star, SteamOS, Sulin, SunOS, SwagArch, t2, Tails, TeArch, TorizonCore, Trisquel, Twister,
5891
+ Ubuntu, Ubuntu Budgie, Ubuntu Cinnamon, Ubuntu Kylin, Ubuntu MATE, Ubuntu Studio, Ubuntu Sway,
5892
+ Ubuntu Touch, Ubuntu-GNOME, ubuntu_old02, Ultramarine Linux, Univalent, Univention, Uos, uwuntu,
5893
+ Vanilla, Venom, VNux, Void, VzLinux, wii-linux-ngx, Windows, Windows 10, Windows 11, XFerience, Xubuntu,
5898
5894
yiffOS, Zorin have ascii logos.
5899
5895
5900
- NOTE: arch, dragonfly, Fedora, LangitKetujuh, nixos, redhat, Ubuntu
5901
- have 'old' logo variants, use {distro}_old to use them.
5896
+ NOTE: arch, dragonfly, Fedora, LangitKetujuh, nixos, redhat, Ubuntu have 'old' logo variants, use
5897
+ {distro}_old to use them.
5902
5898
5903
- NOTE: alpine, android, aoscosretro, arch, arcolinux, artix,
5904
- CalinixOS, centos, cleanjaro, crux, debian, dragonfly, elementary,
5905
- fedora, freebsd, garuda, gentoo, guix, haiku, hyperbola, linuxlite,
5906
- linuxmint, mac, mageia, manjaro, mx, netbsd, nixos, openbsd,
5907
- opensuse, orchid, parabola, popos, postmarketos, pureos, Raspbian,
5908
- rocky, slackware, sunos, ubuntu, void have 'small' logo variants,
5899
+ NOTE: alpine, android, aoscosretro, arch, arcolinux, artix, CalinixOS, centos, cleanjaro, crux,
5900
+ debian, dragonfly, elementary, fedora, freebsd, garuda, gentoo, guix, haiku, hyperbola, linuxlite,
5901
+ linuxmint, mac, mageia, manjaro, mx, netbsd, nixos, openbsd, opensuse, orchid, parabola, popos,
5902
+ postmarketos, pureos, Raspbian, rocky, slackware, sunos, ubuntu, void have 'small' logo variants,
5909
5903
use {distro}_small to use them.
5910
5904
5911
5905
--ascii_bold on/off Whether or not to bold the ascii logo.
@@ -6004,6 +5998,7 @@ get_args() {
6004
5998
" --music_player" ) music_player=" $2 " ;;
6005
5999
" --memory_percent" ) memory_percent=" $2 " ;;
6006
6000
" --memory_unit" ) memory_unit=" $2 " ;;
6001
+ " --memory_precision" ) mem_precision=" $2 " ;;
6007
6002
" --cpu_temp" )
6008
6003
cpu_temp=" $2 "
6009
6004
[[ " $cpu_temp " == " on" ]] && cpu_temp=" C"
0 commit comments