Haiku: Added battery support
This commit is contained in:
parent
342942e727
commit
68a14e5b1f
85
neofetch
85
neofetch
|
@ -310,53 +310,54 @@ getuptime() {
|
||||||
uptime="$(uptime -u)"
|
uptime="$(uptime -u)"
|
||||||
uptime="${uptime/up }"
|
uptime="${uptime/up }"
|
||||||
;;
|
;;
|
||||||
*)
|
|
||||||
# Get uptime in seconds
|
|
||||||
case "$os" in
|
|
||||||
"Linux" | "Windows")
|
|
||||||
seconds="$(< /proc/uptime)"
|
|
||||||
seconds="${seconds/.*}"
|
|
||||||
;;
|
|
||||||
|
|
||||||
"Mac OS X" | "iPhone OS" | "BSD")
|
*)
|
||||||
boot="$(sysctl -n kern.boottime)"
|
# Get uptime in seconds
|
||||||
boot="${boot/'{ sec = '}"
|
case "$os" in
|
||||||
boot="${boot/,*}"
|
"Linux" | "Windows")
|
||||||
|
seconds="$(< /proc/uptime)"
|
||||||
|
seconds="${seconds/.*}"
|
||||||
|
;;
|
||||||
|
|
||||||
# Get current date in seconds
|
"Mac OS X" | "iPhone OS" | "BSD")
|
||||||
now="$(date +%s)"
|
boot="$(sysctl -n kern.boottime)"
|
||||||
seconds="$((now - boot))"
|
boot="${boot/'{ sec = '}"
|
||||||
;;
|
boot="${boot/,*}"
|
||||||
|
|
||||||
"Solaris")
|
# Get current date in seconds
|
||||||
seconds="$(kstat -p unix:0:system_misc:snaptime | awk '{print $2}')"
|
now="$(date +%s)"
|
||||||
seconds="${seconds/.*}"
|
seconds="$((now - boot))"
|
||||||
;;
|
;;
|
||||||
esac
|
|
||||||
|
|
||||||
days="$((seconds / 60 / 60 / 24)) days"
|
"Solaris")
|
||||||
hours="$((seconds / 60 / 60 % 24)) hours"
|
seconds="$(kstat -p unix:0:system_misc:snaptime | awk '{print $2}')"
|
||||||
minutes="$((seconds / 60 % 60)) minutes"
|
seconds="${seconds/.*}"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
case "$days" in
|
days="$((seconds / 60 / 60 / 24)) days"
|
||||||
"0 days") unset days ;;
|
hours="$((seconds / 60 / 60 % 24)) hours"
|
||||||
"1 days") days="${days/s}" ;;
|
minutes="$((seconds / 60 % 60)) minutes"
|
||||||
esac
|
|
||||||
|
|
||||||
case "$hours" in
|
case "$days" in
|
||||||
"0 hours") unset hours ;;
|
"0 days") unset days ;;
|
||||||
"1 hours") hours="${hours/s}" ;;
|
"1 days") days="${days/s}" ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
case "$minutes" in
|
case "$hours" in
|
||||||
"0 minutes") unset minutes ;;
|
"0 hours") unset hours ;;
|
||||||
"1 minutes") minutes="${minutes/s}" ;;
|
"1 hours") hours="${hours/s}" ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
uptime="${days:+$days, }${hours:+$hours, }${minutes}"
|
case "$minutes" in
|
||||||
uptime="${uptime%', '}"
|
"0 minutes") unset minutes ;;
|
||||||
uptime="${uptime:-${seconds} seconds}"
|
"1 minutes") minutes="${minutes/s}" ;;
|
||||||
;;
|
esac
|
||||||
|
|
||||||
|
uptime="${days:+$days, }${hours:+$hours, }${minutes}"
|
||||||
|
uptime="${uptime%', '}"
|
||||||
|
uptime="${uptime:-${seconds} seconds}"
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# Make the output of uptime smaller.
|
# Make the output of uptime smaller.
|
||||||
|
@ -1735,6 +1736,12 @@ getbattery() {
|
||||||
[ "$battery" ] && \
|
[ "$battery" ] && \
|
||||||
battery+="%"
|
battery+="%"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
"Haiku")
|
||||||
|
battery0full="$(awk -F '[^0-9]*' 'NR==2 {print $4}' /dev/power/acpi_battery/0)"
|
||||||
|
battery0now="$(awk -F '[^0-9]*' 'NR==5 {print $4}' /dev/power/acpi_battery/0)"
|
||||||
|
battery="$((battery0full / battery0now * 100))%"
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
case "$battery_state" in
|
case "$battery_state" in
|
||||||
|
|
Reference in New Issue