mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2024-11-25 17:23:35 +01:00
feat(battery): add support for OpenBSD (#11872)
This commit is contained in:
parent
ccce2e1cfd
commit
0dc40e88a3
@ -13,6 +13,10 @@
|
|||||||
# Author: Avneet Singh (kalsi-avneet) #
|
# Author: Avneet Singh (kalsi-avneet) #
|
||||||
# Modified to add support for Android #
|
# Modified to add support for Android #
|
||||||
###########################################
|
###########################################
|
||||||
|
# Author: Not Pua (im-notpua) #
|
||||||
|
# Modified to add support for OpenBSD #
|
||||||
|
###########################################
|
||||||
|
|
||||||
|
|
||||||
if [[ "$OSTYPE" = darwin* ]]; then
|
if [[ "$OSTYPE" = darwin* ]]; then
|
||||||
function battery_is_charging() {
|
function battery_is_charging() {
|
||||||
@ -139,6 +143,46 @@ elif [[ "$OSTYPE" = linux-android ]] && (( ${+commands[termux-battery-status]} )
|
|||||||
echo "%{$fg[$color]%}${battery_pct}%%%{$reset_color%}"
|
echo "%{$fg[$color]%}${battery_pct}%%%{$reset_color%}"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
elif [[ "$OSTYPE" = openbsd* ]]; then
|
||||||
|
function battery_is_charging() {
|
||||||
|
[[ $(apm -b) -eq 3 ]]
|
||||||
|
}
|
||||||
|
function battery_pct() {
|
||||||
|
apm -l
|
||||||
|
}
|
||||||
|
function battery_pct_remaining() {
|
||||||
|
if ! battery_is_charging; then
|
||||||
|
battery_pct
|
||||||
|
else
|
||||||
|
echo "External Power"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
function battery_time_remaining() {
|
||||||
|
local remaining_time
|
||||||
|
remaining_time=$(apm -m)
|
||||||
|
if [[ $remaining_time -ge 0 ]]; then
|
||||||
|
((hour = $remaining_time / 60 ))
|
||||||
|
((minute = $remaining_time % 60 ))
|
||||||
|
printf %02d:%02d $hour $minute
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
function battery_pct_prompt() {
|
||||||
|
local battery_pct color
|
||||||
|
battery_pct=$(battery_pct_remaining)
|
||||||
|
if battery_is_charging; then
|
||||||
|
echo "∞"
|
||||||
|
else
|
||||||
|
if [[ $battery_pct -gt 50 ]]; then
|
||||||
|
color='green'
|
||||||
|
elif [[ $battery_pct -gt 20 ]]; then
|
||||||
|
color='yellow'
|
||||||
|
else
|
||||||
|
color='red'
|
||||||
|
fi
|
||||||
|
echo "%{$fg[$color]%}${battery_pct}%%%{$reset_color%}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
elif [[ "$OSTYPE" = linux* ]]; then
|
elif [[ "$OSTYPE" = linux* ]]; then
|
||||||
function battery_is_charging() {
|
function battery_is_charging() {
|
||||||
if (( $+commands[acpitool] )); then
|
if (( $+commands[acpitool] )); then
|
||||||
|
Loading…
Reference in New Issue
Block a user