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