X-Git-Url: https://git.martlubbers.net/?a=blobdiff_plain;f=i3%2Fbar;h=30e24cea6e1de79e1edb606a1f0f554165578b15;hb=b78a9f27b37eca6b75ec1f2fc993c1e5b717609d;hp=24b05f348c66ece4f7bd7d6ca7f29d3ab7d8a01f;hpb=7df7ab410d3a07d88f42cb9a83752d11f3093001;p=dotfiles.git diff --git a/i3/bar b/i3/bar index 24b05f3..30e24ce 100755 --- a/i3/bar +++ b/i3/bar @@ -1,35 +1,25 @@ #!/bin/bash -function music { - song=$([ "$(mpc | wc -l)" = "1" ] && echo "[stopped]" || echo $(mpc | head -1)) - status=$(mpc | grep -o "\[p.*\]") - echo -ne "♪: $song$status | " +item(){ + echo "{\"full_text\": \"$1\"}$2" } -function net { - cat /run/network/ifstate | grep -q $1 && echo "$2 | " +battery(){ + path=/sys/class/power_supply + now=$(($(cat "$path/BAT0/charge_now")*100/$(cat "$path/BAT0/charge_full"))) + [ "$(cat "$path/ADP1/online")" -eq "1" ] && charge="(C)" + [ "$now" -ge "100" ] && now="FULL" + echo -n "$now%$charge" } -function volume { - volume=$(amixer | grep -A4 Master | grep -o "[0-9]\{1,3\}%\|\[off\]") - echo -ne "♬: $volume | " +volume(){ + mixer=$(amixer | head -5 | tail -1) + echo $mixer | grep "\[on\]" || mute="(M)" + volume=$(echo $mixer | grep -Po "(?<=\[)[0-9]{1,3}%") + echo -n "vol: $volume$mute" } -function temp { - temp=$(sensors|grep temp1|head -1|awk '{print $2}') - echo -ne "⚠: $temp | " -} - -function battery { - pa="/sys/class/power_supply/BAT0" - power=$(echo "$(cat $pa/charge_now)*100/$(cat $pa/charge_full)" | bc) - charge="" - if [ "$(cat $pa/status)" = "Charging" ]; then - charge="(C)" - fi - echo -ne "⚡: $power%$charge | " -} - -while [ 1 ]; do - echo "$(music)$(volume)$(net wlan0 W)$(net eth0 E)$(net usb0 U)$(temp)$(battery)$(date +%y-%m-%d\ %H:%M)" - sleep 5 +while true; +do + echo "$(volume) | $(battery) | $(date +%x\ %X)" + sleep 1 done