#!/bin/bash # ██ # ░██ # ██████ ██████████ ██ ██ ██ ██ # ░░░██░ ░░██░░██░░██░██ ░██░░██ ██ # ░██ ░██ ░██ ░██░██ ░██ ░░███ # ░██ ░██ ░██ ░██░██ ░██ ██░██ # ░░██ ███ ░██ ░██░░██████ ██ ░░██ # ░░ ░░░ ░░ ░░ ░░░░░░ ░░ ░░ # ██ ██ # ░██ ░██ # ██████ ██████ ██████ ██████ ██ ██ ██████ # ██░░░░ ░░░██░ ░░░░░░██ ░░░██░ ░██ ░██ ██░░░░ #░░█████ ░██ ███████ ░██ ░██ ░██░░█████ # ░░░░░██ ░██ ██░░░░██ ░██ ░██ ░██ ░░░░░██ # ██████ ░░██ ░░████████ ░░██ ░░██████ ██████ #░░░░░░ ░░ ░░░░░░░░ ░░ ░░░░░░ ░░░░░░ # # ▓▓▓▓▓▓▓▓▓▓ # ░▓ author ▓ xero # ░▓ 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=$1 size=$2 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]▓▒░" D1=$(df -h | grep '/$' | tr -s ' ' | cut -d ' ' -f5 | sed 's/%//') D2=$(df -h | grep 'x0' | tr -s ' ' | cut -d ' ' -f5 | sed 's/%//') BAT=$({ BATPATH=$(find /sys/class/power_supply -name 'status' -printf "%h\n" | head -1) BATPATH=$(find /tmp/power_supply -name 'status' -printf "%h\n" | head -1) 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=$C0]%s %s%s" "$st" "$bp" "%" fi }) RAM=$(free | awk '/Mem:/ {print int($3/$2 * 100.0)}') CPU=$(printf "%.0f" "$(grep 'cpu ' /proc/stat | awk '{usage=($2+$4)*100/($2+$4+$5)} END {print usage}')") 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 echo "$FRONT" \ "#[fg=$C0] ${RAM}%" "$(draw "$RAM" 4)" \ "#[fg=$C0] ${CPU}%" "$(draw "$CPU" 4)" \ "#[fg=$C0]󰽄 ${D1}%" "$(draw "$D1" 4)" \ "#[fg=$C0]󰖟 ${D2}%" "$(draw "$D2" 4)" \ "$BAT" \ "$TIME"