fix bar for desktop
[dotfiles.git] / x / .local / bin / bar
index 8d8d053..bc01c54 100755 (executable)
@@ -1,4 +1,23 @@
 #!/bin/sh
-echo \
-       "$(date +"%Y-%m-%d %H:%M:%S")"\
-       "       $(df -h | grep '/$' | awk '{print $4"/"$2}')"
+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
+
+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
+done
+
+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 "$net$snd$bat$dsk$date"