Skip to content

Instantly share code, notes, and snippets.

@belkarx
Created July 22, 2022 20:42
Show Gist options
  • Save belkarx/a4f8c620d4dc14ba2d56d2a498f60d48 to your computer and use it in GitHub Desktop.
Save belkarx/a4f8c620d4dc14ba2d56d2a498f60d48 to your computer and use it in GitHub Desktop.
lemonbar.sh
#!/usr/bin/bash
Clock(){
TIME=$(date "+%H:%M:%S")
echo -e -n " \uf017 ${TIME}"
}
Cal() {
DATE=$(date +"%Y/%m/%d [%a]")
echo -e -n "\uf073 ${DATE}"
}
Battery() {
bat=$(cat /sys/class/power_supply/BAT0/capacity)
if [[ $(cat /sys/class/power_supply/BAT0/status) == "Charging" ]]; then
echo -e "\uf0e7 ^^$bat"
else
echo $bat
fi
}
Sound(){
NOTMUTED=$( amixer sget Master | grep "\[on\]" )
if [[ ! -z $NOTMUTED ]] ; then
VOL=$(awk -F"[][]" '/Left:/ { print $2 }' <(amixer sget Master))
echo -e "\uf026 ${VOL}"
else
echo -e "\uf026 M"
fi
}
phrase="belkarx :P"
speed=1
plus=.5 #change this to change speed
Phrase() {
# RANDIDK=$(shuf -i 1-4 -n 1);
# if [[ $RANDIDK == 1 ]]; then
# fi;
echo "$(printf "%*s%s" $1 '')$phrase"
}
while true; do
echo -e "$(Battery) $(Sound) $(Clock) $(Cal) $(Phrase $speed)"
speed=$(($speed + $plus))
if [[ $speed -gt 263 ]] || [[ $speed -lt 1 ]]; then #260 or 271 - len(phrase)
plus=$(($plus * -1))
fi;
sleep 0.01s
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment