24b05f348c66ece4f7bd7d6ca7f29d3ab7d8a01f
[dotfiles.git] / i3 / bar
1 #!/bin/bash
2 function music {
3 song=$([ "$(mpc | wc -l)" = "1" ] && echo "[stopped]" || echo $(mpc | head -1))
4 status=$(mpc | grep -o "\[p.*\]")
5 echo -ne "♪: $song$status | "
6 }
7
8 function net {
9 cat /run/network/ifstate | grep -q $1 && echo "$2 | "
10 }
11
12 function volume {
13 volume=$(amixer | grep -A4 Master | grep -o "[0-9]\{1,3\}%\|\[off\]")
14 echo -ne "♬: $volume | "
15 }
16
17 function temp {
18 temp=$(sensors|grep temp1|head -1|awk '{print $2}')
19 echo -ne "⚠: $temp | "
20 }
21
22 function battery {
23 pa="/sys/class/power_supply/BAT0"
24 power=$(echo "$(cat $pa/charge_now)*100/$(cat $pa/charge_full)" | bc)
25 charge=""
26 if [ "$(cat $pa/status)" = "Charging" ]; then
27 charge="(C)"
28 fi
29 echo -ne "⚡: $power%$charge | "
30 }
31
32 while [ 1 ]; do
33 echo "$(music)$(volume)$(net wlan0 W)$(net eth0 E)$(net usb0 U)$(temp)$(battery)$(date +%y-%m-%d\ %H:%M)"
34 sleep 5
35 done