dotfiles/lemonbar.sh

103 lines
2.6 KiB
Bash
Raw Normal View History

GREY="#5f5f5f"
2015-10-12 16:55:33 +02:00
WHITE="#93a1a1"
WHITE2="#fdf6e3"
BLACK="#181b20"
2015-10-12 16:55:33 +02:00
RED="#dc322f"
BLUE="#2aa198"
GREEN="#859900"
BROWN="#b58900"
FG="#586e75"
BG="#dfdfdf"
2015-08-26 00:56:33 +02:00
buildClock() {
2015-10-12 16:55:33 +02:00
echo -n "%{F$FG}$(date "+%A, %e %B, %k:%M")"
2015-08-26 00:56:33 +02:00
}
getVolume() {
ONOFF=$(amixer get Master | cut -d$'\n' -f 5 | cut -d ' ' -f 8)
VOLUME=$(amixer get Master | sed -n 's/^.*\[\([0-9]\+\)%.*$/\1/p' | uniq)
COLOR=
if [ $ONOFF == "[off]" ]; then
COLOR=$RED
else
2015-10-12 16:55:33 +02:00
COLOR=$FG
fi
VOLUME=$(spark $VOLUME 0 100 | tail -n 1 | cut -b1-3)
echo -n "%{F$COLOR}$VOLUME"
2015-08-26 00:56:33 +02:00
}
getMPD(){
2015-08-28 19:10:03 +02:00
MPD1=$(mpc | cut -d$'\n' -f1)
MPD2=$(mpc | cut -d$'\n' -f2)
PERC=$(echo "$(echo $MPD2 | cut -d ' ' -f4 | cut -b2-3 | cut -d '%' -f1) 0 100" | spark | tail -n 1 | cut -b1-3)
#PERC=$(echo "$(echo $MPD2 | cut -d ' ' -f4 | cut -b2-3 | cut -d '%' -f1) 0 100" | spark | cut -b 1-3)
if [ "$(mpc | wc -l)" -gt 1 ]; then
2015-10-12 16:55:33 +02:00
echo -n "%{F$BLUE}♫ %{F#6c71c4}$MPD1 %{F$BLUE}♫ $PERC %{F$FG}$(echo -n $MPD2 | cut -d ' ' -f1,2)"
fi
2015-08-26 00:56:33 +02:00
}
getNET(){
2015-09-25 18:27:33 +02:00
NDATA=$(connmanctl services | grep "*A")
NSTATE=$(echo $NDATA | cut -b3)
NNAME=$(echo $NDATA | cut -d' ' -f2)
if [ "$NSTATE" == "c" ]; then
2015-10-12 16:55:33 +02:00
NCOLOR="$BLACK"
2015-09-25 18:27:33 +02:00
elif [ "$NSTATE" == "R" ]; then
NCOLOR="$BLUE"
elif [ "$NSTATE" == "O" ]; then
2015-10-12 16:55:33 +02:00
NCOLOR="$FG"
else
2015-09-25 18:27:33 +02:00
NCOLOR="$RED"
fi
if [ "$NCOLOR" == "$RED" ]; then
echo -n "%{F$RED}Offline"
2015-09-25 18:27:33 +02:00
else
echo -n "%{F$NCOLOR}$NNAME"
fi
2015-08-26 00:56:33 +02:00
}
2015-08-27 21:12:34 +02:00
getDISK(){
2015-10-12 16:55:33 +02:00
echo -n "%{F$FG}$(echo "$(du -ms ~ | cut -d$'\t' -f1)/1000" | bc) GB"
}
separator(){
2015-10-12 16:55:33 +02:00
echo -n " "
2015-08-27 21:12:34 +02:00
}
2015-08-31 17:03:18 +02:00
getLOAD(){
LOAD=$(echo -n "$(cat /proc/loadavg | cut -d ' ' -f 1-3) $(egrep -c '^processor' /proc/cpuinfo)00 0" | sed 's/\(0\.\|0\.0\|\.\)//g' | sed 's/800/300/g' | spark | tail -n 1 | cut -b 1-9)
2015-10-12 16:55:33 +02:00
echo -n "%{F$FG}$LOAD"
2015-08-31 17:03:18 +02:00
}
2015-08-28 15:55:07 +02:00
getMEM(){
total=$(grep 'MemTotal' /proc/meminfo | egrep -o '[0-9]+')
not_apps=0
for mem in $(egrep '(MemFree|Buffers|Cached|Slab|PageTables|SwapCached)' /proc/meminfo | egrep -o '[0-9]+'); do
not_apps=$((not_apps+mem))
done
USEDMEM=$(echo "$((total-not_apps))/1000" | bc)
2015-10-12 16:55:33 +02:00
echo -n "%{F$FG}$USEDMEM MB"
2015-08-28 15:55:07 +02:00
}
2015-10-09 13:02:30 +02:00
getBAT(){
BAT=$(acpi -b | head -n1 | cut -d ' ' -f4 | cut -d '%' -f1)
2015-10-12 16:55:33 +02:00
echo -n "%{F$FG}$BAT $(echo $BAT 0 100 | spark | cut -b 1-3)"
}
getWORKSPC(){
FOC="$(bspc query -D -d focused)"
echo -n "%{B$FG}%{F$BG} $FOC %{B$BG}"
2015-10-09 13:02:30 +02:00
}
2015-08-26 00:56:33 +02:00
buildBar () {
while true
do
2015-10-09 13:02:30 +02:00
echo " $(getMPD) %{c}$(buildClock) %{r} $(getLOAD) $(separator) $(getMEM) $(separator) $(getDISK) $(separator) $(getNET) $(separator) $(getVolume) $(separator) $(getBAT) "
2015-10-08 19:02:44 +02:00
sleep 5
2015-08-26 00:56:33 +02:00
done
}
2015-10-12 16:55:33 +02:00
buildBar | lemonbar -p -g "1890x20+15" -B "#dfdfdf" -F "$FG" -f "xft:DejaVu Sans Mono:size=11"