aboutsummaryrefslogtreecommitdiff
path: root/dotfiles/.local/bin/bards4battery
blob: 6058c1986c686a829ece85a6e52da35415eea55b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#!/bin/sh

if [ -f /sys/class/power_supply/ps-controller-battery-*/capacity ]; then
  percentage=$(cat /sys/class/power_supply/ps-controller-battery-*/capacity)

  if [ percentage -lt 40 ]; then
    printf "<span color=\"#b2872f\">%s%%</span>" "$percentage"
    exit
  fi
  if [ percentage -lt 20 ]; then
    printf "<span color=\"#b73030\">%s%%</span>" "$percentage"
    exit
  fi
  printf "<span color=\"#5b8277\">%s%%</span>" "$percentage"
fi