X-Git-Url: https://git.martlubbers.net/?a=blobdiff_plain;f=x%2F.local%2Fbin%2Fbar;h=bc01c546f1072f196d820771e4f9472c375ca8b2;hb=51e5e39bbd52f8ee4fece9e665b556429eb4d0ef;hp=079fac04a17d279f39523db47c26cb87a4fe2a93;hpb=11677e341464bf8954daed4f1d16e373b9111938;p=dotfiles.git diff --git a/x/.local/bin/bar b/x/.local/bin/bar index 079fac0..bc01c54 100755 --- a/x/.local/bin/bar +++ b/x/.local/bin/bar @@ -1,24 +1,23 @@ #!/bin/sh -batprefix=/sys/class/power_supply/BAT0 -if [ -f $batprefix/charge_full -a -f $batprefix/charge_now ]; then - bat="$(echo $(cat $batprefix/charge_now)*100/$(cat $batprefix/charge_full) | bc)% |" +if stat -t /sys/class/power_supply/BAT*/uevent >/dev/null 2>&1; then + for f in /sys/class/power_supply/BAT*/uevent; do + eval $(grep -v " " "$f") + bat="$bat⚡$((POWER_SUPPLY_CHARGE_NOW*100/POWER_SUPPLY_CHARGE_FULL))% ($POWER_SUPPLY_STATUS) | " + done fi -if ip -br a | grep -q '^wlp'; then - wlan="$(/sbin/iwconfig 2>/dev/null | grep -oP '(?<=ESSID:\").*(?=\")')" - if [ -z "$wlan" ]; then - wlan="Not connected |" - else - wlan="$wlan |" +for int in $(ip link show | grep -Po '(?<=.: )[A-Za-z0-9]+(?=:)'); do + if [ $(ip addr show dev $int | grep -Po "(?<=link/)\S+ ") = "ether" ]; then + net="$net$int: " + if /sbin/iwconfig $int >/dev/null 2>&1; then + net="$net$(/sbin/iwconfig $int | grep -Po '(?<=ESSID:").*(?=")') " + fi + net="$net($(ip addr show dev $int | grep -Po "(?<=inet )[0-9.]+")) | " fi -fi +done -eval $(xdotool search --onlyvisible trayer getwindowgeometry --shell) +snd="♪ $(pactl list sinks | grep -Po "(?<=Volume: front)[^%]*" | grep -o "[0-9]\?[0-9][0-9]$" | head -n 1) | " +dsk="Dsk: $(df -h | grep '/$' | awk '{print $4"/"$2}') | " +date="$(date +"%Y-%m-%d %H:%M") " -echo \ - "W $wlan"\ - "♪ $(pactl list sinks | grep -Po "(?<=Volume: front)[^%]*" | grep -o "100$") |"\ - "⚡$bat"\ - "Dsk: $(df -h | grep '/$' | awk '{print $4"/"$2}') |"\ - "$(date +"%Y-%m-%d %H:%M:%S") "\ - "$(printf "% $(((WIDTH-2)/20+1))s")" +echo "$net$snd$bat$dsk$date"