This commit is contained in:
Dylan Araps 2021-06-11 07:45:27 +00:00
commit c55cfc0c06
1 changed files with 63 additions and 12 deletions

View File

@ -158,7 +158,7 @@ uptime_shorthand="on"
# Memory # Memory
# Show memory pecentage in output. # Show memory percentage in output.
# #
# Default: 'off' # Default: 'off'
# Values: 'on', 'off' # Values: 'on', 'off'
@ -1644,7 +1644,7 @@ get_packages() {
nix-store -qR /etc/profiles/per-user/"$USER" nix-store -qR /etc/profiles/per-user/"$USER"
} }
manager=nix-system && tot nix-store -qR /run/current-system/sw manager=nix-system && tot nix-store -qR /run/current-system/sw
manager=nix-user && tot nix-store -qR nix-user-pkgs manager=nix-user && tot nix-user-pkgs
} }
;; ;;
@ -2213,17 +2213,50 @@ get_cpu() {
speed="$((speed / 1000))" speed="$((speed / 1000))"
else else
case $kernel_machine in
"sparc"*)
# SPARC systems use a different file to expose clock speed information.
speed_file="/sys/devices/system/cpu/cpu0/clock_tick"
speed="$(($(< "$speed_file") / 1000000))"
;;
*)
speed="$(awk -F ': |\\.' '/cpu MHz|^clock/ {printf $2; exit}' "$cpu_file")" speed="$(awk -F ': |\\.' '/cpu MHz|^clock/ {printf $2; exit}' "$cpu_file")"
speed="${speed/MHz}" speed="${speed/MHz}"
;;
esac
fi fi
# Get CPU temp. # Get CPU temp.
[[ -f "$temp_dir" ]] && deg="$(($(< "$temp_dir") * 100 / 10000))" [[ -f "$temp_dir" ]] && deg="$(($(< "$temp_dir") * 100 / 10000))"
# Get CPU cores. # Get CPU cores.
case $kernel_machine in
"sparc"*)
case $cpu_cores in case $cpu_cores in
"logical" | "on") cores="$(grep -c "^processor" "$cpu_file")" ;; # SPARC systems doesn't expose detailed topology information in
"physical") cores="$(awk '/^core id/&&!a[$0]++{++i} END {print i}' "$cpu_file")" ;; # /proc/cpuinfo so I have to use lscpu here.
"logical" | "on")
cores="$(lscpu | awk -F ': *' '/^CPU\(s\)/ {print $2}')"
;;
"physical")
cores="$(lscpu | awk -F ': *' '/^Core\(s\) per socket/ {print $2}')"
sockets="$(lscpu | awk -F ': *' '/^Socket\(s\)/ {print $2}')"
cores="$((sockets * cores))"
;;
esac
;;
*)
case $cpu_cores in
"logical" | "on")
cores="$(grep -c "^processor" "$cpu_file")"
;;
"physical")
cores="$(awk '/^core id/&&!a[$0]++{++i} END {print i}' "$cpu_file")"
;;
esac
;;
esac esac
;; ;;
@ -2286,7 +2319,17 @@ get_cpu() {
[[ -z "$speed" ]] && speed="$(sysctl -n hw.clockrate)" [[ -z "$speed" ]] && speed="$(sysctl -n hw.clockrate)"
# Get CPU cores. # Get CPU cores.
case $kernel_name in
"OpenBSD"*)
[[ "$(sysctl -n hw.smt)" == "1" ]] && smt="on" || smt="off"
ncpufound="$(sysctl -n hw.ncpufound)"
ncpuonline="$(sysctl -n hw.ncpuonline)"
cores="${ncpuonline}/${ncpufound},\\xc2\\xa0SMT\\xc2\\xa0${smt}"
;;
*)
cores="$(sysctl -n hw.ncpu)" cores="$(sysctl -n hw.ncpu)"
;;
esac
# Get CPU temp. # Get CPU temp.
case $kernel_name in case $kernel_name in
@ -2439,9 +2482,17 @@ get_gpu() {
case $os in case $os in
"Linux") "Linux")
# Read GPUs into array. # Read GPUs into array.
gpu_cmd="$(lspci -mm | awk -F '\"|\" \"|\\(' \ gpu_cmd="$(lspci -mm |
'/"Display|"3D|"VGA/ {a[$0] = $1 " " $3 " " $4} awk -F '\"|\" \"|\\(' \
END {for(i in a) {if(!seen[a[i]]++) print a[i]}}')" '/"Display|"3D|"VGA/ {
a[$0] = $1 " " $3 " " ($7 ~ /^$|^Device [[:xdigit:]]+$/ ? $4 : $7)
}
END { for (i in a) {
if (!seen[a[i]]++) {
sub("^[^ ]+ ", "", a[i]);
print a[i]
}
}}')"
IFS=$'\n' read -d "" -ra gpus <<< "$gpu_cmd" IFS=$'\n' read -d "" -ra gpus <<< "$gpu_cmd"
# Remove duplicate Intel Graphics outputs. # Remove duplicate Intel Graphics outputs.
@ -9314,7 +9365,7 @@ EOF
"PCLinuxOS"*) "PCLinuxOS"*)
set_colors 4 7 1 set_colors 4 7 1
read -rd '' ascii_data <<'EOF' read -rd '' ascii_data <<'EOF'
${c1}mhhhyyyyhhhdN ${c1} mhhhyyyyhhhdN
dyssyhhhhhhhhhhhssyhN dyssyhhhhhhhhhhhssyhN
Nysyhhyo/:-.....-/oyhhhssd Nysyhhyo/:-.....-/oyhhhssd
Nsshhy+. `/shhysm Nsshhy+. `/shhysm