NetBSD battery power, ipv6
This commit is contained in:
parent
614b0ad4e0
commit
90e8c6cdf0
@ -3,8 +3,11 @@
|
||||
set -e
|
||||
|
||||
# depends on https://git.sr.ht/~trinity/utilities (particularly fdivide(1),
|
||||
# gt(1), and stris(1)) unless POSIXLY_CORRECT is set (not tested)
|
||||
# gt(1), and stris(1))
|
||||
# there are issues with the POSIX shell implementations included in this script
|
||||
# and particularly with stris
|
||||
|
||||
# on Linux only:
|
||||
# these files (separated by newlines) will have the current CPU temperature
|
||||
# multiplied by $CPU_TEMP_SCALE. this script divides the file contents by scale
|
||||
# and displays that temperature (assumed to be in Celsius units)
|
||||
@ -28,7 +31,11 @@ INTERVAL=1
|
||||
|
||||
# this URL will have in plain text the public IP address from which it was
|
||||
# accessed
|
||||
PUBLIC_IP_FETCH_URL="http://ifconfig.io/"
|
||||
#PUBLIC_IP_FETCH_URL="http://ifconfig.io/"
|
||||
#PUBLIC_IP_FETCH_URL="https://ifconfig.io"
|
||||
#PUBLIC_IP_FETCH_URL="http://icanhazip.com"
|
||||
PUBLIC_IP_FETCH_URL="https://icanhazip.com"
|
||||
PUBLIC_IP6_FETCH_URL="$PUBLIC_IP_FETCH_URL"
|
||||
|
||||
get_battery_status() {
|
||||
if [ "$(uname)" = "Linux" ]; then
|
||||
@ -38,6 +45,15 @@ get_battery_status() {
|
||||
# acpi -a will just print the power adapter status.
|
||||
printf "%b" "$(acpi | awk '{print $4}' | sed 's/,$//') ($(acpi -a))"
|
||||
return
|
||||
elif [ "$(uname)" = "NetBSD" ]; then
|
||||
printf "%b%%" "$(envstat -s acpibat0:charge \
|
||||
| sed 1,2d \
|
||||
| cut -d ':' -f 2 \
|
||||
| awk '{print $1}' \
|
||||
| cut -d '.' -f 1)"
|
||||
return
|
||||
else
|
||||
printf "get_battery_status: unsupported OS"
|
||||
fi
|
||||
}
|
||||
|
||||
@ -60,6 +76,9 @@ get_cpu_temp() {
|
||||
| cut -d ':' -f 2 \
|
||||
| awk '{print $1}' \
|
||||
| cut -d '.' -f 1)"
|
||||
return
|
||||
else
|
||||
printf "get_cpu_temp: unsupported OS"
|
||||
fi
|
||||
}
|
||||
|
||||
@ -79,8 +98,19 @@ get_memory_usage() {
|
||||
}
|
||||
|
||||
get_public_ip() {
|
||||
curl "$PUBLIC_IP_FETCH_URL" --no-progress-meter 2>/dev/null \
|
||||
|| printf "[error fetching IP]\n"
|
||||
PUBLIC_IP4="$(curl "$PUBLIC_IP_FETCH_URL" --no-progress-meter 2>/dev/null \
|
||||
|| printf "-1")"
|
||||
PUBLIC_IP6="$(curl -6 "$PUBLIC_IP6_FETCH_URL" --no-progress-meter 2>/dev/null \
|
||||
|| printf "-1")"
|
||||
if [ "$PUBLIC_IP4" = "-1" ] && [ "$PUBLIC_IP6" = "-1" ]; then
|
||||
printf "[error fetching address]"
|
||||
elif [ "$PUBLIC_IP4" = "-1" ]; then
|
||||
printf "%b" "$PUBLIC_IP6"
|
||||
elif [ "$PUBLIC_IP6" = "-1" ]; then
|
||||
printf "%b" "$PUBLIC_IP4"
|
||||
else
|
||||
printf "%b / %b" "$PUBLIC_IP4" "$PUBLIC_IP6"
|
||||
fi
|
||||
return
|
||||
}
|
||||
|
||||
@ -90,8 +120,8 @@ PUBLIC_IP="$(get_public_ip)"
|
||||
printbar() {
|
||||
printf "%b" "$(get_current_desktop)"
|
||||
printf "%b" "$(date)"
|
||||
#printf "%b" "$DELIMITER"
|
||||
#printf "%b" "BAT: $(get_battery_status)"
|
||||
printf "%b" "$DELIMITER"
|
||||
printf "%b" "BAT: $(get_battery_status)"
|
||||
printf "%b" "$DELIMITER"
|
||||
printf "%b" "CPU: $(get_cpu_temp)"
|
||||
printf "%b" "$DELIMITER"
|
||||
|
Loading…
Reference in New Issue
Block a user