64 lines
2.1 KiB
Bash
Executable File
64 lines
2.1 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# --- Color Definitions ---
|
|
# Translating your hex codes to ANSI (closest approximations for 256-color terms)
|
|
FG_MAIN="\e[38;2;157;132;98m" # #9d8462
|
|
FG_TITLE="\e[38;2;255;145;0m" # #ff9100
|
|
BG_METER="\e[48;2;48;51;64m" # #303340
|
|
RESET="\e[0m"
|
|
BOLD="\e[1m"
|
|
|
|
# Ensure we clean up the cursor on exit
|
|
trap "tput cnorm; clear; exit" SIGINT SIGTERM
|
|
|
|
# Hide cursor
|
|
tput civis
|
|
|
|
while true; do
|
|
# 1. Gather Data
|
|
DATE=$(date "+%Y-%m-%d %H:%M:%S")
|
|
|
|
# CPU Usage (Calculated over 1 second for accuracy)
|
|
CPU_USAGE=$(top -bn1 | grep "Cpu(s)" | awk '{print $2 + $4}')
|
|
|
|
# Memory Usage
|
|
MEM_TOTAL=$(free -m | awk '/Mem:/ {print $2}')
|
|
MEM_USED=$(free -m | awk '/Mem:/ {print $3}')
|
|
MEM_PERC=$(( MEM_USED * 100 / MEM_TOTAL ))
|
|
|
|
# CPU Temp (Path may vary: check /sys/class/thermal/thermal_zone*)
|
|
CPU_TEMP=$(cat /sys/class/thermal/thermal_zone0/temp 2>/dev/null || echo 0)
|
|
CPU_TEMP=$(( CPU_TEMP / 1000 ))
|
|
|
|
# Battery
|
|
BAT_PERC=$(cat /sys/class/power_supply/BAT0/capacity 2>/dev/null || echo "N/A")
|
|
|
|
# Graphics Pipe (Radeontop)
|
|
# We use -d- to dump once and grep for the Graphics Pipe percentage
|
|
GPU_PIPE=$(sudo radeontop -d- -l1 2>/dev/null | grep -oP 'graphics pipe \K[0-9.]+(?=%)' || echo "0")
|
|
|
|
# 2. Render Screen
|
|
clear
|
|
echo -e "${FG_TITLE}${BOLD}--- MINI-BTOP ---${RESET}"
|
|
echo -e "${FG_MAIN}Time: ${DATE}${RESET}"
|
|
echo -e "${FG_MAIN}---------------------------------------${RESET}"
|
|
|
|
# CPU Row
|
|
echo -ne "${FG_MAIN}CPU: ${CPU_USAGE}% "
|
|
echo -e "${BG_METER}$(printf '%*s' $(( ${CPU_USAGE%.*} / 5 )) '' | tr ' ' ' ')${RESET}"
|
|
|
|
# Mem Row
|
|
echo -ne "${FG_MAIN}MEM: ${MEM_PERC}% "
|
|
echo -e "${BG_METER}$(printf '%*s' $(( MEM_PERC / 5 )) '' | tr ' ' ' ')${RESET}"
|
|
|
|
# Others
|
|
echo -e "${FG_MAIN}TEMP: ${CPU_TEMP}°C${RESET}"
|
|
echo -e "${FG_MAIN}BATTERY: ${BAT_PERC}%${RESET}"
|
|
echo -e "${FG_MAIN}GPU PIPE:${GPU_PIPE}%${RESET}"
|
|
|
|
echo -e "${FG_MAIN}---------------------------------------${RESET}"
|
|
echo -e "${FG_TITLE}Updating every 10s... (Ctrl+C to exit)${RESET}"
|
|
|
|
sleep 10
|
|
done
|