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)
|
# format for the date (by default in this script, ISO 8601)
|
||||||
alias date="date '+%Y-%m-%dT%T'"
|
alias date="date '+%Y-%m-%dT%T'"
|
||||||
|
|
||||||
|
DELIMITER=" || "
|
||||||
|
|
||||||
# how fast to refresh the display (in seconds, will be substituted with 1 if
|
# how fast to refresh the display (in seconds, will be substituted with 1 if
|
||||||
# not an integer)
|
# not an integer)
|
||||||
INTERVAL=1
|
INTERVAL=1
|
||||||
@ -29,33 +31,51 @@ INTERVAL=1
|
|||||||
PUBLIC_IP_FETCH_URL="http://ifconfig.io/"
|
PUBLIC_IP_FETCH_URL="http://ifconfig.io/"
|
||||||
|
|
||||||
get_battery_status() {
|
get_battery_status() {
|
||||||
# this is a dirty hack.
|
if [ "$(uname)" = "Linux" ]; then
|
||||||
# acpi | awk '{print $4}' will print the battery percentage,
|
# this is a dirty hack.
|
||||||
# and s/,$// strips the trailing comma.
|
# acpi | awk '{print $4}' will print the battery percentage,
|
||||||
# acpi -a will just print the power adapter status.
|
# and s/,$// strips the trailing comma.
|
||||||
printf "%b" "$(acpi | awk '{print $4}' | sed 's/,$//') ($(acpi -a))"
|
# acpi -a will just print the power adapter status.
|
||||||
return
|
printf "%b" "$(acpi | awk '{print $4}' | sed 's/,$//') ($(acpi -a))"
|
||||||
|
return
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
get_cpu_temp() {
|
get_cpu_temp() {
|
||||||
RETVAL=""
|
if [ "$(uname)" = "Linux" ]; then
|
||||||
# iterate over files, adjust, print out "%dC "
|
RETVAL=""
|
||||||
for file in $CPU_TEMP_FILES;
|
# iterate over files, adjust, print out "%dC "
|
||||||
do RETVAL="$RETVAL$(fdivide $(cat $file) $CPU_TEMP_SCALE)C "
|
for file in $CPU_TEMP_FILES;
|
||||||
done
|
do RETVAL="$RETVAL$(fdivide $(cat $file) $CPU_TEMP_SCALE)C "
|
||||||
# in-line python (bet you've never seen that before) that
|
done
|
||||||
# strips off trailing whitespace. could be done with sed but
|
# in-line python (bet you've never seen that before) that
|
||||||
# this was more fun
|
# strips off trailing whitespace. could be done with sed but
|
||||||
printf "%b" "$RETVAL" \
|
# this was more fun
|
||||||
| python -c "from sys import stdin; print(stdin.read().rstrip() + '\n')"
|
printf "%b" "$RETVAL" \
|
||||||
return
|
| 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() {
|
get_memory_usage() {
|
||||||
printf "%b" \
|
if [ "$(uname)" = "Linux" ]; then
|
||||||
"$(free | head -n 2 | tail -n 1 \
|
printf "%b" \
|
||||||
| awk '{print $3 " used / " $2 " total"}')"
|
"$(free | head -n 2 | tail -n 1 \
|
||||||
return
|
| awk '{print $3 " used / " $2 " total"}')"
|
||||||
|
return
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
get_public_ip() {
|
get_public_ip() {
|
||||||
@ -68,13 +88,17 @@ get_public_ip() {
|
|||||||
PUBLIC_IP="$(get_public_ip)"
|
PUBLIC_IP="$(get_public_ip)"
|
||||||
|
|
||||||
printbar() {
|
printbar() {
|
||||||
printf "%b || %b || %b || %b || %b %b\n" \
|
printf "[%b] " "$(get_current_desktop)"
|
||||||
"$(date)" \
|
printf "%b" "$(date)"
|
||||||
"BAT: $(get_battery_status)" \
|
#printf "%b" "$DELIMITER"
|
||||||
"CPU: $(get_cpu_temp)" \
|
#printf "%b" "BAT: $(get_battery_status)"
|
||||||
"PuIP: $PUBLIC_IP" \
|
printf "%b" "$DELIMITER"
|
||||||
"MEM: $(get_memory_usage)" \
|
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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user