diff options
author | guixxx <guixxx@users.noreply.github.com> | 2017-04-12 22:38:43 +0300 |
---|---|---|
committer | Ben Hilburn <bhilburn@gmail.com> | 2017-04-19 01:02:37 +0300 |
commit | c403ad6cd72669a1849fc5738ed51acaa946d2e2 (patch) | |
tree | 576335e12c06282e9b2b7063ad6136939b87b2be /powerlevel9k.zsh-theme | |
parent | 2be5d5071eaec4b6baecd45bca9ecb085953b763 (diff) |
Adds Android icon/battery plugin support
Plus fixes bhilburn/powerlevel9k#479, which was causing integer overflow on 32-bit CPUs
Diffstat (limited to 'powerlevel9k.zsh-theme')
-rwxr-xr-x | powerlevel9k.zsh-theme | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 2a9a159f..93db27cd 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -425,12 +425,17 @@ prompt_battery() { esac fi - if [[ $OS =~ Linux ]]; then + if [[ "$OS" == 'Linux' ]] || [[ "$OS" == 'Android' ]]; then local sysp="/sys/class/power_supply" + # Reported BAT0 or BAT1 depending on kernel version [[ -a $sysp/BAT0 ]] && local bat=$sysp/BAT0 [[ -a $sysp/BAT1 ]] && local bat=$sysp/BAT1 + # Android-related + # Tested on: Moto G falcon (CM 13.0) + [[ -a $sysp/battery ]] && local bat=$sysp/battery + # Return if no battery found [[ -z $bat ]] && return local capacity=$(cat $bat/capacity) @@ -1283,8 +1288,9 @@ powerlevel9k_prepare_prompts() { RETVAL=$? _P9K_COMMAND_DURATION=$((EPOCHREALTIME - _P9K_TIMER_START)) + # Reset start time - _P9K_TIMER_START=99999999999 + _P9K_TIMER_START=2147483647 if [[ "$POWERLEVEL9K_PROMPT_ON_NEWLINE" == true ]]; then PROMPT="$(print_icon 'MULTILINE_FIRST_PROMPT_PREFIX')%f%b%k$(build_left_prompt) @@ -1317,8 +1323,11 @@ NEWLINE=' } prompt_powerlevel9k_setup() { + # I decided to use the value below for better supporting 32-bit CPUs, since the previous value "99999999999" was causing issues on my Android phone, which is powered by an armv7l + # We don't have to change that until 19 January of 2038! :) + # Disable false display of command execution time - _P9K_TIMER_START=99999999999 + _P9K_TIMER_START=2147483647 # Display a warning if the terminal does not support 256 colors local term_colors |