added bat-box
a little script that gives you time, date, and battery level in %, and as a nice utf8 box drawing column
This commit is contained in:
parent
2e29e525cd
commit
e19cb8f133
|
@ -0,0 +1,56 @@
|
|||
#!/bin/sh
|
||||
l="$(echo -e "\033"|rev|head -c1)"
|
||||
xit() {
|
||||
echo "${l}[0m";if command -v tput >/dev/null;then tput cnorm;else echo "failed to find tput";fi;exit
|
||||
}
|
||||
trap xit SIGINT EXIT
|
||||
l1="32" \
|
||||
l2="33" \
|
||||
l3="31" \
|
||||
l="$l" busybox ash<<"EOF"
|
||||
if command -v tput;then tput civis;else echo "failed to find tput!";fi
|
||||
xit() {
|
||||
echo -e "${l}[0m";if command -v tput >/dev/null;then tput cnorm;else echo "failed to find tput";fi;exit
|
||||
}
|
||||
trap xit SIGINT EXIT
|
||||
while true;do
|
||||
clear;
|
||||
bat="$(cat /sys/class/power_supply/BAT0/capacity)"
|
||||
#bat=50
|
||||
case "$bat" in
|
||||
[0-9]|1[0-2]) b0=" \n \n_";;
|
||||
1[2-9]) b0=" \n \n▂";;
|
||||
2[0-7]) b0=" \n \n▄";;
|
||||
2[8-9]|3[0-5]) b0=" \n \n▆";;
|
||||
3[6-9]|4[0-3]) b0=" \n▂\n█";;
|
||||
4[4-9]|5[0-1]) b0=" \n▄\n█";;
|
||||
5[2-9]) b0=" \n▄\n█";;
|
||||
6[0-7]) b0=" \n▆\n█";;
|
||||
6[8-9]|7[0-5]) b0=" \n█\n█";;
|
||||
7[6-9]|8[0-3]) b0="▂\n█\n█";;
|
||||
8[4-9]|9[0-1]) b0="▄\n█\n█";;
|
||||
9[2-9]) b0="▆\n█\n█";;
|
||||
100 ) b0="█\n█\n█";;
|
||||
* ) b0="?\n?\n?";;
|
||||
esac
|
||||
b1=$(printf "$b0"|head -1)
|
||||
b2=$(printf "$b0"|head -2|tail -1)
|
||||
b3=$(printf "$b0"|head -3|tail -1)
|
||||
date "+%F%n%T"|
|
||||
sed -e "1s/^/${l}[${l1}m/" -e"s/$/$l[0m/g" \
|
||||
-e "2s/^/${l}[${l2}m/";
|
||||
echo "┌──────┐$b1"
|
||||
echo -n "│ "
|
||||
printf "%03d%%" $(cat /sys/class/power_supply/BAT0/capacity)|
|
||||
if test $(cat /sys/class/power_supply/BAT0/status) != "Charging";then
|
||||
cat|sed "s/^0/ /";
|
||||
else
|
||||
cat|sed "s/^0/⌁/";
|
||||
fi|
|
||||
sed -e "s/^/$l[${l3}m/" -e "s/$/$l[0m/"
|
||||
echo " │$b2"
|
||||
echo -n "└──────┘$b3"
|
||||
sleep 2;
|
||||
done
|
||||
l="";l1="";l2="";l3="";b0="";b1="";b2="";b3=""
|
||||
EOF
|
Loading…
Reference in New Issue