tmux/.local/bin/tmux-status #!/bin/bash # ██ # ░██ # ██████ ██████████ ██ ██ ██ ██ # ░░░██░ ░░██░░██░░██░██ ░██░░██ ██ # ░██ ░██ ░██ ░██░██ ░██ ░░███ # ░██ ░██ ░██ ░██░██ ░██ ██░██ # ░░██ ███ ░██ ░██░░██████ ██ ░░██ # ░░ ░░░ ░░ ░░ ░░░░░░ ░░ ░░ # ██ ██ # ░██ ░██ # ██████ ██████ ██████ ██████ ██ ██ ██████ # ██░░░░ ░░░██░ ░░░░░░██ ░░░██░ ░██ ░██ ██░░░░ #░░█████ ░██ ███████ ░██ ░██ ░██░░█████ # ░░░░░██ ░██ ██░░░░██ ░██ ░██ ░██ ░░░░░██ # ██████ ░░██ ░░████████ ░░██ ░░██████ ██████ #░░░░░░ ░░ ░░░░░░░░ ░░ ░░░░░░ ░░░░░░ # # ▓▓▓▓▓▓▓▓▓▓ # ░▓ author ▓ xero <x@xero.style> # ░▓ code ▓ https://code.x-e.ro/dotfiles # ░▓ mirror ▓ https://git.io/.files # ░▓▓▓▓▓▓▓▓▓▓ # ░░░░░░░░░░ # #----------------------------------------------------------// vars FULL=━ EMPTY=┄ C0="#000000" C1="#222222" C2="#8FBCBB" C3="#B3291C" C4="#685742" C5="#d7c483" C6="#C9A554" C7="#78824b" C8="#B36D43" #--------------------------------------------------// progress bar draw() { perc= size= inc=$((perc * size / 125)) out= for v in $(seq 0 $((size - 1))); do [[ "$v" -le "$inc" ]] && out="${out}#[fg=$C1]${FULL}" || out="${out}#[fg=$C6]${EMPTY}" done printf "%s" "$out" } #-------------------------------------------------------// compute FRONT="#[bg=$C7]#[fg=0]▓▒░" RAM=$(free | awk '/Mem:/ {print int(/ * 100.0)}') CPU=$(printf "%.0f" "$(grep 'cpu ' /proc/stat | awk '{usage=(+)*100/(++)} END {print usage}')") SYS=$({ printf "#[fg=%s] %s %s " "$C0" "${RAM}%" "$(draw "$RAM" 4)" printf "#[fg=%s] %s %s" "$C0" "${CPU}%" "$(draw "$CPU" 4)" }) D1=$(df -h | grep '/$' | tr -s ' ' | cut -d ' ' -f5 | sed 's/%//') D2=$(df -h | grep 'x0' | tr -s ' ' | cut -d ' ' -f5 | sed 's/%//') DISK=$({ [[ -z "$D0" ]] && printf "#[fg=%s] %s %s" "$C0" "${D1}%" "$(draw "$D1" 4)" [[ -z "$D1" ]] && printf " #[fg=%s] %s %s" "$C0" "${D2}%" "$(draw "$D2" 4)" }) BAT=$({ BATPATH=$(find /sys/class/power_supply -name 'status' \ -printf "%h\n" | head -1 | sed 's/[[:space:]]//g') if [[ -n "$BATPATH" ]]; then bf="$(< "$BATPATH/charge_full")" bn="$(< "$BATPATH/charge_now")" bp=$((100 * bn / bf)) case "$(< "$BATPATH/status")" in Discharging) if [[ "$bp" -gt 90 ]]; then : "" elif [[ "$bp" -gt 50 ]]; then : "" elif [[ "$bp" -gt 20 ]]; then : "" else : "#[fg=$C3]#[fg=$C0]" fi ;; Charging) : "" ;; *) : "" ;; esac st="$_" printf " #[fg=%s]%s %s%s" "$C0" "$st" "$bp" "%" fi }) TIME=$({ printf "#[bg=%s]#[fg=%s]░▒#[bg=%s]#[fg=%s]▓\ #[fg=%s]#[bg=%s] %s #[fg=%s]%s#[fg=%s]%s #[bg=0]#[fg=%s]▒░" \ "$C9" "$C4" "$C9" "$C9" "$C5" "$C4" \ "$(date +'%H:%M')" "$C6" "$(date +'%Y-%m-')" \ "$C5" "$(date +'%d')" "$C4" }) #--------------------------------------------------------// render printf "%s %s %s%s %s" "$FRONT" "$SYS" "$DISK" "$BAT" "$TIME"