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() {
2222
2323main () {
2424 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
2630}
2731main
Original file line number Diff line number Diff line change @@ -30,6 +30,8 @@ print_battery_percentage() {
3030 acpi -b | grep -m 1 -Eo " [0-9]+%"
3131 elif command_exists " termux-battery-status" ; then
3232 termux-battery-status | jq -r ' .percentage' | awk ' {printf("%d%%", $1)}'
33+ elif command_exists " apm" ; then
34+ apm -l
3335 fi
3436}
3537
Original file line number Diff line number Diff line change @@ -20,6 +20,32 @@ battery_charged() {
2020 [[ $status =~ (charged) ]]
2121}
2222
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+
2349pmset_battery_remaining_time () {
2450 local status=" $( pmset -g batt) "
2551 if echo $status | grep ' no estimate' > /dev/null 2>&1 ; then
@@ -90,6 +116,8 @@ print_battery_remain() {
90116 upower_battery_remaining_time
91117 elif command_exists " acpi" ; then
92118 acpi_battery_remaining_time
119+ elif command_exists " apm" ; then
120+ apm_battery_remaining_time
93121 fi
94122}
95123
Original file line number Diff line number Diff line change @@ -38,5 +38,13 @@ battery_status() {
3838 acpi -b | awk ' {gsub(/,/, ""); print tolower($3); exit}'
3939 elif command_exists " termux-battery-status" ; then
4040 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
4149 fi
4250}
You can’t perform that action at this time.
0 commit comments