mirror of
https://github.com/romkatv/powerlevel10k.git
synced 2024-11-14 09:00:07 +00:00
Adds Android icon/battery plugin support
Plus fixes bhilburn/powerlevel9k#479, which was causing integer overflow on 32-bit CPUs
This commit is contained in:
parent
2be5d5071e
commit
c403ad6cd7
3 changed files with 25 additions and 3 deletions
|
@ -43,6 +43,7 @@ case $POWERLEVEL9K_MODE in
|
||||||
MULTILINE_SECOND_PROMPT_PREFIX $'\u2570'$'\U2500 '
|
MULTILINE_SECOND_PROMPT_PREFIX $'\u2570'$'\U2500 '
|
||||||
APPLE_ICON $'\uE26E' #
|
APPLE_ICON $'\uE26E' #
|
||||||
FREEBSD_ICON $'\U1F608 ' # 😈
|
FREEBSD_ICON $'\U1F608 ' # 😈
|
||||||
|
ANDROID_ICON $'\uE270' #
|
||||||
LINUX_ICON $'\uE271' #
|
LINUX_ICON $'\uE271' #
|
||||||
SUNOS_ICON $'\U1F31E ' # 🌞
|
SUNOS_ICON $'\U1F31E ' # 🌞
|
||||||
HOME_ICON $'\uE12C' #
|
HOME_ICON $'\uE12C' #
|
||||||
|
@ -112,6 +113,7 @@ case $POWERLEVEL9K_MODE in
|
||||||
MULTILINE_SECOND_PROMPT_PREFIX $'\u2570'$'\U2500 ' # ╰─
|
MULTILINE_SECOND_PROMPT_PREFIX $'\u2570'$'\U2500 ' # ╰─
|
||||||
APPLE_ICON $'\uF179' #
|
APPLE_ICON $'\uF179' #
|
||||||
FREEBSD_ICON $'\U1F608 ' # 😈
|
FREEBSD_ICON $'\U1F608 ' # 😈
|
||||||
|
ANDROID_ICON $'\uE17B' #
|
||||||
LINUX_ICON $'\uF17C' #
|
LINUX_ICON $'\uF17C' #
|
||||||
SUNOS_ICON $'\uF185 ' #
|
SUNOS_ICON $'\uF185 ' #
|
||||||
HOME_ICON $'\uF015' #
|
HOME_ICON $'\uF015' #
|
||||||
|
@ -177,6 +179,7 @@ case $POWERLEVEL9K_MODE in
|
||||||
MULTILINE_SECOND_PROMPT_PREFIX $'\u2570'$'\U2500 ' # ╰─
|
MULTILINE_SECOND_PROMPT_PREFIX $'\u2570'$'\U2500 ' # ╰─
|
||||||
APPLE_ICON $'\uF179' #
|
APPLE_ICON $'\uF179' #
|
||||||
FREEBSD_ICON $'\UF30E ' #
|
FREEBSD_ICON $'\UF30E ' #
|
||||||
|
ANDROID_ICON $'\uF17B' #
|
||||||
LINUX_ICON $'\uF17C' #
|
LINUX_ICON $'\uF17C' #
|
||||||
SUNOS_ICON $'\uF185 ' #
|
SUNOS_ICON $'\uF185 ' #
|
||||||
HOME_ICON $'\uF015' #
|
HOME_ICON $'\uF015' #
|
||||||
|
@ -242,6 +245,7 @@ case $POWERLEVEL9K_MODE in
|
||||||
MULTILINE_SECOND_PROMPT_PREFIX $'\u2570'$'\u2500 '
|
MULTILINE_SECOND_PROMPT_PREFIX $'\u2570'$'\u2500 '
|
||||||
APPLE_ICON 'OSX'
|
APPLE_ICON 'OSX'
|
||||||
FREEBSD_ICON 'BSD'
|
FREEBSD_ICON 'BSD'
|
||||||
|
ANDROID_ICON 'And'
|
||||||
LINUX_ICON 'Lx'
|
LINUX_ICON 'Lx'
|
||||||
SUNOS_ICON 'Sun'
|
SUNOS_ICON 'Sun'
|
||||||
HOME_ICON ''
|
HOME_ICON ''
|
||||||
|
|
|
@ -111,6 +111,15 @@ case $(uname) in
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
# Not all OSes support the '-o' parameter
|
||||||
|
# That's why this second condition is needed
|
||||||
|
case $(uname -o 2>/dev/null) in
|
||||||
|
Android)
|
||||||
|
OS='Android'
|
||||||
|
OS_ICON=$(print_icon 'ANDROID_ICON')
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
# Determine the correct sed parameter.
|
# Determine the correct sed parameter.
|
||||||
#
|
#
|
||||||
# `sed` is unfortunately not consistent across OSes when it comes to flags.
|
# `sed` is unfortunately not consistent across OSes when it comes to flags.
|
||||||
|
|
|
@ -425,12 +425,17 @@ prompt_battery() {
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $OS =~ Linux ]]; then
|
if [[ "$OS" == 'Linux' ]] || [[ "$OS" == 'Android' ]]; then
|
||||||
local sysp="/sys/class/power_supply"
|
local sysp="/sys/class/power_supply"
|
||||||
|
|
||||||
# Reported BAT0 or BAT1 depending on kernel version
|
# Reported BAT0 or BAT1 depending on kernel version
|
||||||
[[ -a $sysp/BAT0 ]] && local bat=$sysp/BAT0
|
[[ -a $sysp/BAT0 ]] && local bat=$sysp/BAT0
|
||||||
[[ -a $sysp/BAT1 ]] && local bat=$sysp/BAT1
|
[[ -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
|
# Return if no battery found
|
||||||
[[ -z $bat ]] && return
|
[[ -z $bat ]] && return
|
||||||
local capacity=$(cat $bat/capacity)
|
local capacity=$(cat $bat/capacity)
|
||||||
|
@ -1283,8 +1288,9 @@ powerlevel9k_prepare_prompts() {
|
||||||
RETVAL=$?
|
RETVAL=$?
|
||||||
|
|
||||||
_P9K_COMMAND_DURATION=$((EPOCHREALTIME - _P9K_TIMER_START))
|
_P9K_COMMAND_DURATION=$((EPOCHREALTIME - _P9K_TIMER_START))
|
||||||
|
|
||||||
# Reset start time
|
# Reset start time
|
||||||
_P9K_TIMER_START=99999999999
|
_P9K_TIMER_START=2147483647
|
||||||
|
|
||||||
if [[ "$POWERLEVEL9K_PROMPT_ON_NEWLINE" == true ]]; then
|
if [[ "$POWERLEVEL9K_PROMPT_ON_NEWLINE" == true ]]; then
|
||||||
PROMPT="$(print_icon 'MULTILINE_FIRST_PROMPT_PREFIX')%f%b%k$(build_left_prompt)
|
PROMPT="$(print_icon 'MULTILINE_FIRST_PROMPT_PREFIX')%f%b%k$(build_left_prompt)
|
||||||
|
@ -1317,8 +1323,11 @@ NEWLINE='
|
||||||
}
|
}
|
||||||
|
|
||||||
prompt_powerlevel9k_setup() {
|
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
|
# 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
|
# Display a warning if the terminal does not support 256 colors
|
||||||
local term_colors
|
local term_colors
|
||||||
|
|
Loading…
Reference in a new issue