diff --git a/INSTALL.md b/INSTALL.md index e1b65872..3ef9e101 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -136,6 +136,12 @@ Customize label set -g @dracula-battery-label "Battery" ``` +(macOS only) Show time remaining until fully charged + +```bash +set -g @dracula-battery-show-charging-time true +``` + #### gpu-usage options Customize label @@ -190,13 +196,13 @@ set -g @dracula-git-disable-status true Set symbol to use for when branch is up to date with HEAD ```bash -# default is ✓. Avoid using non unicode characters that bash uses like $, * and ! +# default is ✓. Avoid using non unicode characters that bash uses like $, * and ! set -g @dracula-git-show-current-symbol ✓ ``` Set symbol to use for when branch diverges from HEAD ```bash -# default is unicode !. Avoid bash special characters +# default is unicode !. Avoid bash special characters set -g @dracula-git-show-diff-symbol ! ``` diff --git a/scripts/battery.sh b/scripts/battery.sh index 86b9ac05..508f808e 100755 --- a/scripts/battery.sh +++ b/scripts/battery.sh @@ -61,6 +61,32 @@ battery_percent() esac } +battery_time_left() +{ + # Check OS + case $(uname -s) in + Darwin) # regex test: https://regex101.com/r/yU4wn9/1 + time=$(pmset -g batt | \ + grep -Eo '((([1-9][0-9]*|[1-9]):[0-5][0-9])|(0:[1-5][0-9])|(0:0[1-9]))') + ;; + Linux|FreeBSD) + # leaving empty - TODO + ;; + CYGWIN*|MINGW32*|MSYS*|MINGW*) + # leaving empty - TODO - windows compatability + ;; + *) + ;; + esac + if ! $show_charging_time; then + echo '' + elif [ -z "$time" ]; then + echo '' + else + echo "($time)" + fi +} + battery_status() { # Check OS @@ -114,16 +140,18 @@ main() bat_label=$(get_tmux_option "@dracula-battery-label" "♥") bat_stat=$(battery_status) bat_perc=$(battery_percent) + bat_time=$(battery_time_left) if [ -z "$bat_stat" ]; then # Test if status is empty or not echo "$bat_label $bat_perc" elif [ -z "$bat_perc" ]; then # In case it is a desktop with no battery percent, only AC power echo "$bat_label $bat_stat" - else + elif [ -z "$bat_time" ]; then # Battery is fully charged echo "$bat_label $bat_stat $bat_perc" + else + echo "$bat_label $bat_stat $bat_perc $bat_time" fi } #run main driver program main - diff --git a/scripts/dracula.sh b/scripts/dracula.sh index 2b5e1f47..bab788bc 100755 --- a/scripts/dracula.sh +++ b/scripts/dracula.sh @@ -24,6 +24,7 @@ main() show_border_contrast=$(get_tmux_option "@dracula-border-contrast" false) show_day_month=$(get_tmux_option "@dracula-day-month" false) show_refresh=$(get_tmux_option "@dracula-refresh-rate" 5) + show_charging_time=$(get_tmux_option "@dracula-battery-show-charging-time" "false") IFS=' ' read -r -a plugins <<< $(get_tmux_option "@dracula-plugins" "battery network weather") # Dracula Color Pallette @@ -129,7 +130,7 @@ main() if [ $plugin = "git" ]; then IFS=' ' read -r -a colors <<< $(get_tmux_option "@dracula-git-colors" "green dark_gray") - script="#($current_dir/git.sh)" + script="#($current_dir/git.sh)" fi if [ $plugin = "battery" ]; then