79 lines
1.8 KiB
Bash
Executable File
79 lines
1.8 KiB
Bash
Executable File
GREY="#5f5f5f"
|
|
WHITE="#9b9081"
|
|
WHITE2="#b3b3b3"
|
|
BLACK="#181b20"
|
|
RED="#6b4a49"
|
|
BLUE="#435861"
|
|
GREEN="#6f6749"
|
|
GREEN2="#6d6137"
|
|
BROWN="#776049"
|
|
|
|
buildClock() {
|
|
echo -n "%{F$WHITE2}$(date "+%A, %e %B, %k:%M:%S")"
|
|
}
|
|
|
|
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
|
|
elif [ $VOLUME -gt 60 ]; then
|
|
COLOR=$GREEN2
|
|
elif [ $VOLUME -gt 35 ]; then
|
|
COLOR=$GREEN
|
|
else
|
|
COLOR=$GREY
|
|
fi
|
|
VOLUME=$(spark $VOLUME 0 100 | tail -n 1 | cut -b1-3)
|
|
echo -n "$(separator) %{F$COLOR}$VOLUME $(separator)"
|
|
}
|
|
|
|
getMPD(){
|
|
echo -n "%{F$BLUE}♫ "
|
|
if [ "$(mpc | wc -l)" -gt 1 ]; then
|
|
echo -n "%{F$BROWN}$(mpc | cut -d$'\n' -f1) %{F$BLUE}♫ %{F$GREY}$(mpc | cut -d$'\n' -f2)"
|
|
fi
|
|
}
|
|
|
|
getNET(){
|
|
if [ ! -f /tmp/myip ]; then
|
|
echo "$(curl -s --connect-timeout 1 http://canihazip.com/s)" > /tmp/myip
|
|
fi
|
|
IP="$(cat /tmp/myip)"
|
|
if [ -n "$IP" ]; then
|
|
echo -n "%{F$GREEN}$IP"
|
|
else
|
|
echo -n "%{F$RED}Offline"
|
|
fi
|
|
}
|
|
|
|
getDISK(){
|
|
echo -n "%{F$BLUE}$(echo "$(du -ms ~ | cut -d$'\t' -f1)/1000" | bc) GB"
|
|
}
|
|
|
|
separator(){
|
|
echo -n "%{F$GREY}◆"
|
|
}
|
|
|
|
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)
|
|
echo -n "%{F$BLUE}$USEDMEM MB"
|
|
}
|
|
|
|
buildBar () {
|
|
while true
|
|
do
|
|
echo " $(getVolume) $(getMPD) %{c}$(buildClock) %{r} $(getMEM) $(separator) $(getDISK) $(separator) $(getNET) "
|
|
sleep 1
|
|
done
|
|
}
|
|
|
|
buildBar | lemonbar -p -g "1872x20+24+8" -B "$BLACK" -F "$GREY" -f -gohu-gohufont-medium-r-normal--14-100-100-100-c-80-iso10646-1
|
|
|