fix_modules.sh (684B)
1 #!/usr/bin/env bash 2 3 # Fix Some polybar modules 4 5 dir="$HOME/.config/polybar" 6 style=$(cat $dir/launch.sh | grep STYLE | head -n 1 | tr -d 'STYLE=' | tr -d \") 7 module="$dir/$style/modules.ini" 8 9 # Battery Module 10 BAT=$(ls /sys/class/power_supply | grep BAT | head -n 1) 11 AC=$(ls /sys/class/power_supply | grep AC | head -n 1) 12 if [[ "$BAT" ]]; then 13 sed -i -e "s/battery = .*/battery = $BAT/g" $module 14 fi 15 if [[ "$AC" ]]; then 16 sed -i -e "s/adapter = .*/adapter = $AC/g" $module 17 fi 18 19 # Network (Wifi) Module 20 IFACE=$(ip link | awk '/state UP/ {print $2}' | tr -d :) 21 if [[ "$IFACE" ]]; then 22 sed -i -e "s/interface = .*/interface = $IFACE/g" $module 23 fi 24 25 # Reload Config 26 polybar-msg cmd restart