dotfiles

custom linux config files managed with gnu stow

dotfiles

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
[[ -z "$UI_THEME" ]] && UI_THEME="MIASMA"
FULL=━
EMPTY=┄
if [[ "$UI_THEME" == "EVANGELION" ]]; then
	C0=#201430
	C1=#3b3847
	C2=#a4d2ec
	C3=#db6088
	C4=#875FAF
	C5=#ccd2d9
	C6=#e1d6f8
	C7=#ab92fc
else
	C0="#000000"
	C1="#222222"
	C2="#8FBCBB"
	C3="#B3291C"
	C4="#685742"
	C5="#d7c483"
	C6="#C9A554"
	C7="#78824b"
fi
#--------------------------------------------------// 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=$({
	[[ -n "$D1" ]] &&
		printf "#[fg=%s]󰽄 %s %s" "$C0" "${D1}%" "$(draw "$D1" 4)"
	[[ -n "$D2" ]] &&
		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]▒░" \
		"$C7" "$C4" "$C7" "$C4" "$C5" "$C4" \
		"$(date +'%H:%M')" "$C6" "$(date +'%Y-%m-')" \
		"$C5" "$(date +'%d')" "$C4"
})
#--------------------------------------------------------// render
printf "%s %s %s %s" "$FRONT" "$SYS" "$DISK" "$TIME"

Download

raw zip tar