dotfiles/.config/spectrwm/bar

71 lines
1.5 KiB
Plaintext
Raw Normal View History

2020-12-01 02:27:42 +01:00
#! /usr/bin/env bash
entropy() {
entropy=$(cat /proc/sys/kernel/random/entropy_avail)
echo -e "Entr.: $entropy"
}
iface() {
# if Docker isn't installed, write '1p' insted of '2p'
# iface=$(ls /sys/class/net/ | tr " " "\n" | sed -n '2p')
# ip=$(ip addr show $iface | awk '{print $2}' | sed -n '3p')
# echo -e "$iface: $ip"
ip=$(hostname -i)
echo -e "IP: $ip"
}
kernelver() {
kernelver=$(uname -r)
echo -e "Kernel: $kernelver"
}
home() {
# disk=$(df -h | awk 'NR==9{print $3, $5}')
home=$(df -h | awk 'NR==9{print $3}')
echo -e "/home: $home"
}
root() {
# disk=$(df -h | awk 'NR==4{print $3, $5}')
root=$(df -h | awk 'NR==4{print $3}')
echo -e "/: $root"
}
memory() {
# memory=$(free | awk '/Mem/ {printf "%dMB / %dMB\n", $3 / 1024.0, $2 / 1024.0 }')
memory=$(free | awk '/Mem/ {printf "%d MB\n", $3 / 1024.0, $2 / 1024.0 }')
echo -e "RAM: $memory"
}
cpu() {
cpu=$(top -bn1 | grep "Cpu(s)" | sed "s/.*, *\([0-9.]*\)%* id.*/\1/" | awk '{print 100 - $1"%"}')
echo -e "CPU: $cpu"
}
battery() {
battery=$(cat /sys/class/power_supply/BAT0/capacity)
echo -e "Bat.: $battery%"
}
volume() {
volume=$(amixer get Master | awk -F'[][]' 'END{ print $4":"$2 }' | sed 's/on://g')
echo -e "Vol.: $volume"
}
brightness() {
brightness=$(xbacklight -get | sed 's/\..*$//')
echo -e "Bright.: $brightness%"
}
strengthness() {
strengthness=$(iwconfig wlp2s0 | grep -oP -- '-\d+ dBm')
echo -e "Wi-Fi stren.: $strengthness"
}
SLEEP_SEC=5
while :; do
echo "$(volume) | $(battery) | $(memory) | $(strengthness) | $(home) |"
sleep $SLEEP_SEC
done