tmux-kanagawa/scripts/battery.sh

33 lines
500 B
Bash
Raw Normal View History

2020-03-14 22:42:06 +01:00
#!/usr/bin/env bash
2020-03-15 00:57:01 +01:00
#author: Dane Williams
#scipt for gathering battery percentage and A/C status
#script is called in dracula.tmux program
2020-03-14 22:42:06 +01:00
battery_percent()
{
echo $(pmset -g batt | grep -Eo '[0-9]?[0-9]?[0-9]%')
}
battery_status()
{
status=$(pmset -g batt | sed -n 2p | cut -d ';' -f 2)
if [ $status = 'discharging' ]; then
echo ''
else
2020-03-15 22:18:06 +01:00
echo 'AC '
2020-03-14 22:42:06 +01:00
fi
}
main()
{
bat_stat=$(battery_status)
bat_perc=$(battery_percent)
echo "$bat_stat$bat_perc"
}
2020-03-15 00:57:01 +01:00
#run main driver program
2020-03-14 22:42:06 +01:00
main