Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
O
oh-my-zsh
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
github
oh-my-zsh
Commits
0dc40e88
Unverified
Commit
0dc40e88
authored
Sep 02, 2023
by
not pua
Committed by
GitHub
Sep 02, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(battery): add support for OpenBSD (#11872)
parent
ccce2e1c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
0 deletions
+44
-0
battery.plugin.zsh
plugins/battery/battery.plugin.zsh
+44
-0
No files found.
plugins/battery/battery.plugin.zsh
View file @
0dc40e88
...
@@ -13,6 +13,10 @@
...
@@ -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]} )
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment