From ff3f6b8e833946a8e98352ceb15e8eb5682e2b69 Mon Sep 17 00:00:00 2001 From: rjorgenson Date: Sun, 18 Oct 2015 19:48:45 -0700 Subject: [PATCH] added time remaining support to battery segment on Linux --- README.md | 2 +- powerlevel9k.zsh-theme | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 33b0fc85..b66304bc 100644 --- a/README.md +++ b/README.md @@ -116,7 +116,7 @@ with the environment variables detailed below with their default values. In addition to the above it supports standard _FOREGROUND value without affecting the icon color -Supports both OS X and Linux(time remaining is only output in OS X) +Supports both OS X and Linux(time remaining requires the acpi program on Linux) ##### context diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index eefeaa5b..bb24e60a 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -670,6 +670,10 @@ prompt_battery() { if [[ ! $connected =~ true ]]; then [[ $bat_percent -lt $POWERLEVEL9K_BATTERY_LOW_THRESHOLD ]] && local conn="%F{$POWERLEVEL9K_BATTERY_LOW_COLOR}" || local conn="%F{$POWERLEVEL9K_BATTERY_DISCONNECTED}" fi + if [[ -f /usr/bin/acpi ]]; then + [[ $(acpi | awk '{ print $5 }') =~ rate ]] && local tstring="..." || local tstring=${(f)$(date -u -d @$(acpi | awk '{ print $5 }' | sed s/://g) +%k:%M)} + fi + [[ ! -z $tstring ]] && local remain=" ($tstring)" fi # display prompt_segment