From 5f784b72b6e18420b14072b0e6265ce07d5f5e5c Mon Sep 17 00:00:00 2001 From: Dane Williams Date: Sat, 14 Mar 2020 14:42:06 -0700 Subject: [PATCH] added battery support --- battery.sh | 27 +++++++++++++++++++++++++++ dracula.tmux | 20 +------------------- 2 files changed, 28 insertions(+), 19 deletions(-) create mode 100755 battery.sh diff --git a/battery.sh b/battery.sh new file mode 100755 index 0000000..fe8a234 --- /dev/null +++ b/battery.sh @@ -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 + diff --git a/dracula.tmux b/dracula.tmux index 36af5f5..4ce3119 100755 --- a/dracula.tmux +++ b/dracula.tmux @@ -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 "