File tree Expand file tree Collapse file tree 4 files changed +43
-1
lines changed Expand file tree Collapse file tree 4 files changed +43
-1
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,10 @@ print_graph() {
22
22
23
23
main () {
24
24
local percentage=$( $CURRENT_DIR /battery_percentage.sh)
25
- print_graph ${percentage% ?}
25
+ if [ " $( uname) " == " OpenBSD" ]; then
26
+ print_graph ${percentage}
27
+ else
28
+ print_graph ${percentage% ?}
29
+ fi
26
30
}
27
31
main
Original file line number Diff line number Diff line change @@ -30,6 +30,8 @@ print_battery_percentage() {
30
30
acpi -b | grep -m 1 -Eo " [0-9]+%"
31
31
elif command_exists " termux-battery-status" ; then
32
32
termux-battery-status | jq -r ' .percentage' | awk ' {printf("%d%%", $1)}'
33
+ elif command_exists " apm" ; then
34
+ apm -l
33
35
fi
34
36
}
35
37
Original file line number Diff line number Diff line change @@ -20,6 +20,32 @@ battery_charged() {
20
20
[[ $status =~ (charged) ]]
21
21
}
22
22
23
+
24
+ convertmins () {
25
+ (( h= ${1} / 60 ))
26
+ (( m= ${1} % 60 ))
27
+ printf " %02d:%02d\n" $h $m $s
28
+ }
29
+
30
+ apm_battery_remaining_time () {
31
+ local remaining_time=" $( convertmins $( apm -m) ) "
32
+ if battery_discharging; then
33
+ if $short ; then
34
+ echo $remaining_time | awk ' {printf "~%s", $1}'
35
+ else
36
+ echo $remaining_time | awk ' {printf "- %s left", $1}'
37
+ fi
38
+ elif battery_charged; then
39
+ if $short ; then
40
+ echo $remaining_time | awk ' {printf "charged", $1}'
41
+ else
42
+ echo $remaining_time | awk ' {printf "fully charged", $1}'
43
+ fi
44
+ else
45
+ echo " charging"
46
+ fi
47
+ }
48
+
23
49
pmset_battery_remaining_time () {
24
50
local status=" $( pmset -g batt) "
25
51
if echo $status | grep ' no estimate' > /dev/null 2>&1 ; then
@@ -90,6 +116,8 @@ print_battery_remain() {
90
116
upower_battery_remaining_time
91
117
elif command_exists " acpi" ; then
92
118
acpi_battery_remaining_time
119
+ elif command_exists " apm" ; then
120
+ apm_battery_remaining_time
93
121
fi
94
122
}
95
123
Original file line number Diff line number Diff line change @@ -38,5 +38,13 @@ battery_status() {
38
38
acpi -b | awk ' {gsub(/,/, ""); print tolower($3); exit}'
39
39
elif command_exists " termux-battery-status" ; then
40
40
termux-battery-status | jq -r ' .status' | awk ' {printf("%s%", tolower($1))}'
41
+ elif command_exists " apm" ; then
42
+ local battery
43
+ battery=$( apm -a)
44
+ if [ $battery -eq 0 ]; then
45
+ echo " discharging"
46
+ elif [ $battery -eq 1 ]; then
47
+ echo " charging"
48
+ fi
41
49
fi
42
50
}
You can’t perform that action at this time.
0 commit comments