dotfiles/stow_home/spectrwm/.config/spectrwm/baraction.sh

108 lines
2.6 KiB
Bash
Executable File

# network status
network() {
wifi="$(ip a | grep wlan0 | grep inet | wc -l)"
wire="$(ip a | grep enp1s0 | grep inet | wc -l)"
if [ $wire = 1 ]; then
echo " "
elif [ $wifi = 1 ]; then
echo " "
else
echo "睊"
fi
}
# battery status
bat() {
batstat="$(cat /sys/class/power_supply/BAT0/status)"
battery="$(cat /sys/class/power_supply/BAT0/capacity)"
if [ $batstat = 'Unknown' ]; then
batstat=""
elif [[ $battery -ge 5 ]] && [[ $battery -le 19 ]]; then
batstat=""
elif [[ $battery -ge 20 ]] && [[ $battery -le 39 ]]; then
batstat=""
elif [[ $battery -ge 40 ]] && [[ $battery -le 59 ]]; then
batstat=""
elif [[ $battery -ge 60 ]] && [[ $battery -le 79 ]]; then
batstat=""
elif [[ $battery -ge 80 ]] && [[ $battery -le 95 ]]; then
batstat=""
elif [[ $battery -ge 96 ]] && [[ $battery -le 100 ]]; then
batstat=""
fi
echo "$batstat $battery"
}
# volume status
vol() {
volstat=$(pamixer --get-volume-human)
vol=$(echo "$volstat")
volicon="墳"
echo "$volicon $vol"
}
# used storage
hdd() {
hdd="$(df -h /home | grep /dev | awk '{print $3 " / " $2}')"
echo "$hdd"
}
# available ram
mem() {
used="$(free -h | grep Mem: | awk '{print $3}')"
#total="$(free | grep Mem: | awk '{print $2}')"
#totalh="$(free -h | grep Mem: | awk '{print $2}' | sed 's/Gi/G/')"
ram="$used"
echo $ram
}
# Cpu things
cpu() {
read cpu a b c previdle rest < /proc/stat
prevtotal=$((a+b+c+previdle))
sleep 0.5
read cpu a b c idle rest < /proc/stat
total=$((a+b+c+idle))
cpu=$((100*( (total-prevtotal) - (idle-previdle) ) / (total-prevtotal) ))
echo -e " $cpu%"
}
# Loop to update bar output
update(){
echo "$(cpu)+@fg=3; +@bg=1;+@fg=1;  $(mem) +@fg=4;+@bg=2;+@fg=1;  $(hdd) +@fg=5;+@bg=3;+@fg=1; $(vol) +@fg=7;+@bg=5;+@fg=1; $(bat) +@fg=8;+@bg=6;+@fg=1; $(network) +@fg=1;+@bg=0;"
wait
}
while :; do
update
#~/.config/spectrwm/scripts/trayer_follows_ws.sh
sleep 2 &
wait
done
mpd(){
song="$(mpc current)"
status="$(mpc status | grep paused | awk '{print $1}')"
echo -e "$song"
}
# Installed packages
pkgs() {
pkgs="$(xbps-query -l | wc -l)"
echo -e " $pkgs"
}
# Available updates
upgrades() {
upgrades="$(xbps-install -Sun | wc -l)"
echo -e " $upgrades"
}
# weather using curl wttr.in
temp() {
tmp="$(curl -s wttr.in | grep -m 1 °C | awk '{print $5 $6}')"
##tmp="$(grep temp_F ~/.config/weather.txt | awk '{print $2}' | sed 's/"//g' | sed 's/,/ F/g')"
echo " $tmp"
}