#!/bin/bash # ██ # ░██ # ██████ ██████████ ██ ██ ██ ██ # ░░░██░ ░░██░░██░░██░██ ░██░░██ ██ # ░██ ░██ ░██ ░██░██ ░██ ░░███ # ░██ ░██ ░██ ░██░██ ░██ ██░██ # ░░██ ███ ░██ ░██░░██████ ██ ░░██ # ░░ ░░░ ░░ ░░ ░░░░░░ ░░ ░░ # ██ ██ # ░██ ░██ # ██████ ██████ ██████ ██████ ██ ██ ██████ # ██░░░░ ░░░██░ ░░░░░░██ ░░░██░ ░██ ░██ ██░░░░ #░░█████ ░██ ███████ ░██ ░██ ░██░░█████ # ░░░░░██ ░██ ██░░░░██ ░██ ░██ ░██ ░░░░░██ # ██████ ░░██ ░░████████ ░░██ ░░██████ ██████ #░░░░░░ ░░ ░░░░░░░░ ░░ ░░░░░░ ░░░░░░ # # ▓▓▓▓▓▓▓▓▓▓ # ░▓ author ▓ xero # ░▓ code ▓ https://code.x-e.ro/dotfiles # ░▓ mirror ▓ https://git.io/.files # ░▓▓▓▓▓▓▓▓▓▓ # ░░░░░░░░░░ FULL=━ EMPTY=┄ C0="#000000" C1="#222222" C2="#8FBCBB" C3="#B3291C" C4="#685742" C5="#d7c483" C6="#C9A554" C7="#78824b" C8="#B36D43" draw() { perc=$1 size=$2 inc=$((perc * size / 100)) out= for v in $(seq 0 $((size - 1))); do test "$v" -le "$inc" && out="${out}#[fg=$C1]${FULL}" || out="${out}#[fg=$C6]${EMPTY}" done echo "$out" } temp() { builtin type -P "sensors" &>/dev/null || exit t=$(sensors | awk '/Core\ 0/ {gsub(/\+/,"",$3); gsub(/\..+/,"",$3) ; print $3}') tc=$C0 if [ $((t <= 50)) ]; then tc=$C2 elif [ $((t >= 75)) ]; then tc=$C3 fi echo " #[fg=$tc]$t°c" } bat() { BATPATH=/sys/class/power_supply/BAT0 STATUS=$BATPATH/status BAT_FULL=$BATPATH/charge_full BAT_NOW=$BATPATH/charge_now bf=$(cat $BAT_FULL) bn=$(cat $BAT_NOW) bp=$((100 * bn / bf)) stat=$(cat $STATUS) case $stat in Full) st="=" ;; Discharging) st="-" ;; Charging) st="+" ;; esac test "$bp" -lt 10 && bc=$C3 || bc=$C1 echo "$st#[fg=$bc]$bp""%" } cpu() { CPU_USE=$(grep 'cpu ' /proc/stat | awk '{usage=($2+$4)*100/($2+$4+$5)} END {print usage}') printf "%.0f" "$CPU_USE" } ram() { free | awk '/Mem:/ {print int($3/$2 * 100.0)}' } disk() { df -h | grep '/$' | tr -s ' ' | cut -d ' ' -f5 | sed 's/%//' } vpn() { pgrep 'vpn/|openvpn/|openconnect' >/dev/null 2>&1 && echo "#[bg=$C8]#[fg=$C7]▓▒░#[fg=0]" || echo "#[bg=$C8]#[fg=$C7]▓▒░#[fg=0]" } clock() { mtime=$(date +'%H:%M') myear=$(date +'%Y-%m-') mday=$(date +'%d') echo "#[fg=$C5]#[bg=$C4] $mtime #[fg=$C6]$myear#[fg=$C5]$mday #[bg=0]#[fg=$C4]▒░" } front() { echo "#[bg=$C7]#[fg=0]▓▒░" } separator() { echo "#[bg=$C9]#[fg=$C4]░▒#[bg=$C9]#[fg=$C9]▓" } CPU_INFO=$(cpu) RAM_INFO=$(ram) DISK_INFO=$(disk) echo "$(front)" "#[fg=0] ${RAM_INFO}%" "$(draw "$RAM_INFO" 4)" "#[fg=0] ${CPU_INFO}%" "$(draw "$CPU_INFO" 4)" "#[fg=0]󰽄 ${DISK_INFO}%" "$(draw "${DISK_INFO}" 4)" "$(vpn)" "$(separator)""$(clock)"