NetBSD support and stuff
This commit is contained in:
parent
1cc0c3418e
commit
5abeb68097
@ -15,6 +15,8 @@ CPU_TEMP_SCALE=1000
|
||||
# format for the date (by default in this script, ISO 8601)
|
||||
alias date="date '+%Y-%m-%dT%T'"
|
||||
|
||||
DELIMITER=" || "
|
||||
|
||||
# how fast to refresh the display (in seconds, will be substituted with 1 if
|
||||
# not an integer)
|
||||
INTERVAL=1
|
||||
@ -29,15 +31,18 @@ INTERVAL=1
|
||||
PUBLIC_IP_FETCH_URL="http://ifconfig.io/"
|
||||
|
||||
get_battery_status() {
|
||||
if [ "$(uname)" = "Linux" ]; then
|
||||
# this is a dirty hack.
|
||||
# acpi | awk '{print $4}' will print the battery percentage,
|
||||
# and s/,$// strips the trailing comma.
|
||||
# acpi -a will just print the power adapter status.
|
||||
printf "%b" "$(acpi | awk '{print $4}' | sed 's/,$//') ($(acpi -a))"
|
||||
return
|
||||
fi
|
||||
}
|
||||
|
||||
get_cpu_temp() {
|
||||
if [ "$(uname)" = "Linux" ]; then
|
||||
RETVAL=""
|
||||
# iterate over files, adjust, print out "%dC "
|
||||
for file in $CPU_TEMP_FILES;
|
||||
@ -49,13 +54,28 @@ get_cpu_temp() {
|
||||
printf "%b" "$RETVAL" \
|
||||
| python -c "from sys import stdin; print(stdin.read().rstrip() + '\n')"
|
||||
return
|
||||
elif [ "$(uname)" = "NetBSD" ]; then
|
||||
printf "%bC" "$(envstat -s coretemp0:'cpu0 temperature' \
|
||||
| sed 1,2d \
|
||||
| cut -d ':' -f 2 \
|
||||
| awk '{print $1}' \
|
||||
| cut -d '.' -f 1)"
|
||||
fi
|
||||
}
|
||||
|
||||
get_current_desktop() {
|
||||
case "$WM" in
|
||||
(bspwm) bspc query -D -d focused --names ;;
|
||||
esac
|
||||
}
|
||||
|
||||
get_memory_usage() {
|
||||
if [ "$(uname)" = "Linux" ]; then
|
||||
printf "%b" \
|
||||
"$(free | head -n 2 | tail -n 1 \
|
||||
| awk '{print $3 " used / " $2 " total"}')"
|
||||
return
|
||||
fi
|
||||
}
|
||||
|
||||
get_public_ip() {
|
||||
@ -68,13 +88,17 @@ get_public_ip() {
|
||||
PUBLIC_IP="$(get_public_ip)"
|
||||
|
||||
printbar() {
|
||||
printf "%b || %b || %b || %b || %b %b\n" \
|
||||
"$(date)" \
|
||||
"BAT: $(get_battery_status)" \
|
||||
"CPU: $(get_cpu_temp)" \
|
||||
"PuIP: $PUBLIC_IP" \
|
||||
"MEM: $(get_memory_usage)" \
|
||||
""
|
||||
printf "[%b] " "$(get_current_desktop)"
|
||||
printf "%b" "$(date)"
|
||||
#printf "%b" "$DELIMITER"
|
||||
#printf "%b" "BAT: $(get_battery_status)"
|
||||
printf "%b" "$DELIMITER"
|
||||
printf "%b" "CPU: $(get_cpu_temp)"
|
||||
printf "%b" "$DELIMITER"
|
||||
printf "%b" "PuIP: $PUBLIC_IP"
|
||||
#printf "%b" "$DELIMITER"
|
||||
#printf "%b" "MEM: $(get_memory_usage)"
|
||||
printf "\n"
|
||||
return
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user