commit
07b9305d2f
|
|
@ -10,6 +10,10 @@ ac_adapter_connected(){
|
||||||
then
|
then
|
||||||
ioreg -n AppleSmartBattery -r | grep -q '"ExternalConnected" = Yes'
|
ioreg -n AppleSmartBattery -r | grep -q '"ExternalConnected" = Yes'
|
||||||
return $?
|
return $?
|
||||||
|
elif command_exists WMIC;
|
||||||
|
then
|
||||||
|
WMIC Path Win32_Battery Get BatteryStatus /Format:List | grep -q 'BatteryStatus=2'
|
||||||
|
return $?
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -22,6 +26,10 @@ ac_adapter_disconnected(){
|
||||||
then
|
then
|
||||||
ioreg -n AppleSmartBattery -r | grep -q '"ExternalConnected" = No'
|
ioreg -n AppleSmartBattery -r | grep -q '"ExternalConnected" = No'
|
||||||
return $?
|
return $?
|
||||||
|
elif command_exists WMIC;
|
||||||
|
then
|
||||||
|
WMIC Path Win32_Battery Get BatteryStatus /Format:List | grep -q 'BatteryStatus=1'
|
||||||
|
return $?
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -38,37 +46,45 @@ battery_percentage(){
|
||||||
case $PERC_OUTPUT in
|
case $PERC_OUTPUT in
|
||||||
*%)
|
*%)
|
||||||
echo "0${PERC_OUTPUT}" | head -c 2
|
echo "0${PERC_OUTPUT}" | head -c 2
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo ${PERC_OUTPUT}
|
echo ${PERC_OUTPUT}
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
|
|
||||||
*" Charging"* | *" Discharging"*)
|
*" Charging"* | *" Discharging"*)
|
||||||
local PERC_OUTPUT=$(echo $ACPI_OUTPUT | awk -F, '/,/{gsub(/ /, "", $0); gsub(/%/,"", $0); print $2}' )
|
local PERC_OUTPUT=$(echo $ACPI_OUTPUT | awk -F, '/,/{gsub(/ /, "", $0); gsub(/%/,"", $0); print $2}' )
|
||||||
echo ${PERC_OUTPUT}
|
echo ${PERC_OUTPUT}
|
||||||
;;
|
;;
|
||||||
*" Full"*)
|
*" Full"*)
|
||||||
echo '100'
|
echo '100'
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo '-1'
|
echo '-1'
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
elif command_exists ioreg;
|
elif command_exists ioreg;
|
||||||
then
|
then
|
||||||
# http://hints.macworld.com/article.php?story=20100130123935998
|
|
||||||
#local IOREG_OUTPUT_10_6=$(ioreg -l | grep -i capacity | tr '\n' ' | ' | awk '{printf("%.2f%%", $10/$5 * 100)}')
|
|
||||||
#local IOREG_OUTPUT_10_5=$(ioreg -l | grep -i capacity | grep -v Legacy| tr '\n' ' | ' | awk '{printf("%.2f%%", $14/$7 * 100)}')
|
|
||||||
local IOREG_OUTPUT=$(ioreg -n AppleSmartBattery -r | awk '$1~/Capacity/{c[$1]=$3} END{OFMT="%05.2f%%"; max=c["\"MaxCapacity\""]; print (max>0? 100*c["\"CurrentCapacity\""]/max: "?")}')
|
local IOREG_OUTPUT=$(ioreg -n AppleSmartBattery -r | awk '$1~/Capacity/{c[$1]=$3} END{OFMT="%05.2f%%"; max=c["\"MaxCapacity\""]; print (max>0? 100*c["\"CurrentCapacity\""]/max: "?")}')
|
||||||
case $IOREG_OUTPUT in
|
case $IOREG_OUTPUT in
|
||||||
100*)
|
100*)
|
||||||
echo '100'
|
echo '100'
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo $IOREG_OUTPUT | head -c 2
|
echo $IOREG_OUTPUT | head -c 2
|
||||||
;;
|
;;
|
||||||
|
esac
|
||||||
|
elif command_exists WMIC;
|
||||||
|
then
|
||||||
|
local WINPC=$(echo porcent=$(WMIC PATH Win32_Battery Get EstimatedChargeRemaining /Format:List) | grep -o '[0-9]*')
|
||||||
|
case $WINPC in
|
||||||
|
100*)
|
||||||
|
echo '100'
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo $WINPC
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
else
|
else
|
||||||
echo "no"
|
echo "no"
|
||||||
|
|
@ -93,51 +109,51 @@ battery_charge(){
|
||||||
case $BATTERY_PERC in
|
case $BATTERY_PERC in
|
||||||
no)
|
no)
|
||||||
echo ""
|
echo ""
|
||||||
;;
|
;;
|
||||||
9*)
|
9*)
|
||||||
echo "${FULL_COLOR}${F_C}${F_C}${F_C}${F_C}${F_C}${normal}"
|
echo "${FULL_COLOR}${F_C}${F_C}${F_C}${F_C}${F_C}${normal}"
|
||||||
;;
|
;;
|
||||||
8*)
|
8*)
|
||||||
echo "${FULL_COLOR}${F_C}${F_C}${F_C}${F_C}${HALF_COLOR}${F_C}${normal}"
|
echo "${FULL_COLOR}${F_C}${F_C}${F_C}${F_C}${HALF_COLOR}${F_C}${normal}"
|
||||||
;;
|
;;
|
||||||
7*)
|
7*)
|
||||||
echo "${FULL_COLOR}${F_C}${F_C}${F_C}${F_C}${DEPLETED_COLOR}${D_C}${normal}"
|
echo "${FULL_COLOR}${F_C}${F_C}${F_C}${F_C}${DEPLETED_COLOR}${D_C}${normal}"
|
||||||
;;
|
;;
|
||||||
6*)
|
6*)
|
||||||
echo "${FULL_COLOR}${F_C}${F_C}${F_C}${HALF_COLOR}${F_C}${DEPLETED_COLOR}${D_C}${normal}"
|
echo "${FULL_COLOR}${F_C}${F_C}${F_C}${HALF_COLOR}${F_C}${DEPLETED_COLOR}${D_C}${normal}"
|
||||||
;;
|
;;
|
||||||
5*)
|
5*)
|
||||||
echo "${FULL_COLOR}${F_C}${F_C}${F_C}${DEPLETED_COLOR}${D_C}${D_C}${normal}"
|
echo "${FULL_COLOR}${F_C}${F_C}${F_C}${DEPLETED_COLOR}${D_C}${D_C}${normal}"
|
||||||
;;
|
;;
|
||||||
4*)
|
4*)
|
||||||
echo "${FULL_COLOR}${F_C}${F_C}${HALF_COLOR}${F_C}${DEPLETED_COLOR}${D_C}${D_C}${normal}"
|
echo "${FULL_COLOR}${F_C}${F_C}${HALF_COLOR}${F_C}${DEPLETED_COLOR}${D_C}${D_C}${normal}"
|
||||||
;;
|
;;
|
||||||
3*)
|
3*)
|
||||||
echo "${FULL_COLOR}${F_C}${F_C}${DEPLETED_COLOR}${D_C}${D_C}${D_C}${normal}"
|
echo "${FULL_COLOR}${F_C}${F_C}${DEPLETED_COLOR}${D_C}${D_C}${D_C}${normal}"
|
||||||
;;
|
;;
|
||||||
2*)
|
2*)
|
||||||
echo "${FULL_COLOR}${F_C}${HALF_COLOR}${F_C}${DEPLETED_COLOR}${D_C}${D_C}${D_C}${normal}"
|
echo "${FULL_COLOR}${F_C}${HALF_COLOR}${F_C}${DEPLETED_COLOR}${D_C}${D_C}${D_C}${normal}"
|
||||||
;;
|
;;
|
||||||
1*)
|
1*)
|
||||||
echo "${FULL_COLOR}${F_C}${DEPLETED_COLOR}${D_C}${D_C}${D_C}${D_C}${normal}"
|
echo "${FULL_COLOR}${F_C}${DEPLETED_COLOR}${D_C}${D_C}${D_C}${D_C}${normal}"
|
||||||
;;
|
;;
|
||||||
05)
|
05)
|
||||||
echo "${DANGER_COLOR}${F_C}${DEPLETED_COLOR}${D_C}${D_C}${D_C}${D_C}${normal}"
|
echo "${DANGER_COLOR}${F_C}${DEPLETED_COLOR}${D_C}${D_C}${D_C}${D_C}${normal}"
|
||||||
;;
|
;;
|
||||||
04)
|
04)
|
||||||
echo "${DANGER_COLOR}${F_C}${DEPLETED_COLOR}${D_C}${D_C}${D_C}${D_C}${normal}"
|
echo "${DANGER_COLOR}${F_C}${DEPLETED_COLOR}${D_C}${D_C}${D_C}${D_C}${normal}"
|
||||||
;;
|
;;
|
||||||
03)
|
03)
|
||||||
echo "${DANGER_COLOR}${F_C}${DEPLETED_COLOR}${D_C}${D_C}${D_C}${D_C}${normal}"
|
echo "${DANGER_COLOR}${F_C}${DEPLETED_COLOR}${D_C}${D_C}${D_C}${D_C}${normal}"
|
||||||
;;
|
;;
|
||||||
02)
|
02)
|
||||||
echo "${DANGER_COLOR}${F_C}${DEPLETED_COLOR}${D_C}${D_C}${D_C}${D_C}${normal}"
|
echo "${DANGER_COLOR}${F_C}${DEPLETED_COLOR}${D_C}${D_C}${D_C}${D_C}${normal}"
|
||||||
;;
|
;;
|
||||||
0*)
|
0*)
|
||||||
echo "${HALF_COLOR}${F_C}${DEPLETED_COLOR}${D_C}${D_C}${D_C}${D_C}${normal}"
|
echo "${HALF_COLOR}${F_C}${DEPLETED_COLOR}${D_C}${D_C}${D_C}${D_C}${normal}"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "${DANGER_COLOR}UNPLG${normal}"
|
echo "${DANGER_COLOR}UNPLG${normal}"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,12 +9,9 @@
|
||||||
IRed="\e[1;49;31m"
|
IRed="\e[1;49;31m"
|
||||||
IGreen="\e[1;49;32m"
|
IGreen="\e[1;49;32m"
|
||||||
IYellow="\e[1;49;33m"
|
IYellow="\e[1;49;33m"
|
||||||
ICyan="\e[1;49;36m"
|
|
||||||
IWhite="\e[1;49;37m"
|
IWhite="\e[1;49;37m"
|
||||||
White="\e[0;49;37m"
|
|
||||||
BIWhite="\e[1;49;37m"
|
BIWhite="\e[1;49;37m"
|
||||||
BICyan="\e[1;49;36m"
|
BICyan="\e[1;49;36m"
|
||||||
ResetColor="\e[0;49;37m"
|
|
||||||
|
|
||||||
#############
|
#############
|
||||||
## Symbols ##
|
## Symbols ##
|
||||||
|
|
@ -31,79 +28,79 @@ Face="\342\230\273"
|
||||||
#############
|
#############
|
||||||
|
|
||||||
____atomic_top_left_parse() {
|
____atomic_top_left_parse() {
|
||||||
ifs_old="${IFS}"
|
ifs_old="${IFS}"
|
||||||
IFS="|"
|
IFS="|"
|
||||||
args=( $1 )
|
args=( $1 )
|
||||||
IFS="${ifs_old}"
|
IFS="${ifs_old}"
|
||||||
if [ -n "${args[3]}" ]; then
|
if [ -n "${args[3]}" ]; then
|
||||||
_TOP_LEFT+="${args[2]}${args[3]}"
|
_TOP_LEFT+="${args[2]}${args[3]}"
|
||||||
fi
|
fi
|
||||||
_TOP_LEFT+="${args[0]}${args[1]}"
|
_TOP_LEFT+="${args[0]}${args[1]}"
|
||||||
if [ -n "${args[4]}" ]; then
|
if [ -n "${args[4]}" ]; then
|
||||||
_TOP_LEFT+="${args[2]}${args[4]}"
|
_TOP_LEFT+="${args[2]}${args[4]}"
|
||||||
fi
|
fi
|
||||||
_TOP_LEFT+=""
|
_TOP_LEFT+=""
|
||||||
}
|
}
|
||||||
|
|
||||||
____atomic_top_right_parse() {
|
____atomic_top_right_parse() {
|
||||||
ifs_old="${IFS}"
|
ifs_old="${IFS}"
|
||||||
IFS="|"
|
IFS="|"
|
||||||
args=( $1 )
|
args=( $1 )
|
||||||
IFS="${ifs_old}"
|
IFS="${ifs_old}"
|
||||||
_TOP_RIGHT+=" "
|
_TOP_RIGHT+=" "
|
||||||
if [ -n "${args[3]}" ]; then
|
if [ -n "${args[3]}" ]; then
|
||||||
_TOP_RIGHT+="${args[2]}${args[3]}"
|
_TOP_RIGHT+="${args[2]}${args[3]}"
|
||||||
fi
|
fi
|
||||||
_TOP_RIGHT+="${args[0]}${args[1]}"
|
_TOP_RIGHT+="${args[0]}${args[1]}"
|
||||||
if [ -n "${args[4]}" ]; then
|
if [ -n "${args[4]}" ]; then
|
||||||
_TOP_RIGHT+="${args[2]}${args[4]}"
|
_TOP_RIGHT+="${args[2]}${args[4]}"
|
||||||
fi
|
fi
|
||||||
__TOP_RIGHT_LEN=$(( __TOP_RIGHT_LEN + ${#args[1]} + ${#args[3]} + ${#args[4]} + 1 ))
|
__TOP_RIGHT_LEN=$(( __TOP_RIGHT_LEN + ${#args[1]} + ${#args[3]} + ${#args[4]} + 1 ))
|
||||||
(( __SEG_AT_RIGHT += 1 ))
|
(( __SEG_AT_RIGHT += 1 ))
|
||||||
}
|
}
|
||||||
|
|
||||||
____atomic_bottom_parse() {
|
____atomic_bottom_parse() {
|
||||||
ifs_old="${IFS}"
|
ifs_old="${IFS}"
|
||||||
IFS="|"
|
IFS="|"
|
||||||
args=( $1 )
|
args=( $1 )
|
||||||
IFS="${ifs_old}"
|
IFS="${ifs_old}"
|
||||||
_BOTTOM+="${args[0]}${args[1]}"
|
_BOTTOM+="${args[0]}${args[1]}"
|
||||||
[ ${#args[1]} -gt 0 ] && _BOTTOM+=" "
|
[ ${#args[1]} -gt 0 ] && _BOTTOM+=" "
|
||||||
}
|
}
|
||||||
|
|
||||||
____atomic_top() {
|
____atomic_top() {
|
||||||
_TOP_LEFT=""
|
_TOP_LEFT=""
|
||||||
_TOP_RIGHT=""
|
_TOP_RIGHT=""
|
||||||
__TOP_RIGHT_LEN=0
|
__TOP_RIGHT_LEN=0
|
||||||
__SEG_AT_RIGHT=0
|
__SEG_AT_RIGHT=0
|
||||||
|
|
||||||
for seg in ${___ATOMIC_TOP_LEFT}; do
|
for seg in ${___ATOMIC_TOP_LEFT}; do
|
||||||
info="$(___atomic_prompt_"${seg}")"
|
info="$(___atomic_prompt_"${seg}")"
|
||||||
[ -n "${info}" ] && ____atomic_top_left_parse "${info}"
|
[ -n "${info}" ] && ____atomic_top_left_parse "${info}"
|
||||||
done
|
done
|
||||||
|
|
||||||
___cursor_right="\e[500C"
|
___cursor_right="\e[500C"
|
||||||
_TOP_LEFT+="${___cursor_right}"
|
_TOP_LEFT+="${___cursor_right}"
|
||||||
|
|
||||||
for seg in ${___ATOMIC_TOP_RIGHT}; do
|
for seg in ${___ATOMIC_TOP_RIGHT}; do
|
||||||
info="$(___atomic_prompt_"${seg}")"
|
info="$(___atomic_prompt_"${seg}")"
|
||||||
[ -n "${info}" ] && ____atomic_top_right_parse "${info}"
|
[ -n "${info}" ] && ____atomic_top_right_parse "${info}"
|
||||||
done
|
done
|
||||||
|
|
||||||
[ $__TOP_RIGHT_LEN -gt 0 ] && __TOP_RIGHT_LEN=$(( __TOP_RIGHT_LEN - 0 ))
|
[ $__TOP_RIGHT_LEN -gt 0 ] && __TOP_RIGHT_LEN=$(( __TOP_RIGHT_LEN - 0 ))
|
||||||
___cursor_adjust="\e[${__TOP_RIGHT_LEN}D"
|
___cursor_adjust="\e[${__TOP_RIGHT_LEN}D"
|
||||||
_TOP_LEFT+="${___cursor_adjust}"
|
_TOP_LEFT+="${___cursor_adjust}"
|
||||||
|
|
||||||
printf "%s%s" "${_TOP_LEFT}" "${_TOP_RIGHT}"
|
printf "%s%s" "${_TOP_LEFT}" "${_TOP_RIGHT}"
|
||||||
}
|
}
|
||||||
|
|
||||||
____atomic_bottom() {
|
____atomic_bottom() {
|
||||||
_BOTTOM=""
|
_BOTTOM=""
|
||||||
for seg in $___ATOMIC_BOTTOM; do
|
for seg in $___ATOMIC_BOTTOM; do
|
||||||
info="$(___atomic_prompt_"${seg}")"
|
info="$(___atomic_prompt_"${seg}")"
|
||||||
[ -n "${info}" ] && ____atomic_bottom_parse "${info}"
|
[ -n "${info}" ] && ____atomic_bottom_parse "${info}"
|
||||||
done
|
done
|
||||||
printf "\n%s" "${_BOTTOM}"
|
printf "\n%s" "${_BOTTOM}"
|
||||||
}
|
}
|
||||||
|
|
||||||
##############
|
##############
|
||||||
|
|
@ -111,95 +108,95 @@ ____atomic_bottom() {
|
||||||
##############
|
##############
|
||||||
|
|
||||||
___atomic_prompt_user_info() {
|
___atomic_prompt_user_info() {
|
||||||
color=$white
|
color=$white
|
||||||
box="${normal}${LineA}\$([[ \$? != 0 ]] && echo \"${BIWhite}[${IRed}${SX}${BIWhite}]${normal}${Line}\")${Line}${BIWhite}[|${BIWhite}]${normal}${Line}"
|
box="${normal}${LineA}\$([[ \$? != 0 ]] && echo \"${BIWhite}[${IRed}${SX}${BIWhite}]${normal}${Line}\")${Line}${BIWhite}[|${BIWhite}]${normal}${Line}"
|
||||||
info="${IYellow}\u${IRed}@${IGreen}\h"
|
info="${IYellow}\u${IRed}@${IGreen}\h"
|
||||||
|
|
||||||
printf "%s|%s|%s|%s" "${color}" "${info}" "${white}" "${box}"
|
printf "%s|%s|%s|%s" "${color}" "${info}" "${white}" "${box}"
|
||||||
}
|
}
|
||||||
|
|
||||||
___atomic_prompt_dir() {
|
___atomic_prompt_dir() {
|
||||||
color=${IRed}
|
color=${IRed}
|
||||||
box="[|]${normal}${Line}"
|
box="[|]${normal}${Line}"
|
||||||
info="\w"
|
info="\w"
|
||||||
printf "%s|%s|%s|%s" "${color}" "${info}" "${bold_white}" "${box}"
|
printf "%s|%s|%s|%s" "${color}" "${info}" "${bold_white}" "${box}"
|
||||||
}
|
}
|
||||||
|
|
||||||
___atomic_prompt_scm() {
|
___atomic_prompt_scm() {
|
||||||
[ "${THEME_SHOW_SCM}" != "true" ] && return
|
[ "${THEME_SHOW_SCM}" != "true" ] && return
|
||||||
color=$bold_green
|
color=$bold_green
|
||||||
box="[${IWhite}$(scm_char)] "
|
box="[${IWhite}$(scm_char)] "
|
||||||
info="$(scm_prompt_info)"
|
info="$(scm_prompt_info)"
|
||||||
printf "%s|%s|%s|%s" "${color}" "${info}" "${bold_white}" "${box}"
|
printf "%s|%s|%s|%s" "${color}" "${info}" "${bold_white}" "${box}"
|
||||||
}
|
}
|
||||||
|
|
||||||
___atomic_prompt_python() {
|
___atomic_prompt_python() {
|
||||||
[ "${THEME_SHOW_PYTHON}" != "true" ] && return
|
[ "${THEME_SHOW_PYTHON}" != "true" ] && return
|
||||||
color=$bold_yellow
|
color=$bold_yellow
|
||||||
box="[|]"
|
box="[|]"
|
||||||
info="$(python_version_prompt)"
|
info="$(python_version_prompt)"
|
||||||
printf "%s|%s|%s|%s" "${color}" "${info}" "${bold_blue}" "${box}"
|
printf "%s|%s|%s|%s" "${color}" "${info}" "${bold_blue}" "${box}"
|
||||||
}
|
}
|
||||||
|
|
||||||
___atomic_prompt_ruby() {
|
___atomic_prompt_ruby() {
|
||||||
[ "${THEME_SHOW_RUBY}" != "true" ] && return
|
[ "${THEME_SHOW_RUBY}" != "true" ] && return
|
||||||
color=$bold_white
|
color=$bold_white
|
||||||
box="[|]"
|
box="[|]"
|
||||||
info="rb-$(ruby_version_prompt)"
|
info="rb-$(ruby_version_prompt)"
|
||||||
printf "%s|%s|%s|%s" "${color}" "${info}" "${bold_red}" "${box}"
|
printf "%s|%s|%s|%s" "${color}" "${info}" "${bold_red}" "${box}"
|
||||||
}
|
}
|
||||||
|
|
||||||
___atomic_prompt_todo() {
|
___atomic_prompt_todo() {
|
||||||
[ "${THEME_SHOW_TODO}" != "true" ] ||
|
[ "${THEME_SHOW_TODO}" != "true" ] ||
|
||||||
[ -z "$(which todo.sh)" ] && return
|
[ -z "$(which todo.sh)" ] && return
|
||||||
color=$bold_white
|
color=$bold_white
|
||||||
box="[|]"
|
box="[|]"
|
||||||
info="t:$(todo.sh ls | egrep "TODO: [0-9]+ of ([0-9]+)" | awk '{ print $4 }' )"
|
info="t:$(todo.sh ls | egrep "TODO: [0-9]+ of ([0-9]+)" | awk '{ print $4 }' )"
|
||||||
printf "%s|%s|%s|%s" "${color}" "${info}" "${bold_green}" "${box}"
|
printf "%s|%s|%s|%s" "${color}" "${info}" "${bold_green}" "${box}"
|
||||||
}
|
}
|
||||||
|
|
||||||
___atomic_prompt_clock() {
|
___atomic_prompt_clock() {
|
||||||
[ "${THEME_SHOW_CLOCK}" != "true" ] && return
|
[ "${THEME_SHOW_CLOCK}" != "true" ] && return
|
||||||
color=$THEME_CLOCK_COLOR
|
color=$THEME_CLOCK_COLOR
|
||||||
box="[|]"
|
box="[|]"
|
||||||
info="$(date +"${THEME_CLOCK_FORMAT}")"
|
info="$(date +"${THEME_CLOCK_FORMAT}")"
|
||||||
printf "%s|%s|%s|%s" "${color}" "${info}" "${bold_white}" "${box}"
|
printf "%s|%s|%s|%s" "${color}" "${info}" "${bold_white}" "${box}"
|
||||||
}
|
}
|
||||||
|
|
||||||
___atomic_prompt_battery() {
|
___atomic_prompt_battery() {
|
||||||
[ ! -e "$BASH_IT"/plugins/enabled/battery.plugin.bash ] ||
|
chk=$(command_exists battery_percentage && echo yes || echo no)
|
||||||
[ "${THEME_SHOW_BATTERY}" != "true" ] && return
|
[ "$chk" != "yes" ] || [ "${THEME_SHOW_BATTERY}" != "true" ] && return
|
||||||
batp=$(battery_percentage)
|
batp=$(battery_percentage)
|
||||||
if [ "$batp" -gt 50 ]; then
|
if [ "$batp" -eq 50 ] || [ "$batp" -gt 50 ]; then
|
||||||
color=$bold_green
|
color=$bold_green
|
||||||
elif [ "$batp" -lt 50 ] && [ "$batp" -gt 25 ]; then
|
elif [ "$batp" -lt 50 ] && [ "$batp" -gt 25 ]; then
|
||||||
color=$bold_yellow
|
color=$bold_yellow
|
||||||
elif [ "$batp" -lt 25 ]; then
|
elif [ "$batp" -eq 25 ] || [ "$batp" -lt 25 ]; then
|
||||||
color=$IRed
|
color=$IRed
|
||||||
fi
|
fi
|
||||||
box="[|]"
|
box="[|]"
|
||||||
ac_adapter_disconnected && info="-"
|
ac_adapter_disconnected && info="-"
|
||||||
ac_adapter_connected && info="+"
|
ac_adapter_connected && info="+"
|
||||||
info+=$batp
|
info+=$batp
|
||||||
[ "$info" == "+100" ] && info="AC"
|
[ "$info" == "+100" ] && info="AC"
|
||||||
printf "%s|%s|%s|%s" "${color}" "${info}" "${bold_white}" "${box}"
|
printf "%s|%s|%s|%s" "${color}" "${info}" "${bold_white}" "${box}"
|
||||||
}
|
}
|
||||||
|
|
||||||
___atomic_prompt_exitcode() {
|
___atomic_prompt_exitcode() {
|
||||||
[ "${THEME_SHOW_EXITCODE}" != "true" ] && return
|
[ "${THEME_SHOW_EXITCODE}" != "true" ] && return
|
||||||
color=$bold_purple
|
color=$bold_purple
|
||||||
[ "$exitcode" -ne 0 ] && printf "%s|%s" "${color}" "${exitcode}"
|
[ "$exitcode" -ne 0 ] && printf "%s|%s" "${color}" "${exitcode}"
|
||||||
}
|
}
|
||||||
|
|
||||||
___atomic_prompt_char() {
|
___atomic_prompt_char() {
|
||||||
color=$white
|
color=$white
|
||||||
prompt_char="${__ATOMIC_PROMPT_CHAR_PS1}"
|
prompt_char="${__ATOMIC_PROMPT_CHAR_PS1}"
|
||||||
if [ "${THEME_SHOW_SUDO}" == "true" ]; then
|
if [ "${THEME_SHOW_SUDO}" == "true" ]; then
|
||||||
if [ $(sudo -n id -u 2>&1 | grep 0) ]; then
|
if [ $(sudo -n id -u 2>&1 | grep 0) ]; then
|
||||||
prompt_char="${__ATOMIC_PROMPT_CHAR_PS1_SUDO}"
|
prompt_char="${__ATOMIC_PROMPT_CHAR_PS1_SUDO}"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
printf "%s|%s" "${color}" "${prompt_char}"
|
printf "%s|%s" "${color}" "${prompt_char}"
|
||||||
}
|
}
|
||||||
|
|
||||||
#########
|
#########
|
||||||
|
|
@ -208,53 +205,53 @@ ___atomic_prompt_char() {
|
||||||
|
|
||||||
__atomic_show() {
|
__atomic_show() {
|
||||||
typeset _seg=${1:-}
|
typeset _seg=${1:-}
|
||||||
shift
|
shift
|
||||||
export THEME_SHOW_${_seg}=true
|
export THEME_SHOW_${_seg}=true
|
||||||
}
|
}
|
||||||
|
|
||||||
__atomic_hide() {
|
__atomic_hide() {
|
||||||
typeset _seg=${1:-}
|
typeset _seg=${1:-}
|
||||||
shift
|
shift
|
||||||
export THEME_SHOW_${_seg}=false
|
export THEME_SHOW_${_seg}=false
|
||||||
}
|
}
|
||||||
|
|
||||||
_atomic_completion() {
|
_atomic_completion() {
|
||||||
local cur _action actions segments
|
local cur _action actions segments
|
||||||
COMPREPLY=()
|
COMPREPLY=()
|
||||||
cur="${COMP_WORDS[COMP_CWORD]}"
|
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||||
_action="${COMP_WORDS[1]}"
|
_action="${COMP_WORDS[1]}"
|
||||||
actions="show hide"
|
actions="show hide"
|
||||||
segments="battery clock exitcode python ruby scm sudo todo"
|
segments="battery clock exitcode python ruby scm sudo todo"
|
||||||
case "${_action}" in
|
case "${_action}" in
|
||||||
show)
|
show)
|
||||||
COMPREPLY=( $(compgen -W "${segments}" -- "${cur}") )
|
COMPREPLY=( $(compgen -W "${segments}" -- "${cur}") )
|
||||||
return 0
|
return 0
|
||||||
;;
|
;;
|
||||||
hide)
|
hide)
|
||||||
COMPREPLY=( $(compgen -W "${segments}" -- "${cur}") )
|
COMPREPLY=( $(compgen -W "${segments}" -- "${cur}") )
|
||||||
return 0
|
return 0
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
COMPREPLY=( $(compgen -W "${actions}" -- "${cur}") )
|
COMPREPLY=( $(compgen -W "${actions}" -- "${cur}") )
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
atomic() {
|
atomic() {
|
||||||
typeset action=${1:-}
|
typeset action=${1:-}
|
||||||
shift
|
shift
|
||||||
typeset segs=${*:-}
|
typeset segs=${*:-}
|
||||||
typeset func
|
typeset func
|
||||||
case $action in
|
case $action in
|
||||||
show)
|
show)
|
||||||
func=__atomic_show;;
|
func=__atomic_show;;
|
||||||
hide)
|
hide)
|
||||||
func=__atomic_hide;;
|
func=__atomic_hide;;
|
||||||
esac
|
esac
|
||||||
for seg in ${segs}; do
|
for seg in ${segs}; do
|
||||||
seg=$(printf "%s" "${seg}" | tr '[:lower:]' '[:upper:]')
|
seg=$(printf "%s" "${seg}" | tr '[:lower:]' '[:upper:]')
|
||||||
$func "${seg}"
|
$func "${seg}"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
complete -F _atomic_completion atomic
|
complete -F _atomic_completion atomic
|
||||||
|
|
@ -303,19 +300,19 @@ ___ATOMIC_BOTTOM=${___ATOMIC_BOTTOM:-"char"}
|
||||||
############
|
############
|
||||||
|
|
||||||
__atomic_ps1() {
|
__atomic_ps1() {
|
||||||
printf "%s%s%s" "$(____atomic_top)" "$(____atomic_bottom)" "${normal}"
|
printf "%s%s%s" "$(____atomic_top)" "$(____atomic_bottom)" "${normal}"
|
||||||
}
|
}
|
||||||
|
|
||||||
__atomic_ps2() {
|
__atomic_ps2() {
|
||||||
color=$bold_white
|
color=$bold_white
|
||||||
printf "%s%s%s" "${color}" "${__ATOMIC_PROMPT_CHAR_PS2} " "${normal}"
|
printf "%s%s%s" "${color}" "${__ATOMIC_PROMPT_CHAR_PS2} " "${normal}"
|
||||||
}
|
}
|
||||||
|
|
||||||
_atomic_prompt() {
|
_atomic_prompt() {
|
||||||
exitcode="$?"
|
exitcode="$?"
|
||||||
|
|
||||||
PS1="$(__atomic_ps1)"
|
PS1="$(__atomic_ps1)"
|
||||||
PS2="$(__atomic_ps2)"
|
PS2="$(__atomic_ps2)"
|
||||||
}
|
}
|
||||||
|
|
||||||
safe_append_prompt_command _atomic_prompt
|
safe_append_prompt_command _atomic_prompt
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue