summaryrefslogtreecommitdiff
path: root/.local/bin/dwmbar/dwmb-battery
blob: 5f3759ed66341a6c757361d93b16ccdd9cc1bf6a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/bin/sh

case $BLOCK_BUTTON in
	1) notify-send -a "  Battery" "$(acpi -b)" ;;
	3) notify-send -a "  Battery" "$(acpi -V)" ;;
	6) "$TERMINAL" -e "$EDITOR" "$0" ;;
esac

# Charging:					  #
# Discharching:			  #
# Full: underscore:   #
# LOW BATTERY:			  #

batstatus=$(acpi | tail -n 1)

ico=""

# Change the underscore color according to the charging state
case "$batstatus" in
  *Charging*) ico="  ";;
  *Discharging*) ico="  " ;;
  *) ico="  " ;;
esac

percentage=$( echo "$batstatus" | sed "s/.*\(\ [0-9]*\)\%.*$/\1/; s/\ //g; 1q")

echo "$ico$percentage% "