This commit is contained in:
DarthMooMancer
2025-09-20 18:52:10 -04:00
parent 1287cbb0a1
commit b6ca417cc5
+1 -23
View File
@@ -37,16 +37,6 @@ cpu_usage() {
((dt>0)) && printf "%.1f%%" "$(bc -l <<< "100*($dt-$di)/$dt")" || echo "0.0%"
}
# Time since last system update
since_update() {
days_since_update=0
if [[ -f ~/.last_world_update ]]; then
last_epoch=$(stat -c %Y ~/.last_world_update)
days_since_update=$(( ( $(date +%s) - last_epoch ) / 86400 ))
fi
echo $days_since_update
}
cpu_use=$(cpu_usage)
# Memory
@@ -58,16 +48,12 @@ sys_age=$(( ( $(date +%s) - $(stat -c %W / 2>/dev/null || echo 0) ) / 86400 ))
# Packages
pkg_count=$(find /var/db/pkg -mindepth 2 -maxdepth 2 -type d 2>/dev/null | wc -l)
# Days since last update
days_update=$(since_update)
# --- Define lines (easy to add new ones) ---
lines=(
"${cyan}CPU${reset}: ${physical_cores}c/${logical_threads}t/${cpu_use}"
"${green}Memory${reset}: ${mem_usage}"
"${magenta}Age${reset}: ${sys_age} days"
"${red}Age${reset}: ${sys_age} days"
"${blue}Pkgs${reset}: ${pkg_count}"
"${red}Update${reset}: ${days_update}"
)
# --- Compute max width ---
@@ -82,14 +68,6 @@ for l in "${lines[@]}"; do
hline=$(printf "%${maxlen}s" "" | sed "s/ /$h/g")
printf '%s%s%s\n' "$tl" "$hline" "$tr"
# # --- Content ---
# for l in "${lines[@]}"; do
# stripped=$(strip_colors "$l")
# pad=$((maxlen - ${#stripped}))
# printf '%s%s%*s%s\n' "$v" "$l" "$pad" "" "$v"
# done
# --- Content with right-aligned values ---
for l in "${lines[@]}"; do
# split into label and value at first colon
label="${l%%:*}:" # label including colon