added battery support

This commit is contained in:
Dane Williams 2020-03-14 14:42:06 -07:00
parent 6d1af6e5d0
commit 5f784b72b6
2 changed files with 28 additions and 19 deletions

27
battery.sh Executable file
View File

@ -0,0 +1,27 @@
#!/usr/bin/env bash
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
echo 'Charging '
fi
}
main()
{
bat_stat=$(battery_status)
bat_perc=$(battery_percent)
echo "$bat_stat$bat_perc"
}
main

View File

@ -4,21 +4,6 @@
# author: Dane Williams
battery_percent()
{
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 'Charging'
else
echo 'Battery'
fi
}
main()
{
@ -40,9 +25,6 @@ main()
tmux set-option -g status-left-length 100
tmux set-option -g status-right-length 100
# battery
batt_perc=$(battery_percent)
# pane border styling
tmux set-option -g pane-active-border-style "fg=${dark_purple}"
tmux set-option -g pane-border-style "fg=${gray}"
@ -54,7 +36,7 @@ main()
tmux set-option -g status-style "bg=${gray},fg=${white}"
tmux set-option -g status-left "#[bg=${green},fg=${dark_gray}]#{?client_prefix,#[bg=${orange}],} ☺ "
tmux set-option -g status-right "#[fg=${dark_gray},bg=${cyan}] tructus "
tmux set-option -ga status-right "#[fg=${dark_gray},bg=${pink}] $(battery_status) ${batt_perc}% #[fg=${white},bg=${dark_purple}] %a %H:%M:%S #(date +%Z) %m/%d/%Y "
tmux set-option -ga status-right "#[fg=${dark_gray},bg=${pink}] #(~/.tmux/plugins/tmux-dracula/battery.sh) #[fg=${white},bg=${dark_purple}] %a %H:%M #(date +%Z) %m/%d/%Y "
# window tabs
tmux set-window-option -g window-status-current-format "#[fg=${white},bg=${dark_purple}] #I #W "