diff --git a/ansible/roles/sway/files/style.css b/ansible/roles/sway/files/style.css index 1da6e35..e29394d 100644 --- a/ansible/roles/sway/files/style.css +++ b/ansible/roles/sway/files/style.css @@ -76,11 +76,11 @@ animation-direction: alternate; } -#battery.warning { +#custom-battery.warning { color: orange; } -#battery.critical { +#custom-battery.critical { color: red; } diff --git a/ansible/roles/sway/files/waybar_battery_freebsd.bash b/ansible/roles/sway/files/waybar_battery_freebsd.bash index 7dd0741..18357a2 100644 --- a/ansible/roles/sway/files/waybar_battery_freebsd.bash +++ b/ansible/roles/sway/files/waybar_battery_freebsd.bash @@ -13,6 +13,7 @@ while true; do battery_percentage=$(apm -l) battery_status=$(apm -b) seconds_remaining=$(apm -t) + class="" if [ $battery_status -eq 3 ]; then if [ $battery_percentage -eq 100 ]; then @@ -33,6 +34,13 @@ while true; do else battery_icon="" fi + + if [ $battery_percentage -le 15 ]; then + class="critical" + elif [ $battery_percentage -le 30 ]; then + class="warning" + fi + if [ $seconds_remaining -eq -1 ]; then time_remaining="unknown time remaining." else @@ -43,7 +51,8 @@ while true; do { "text":"${battery_percentage}% ${battery_icon}", "tooltip":"${time_remaining}", -"percentage":${battery_percentage} +"percentage":${battery_percentage}, +"class":"${class}" } EOF sleep $SLEEP_INTERVAL diff --git a/ansible/roles/sway/files/waybar_battery_linux.bash b/ansible/roles/sway/files/waybar_battery_linux.bash index af221ff..96274d3 100644 --- a/ansible/roles/sway/files/waybar_battery_linux.bash +++ b/ansible/roles/sway/files/waybar_battery_linux.bash @@ -13,6 +13,8 @@ while true; do text="" tooltip="" percentage="" + class="" + while read bat; do battery_now=$(cat "$bat/charge_now") battery_capacity=$(cat "$bat/charge_full") @@ -39,6 +41,13 @@ while true; do else battery_icon="" fi + + if [ $battery_percentage -le 15 ]; then + class="critical" + elif [ $battery_percentage -le 30 ]; then + class="warning" + fi + if [ $seconds_remaining -eq -1 ]; then time_remaining="unknown time remaining." else @@ -55,7 +64,8 @@ while true; do { "text":"$text", "tooltip":"$tooltip", -"percentage":$percentage +"percentage":${percentage}, +"class":"${class}" } EOF sleep $SLEEP_INTERVAL