Add temperature to waybar in FreeBSD.
This commit is contained in:
parent
0bf29aba6f
commit
46672786ab
@ -59,6 +59,7 @@
|
|||||||
#custom-battery,
|
#custom-battery,
|
||||||
#custom-clock,
|
#custom-clock,
|
||||||
#custom-sound,
|
#custom-sound,
|
||||||
|
#custom-temperature,
|
||||||
#idle_inhibitor,
|
#idle_inhibitor,
|
||||||
#memory,
|
#memory,
|
||||||
#mode,
|
#mode,
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
// "height": 10, // Waybar height (to be removed for auto height)
|
// "height": 10, // Waybar height (to be removed for auto height)
|
||||||
"modules-left": ["sway/workspaces", "sway/mode"],
|
"modules-left": ["sway/workspaces", "sway/mode"],
|
||||||
"modules-right": ["custom/sound", "custom/available_memory", "custom/battery", "idle_inhibitor", "custom/clock", "tray"],
|
"modules-right": ["custom/temperature", "custom/sound", "custom/available_memory", "custom/battery", "idle_inhibitor", "custom/clock", "tray"],
|
||||||
"sway/workspaces": {
|
"sway/workspaces": {
|
||||||
"disable-scroll": true
|
"disable-scroll": true
|
||||||
},
|
},
|
||||||
@ -38,5 +38,10 @@
|
|||||||
"exec": "waybar_custom_sound",
|
"exec": "waybar_custom_sound",
|
||||||
"return-type": "json",
|
"return-type": "json",
|
||||||
"restart-interval": 30
|
"restart-interval": 30
|
||||||
|
},
|
||||||
|
"custom/temperature": {
|
||||||
|
"exec": "waybar_custom_temperature",
|
||||||
|
"return-type": "json",
|
||||||
|
"restart-interval": 30
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,46 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
# Read temperature status in FreeBSD
|
||||||
|
set -euo pipefail
|
||||||
|
IFS=$'\n\t'
|
||||||
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
|
||||||
|
SLEEP_INTERVAL=${SLEEP_INTERVAL:-30}
|
||||||
|
|
||||||
|
while true; do
|
||||||
|
current_cpu_temps=$(sysctl 'dev.cpu' | grep -E 'dev\.cpu\.[0-9]+\.temperature')
|
||||||
|
sum_temperature=0
|
||||||
|
num_temperature=0
|
||||||
|
max_temperature=0
|
||||||
|
while read temp; do
|
||||||
|
numeric_temp=$(echo "$temp" | cut -d ':' -f 2 | grep -oE '[0-9]+(\.[0-9]+)?')
|
||||||
|
sum_temperature=$(bc -s <<<"$sum_temperature + $numeric_temp")
|
||||||
|
num_temperature=$((num_temperature + 1))
|
||||||
|
max_temperature=$(bc <<EOF
|
||||||
|
define max(a,b){
|
||||||
|
if(a>b)
|
||||||
|
{
|
||||||
|
return(a)
|
||||||
|
}else{
|
||||||
|
return(b)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
max($max_temperature,$numeric_temp)
|
||||||
|
EOF
|
||||||
|
)
|
||||||
|
done<<<"$current_cpu_temps"
|
||||||
|
avg_temperature=$(bc -s <<<"$sum_temperature / $num_temperature")
|
||||||
|
tooltip="<tt>$current_cpu_temps</tt>"
|
||||||
|
class=""
|
||||||
|
icon="🌡"
|
||||||
|
|
||||||
|
jq --unbuffered --compact-output <<EOF
|
||||||
|
{
|
||||||
|
"text":"${max_temperature}℃ ${icon}",
|
||||||
|
"tooltip":"${tooltip//$'\n'/\\n}",
|
||||||
|
"percentage":50,
|
||||||
|
"class":"${class}"
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
sleep $SLEEP_INTERVAL
|
||||||
|
done
|
@ -63,3 +63,5 @@
|
|||||||
dest: /usr/local/bin/waybar_custom_available_memory
|
dest: /usr/local/bin/waybar_custom_available_memory
|
||||||
- src: waybar_sound_freebsd.bash
|
- src: waybar_sound_freebsd.bash
|
||||||
dest: /usr/local/bin/waybar_custom_sound
|
dest: /usr/local/bin/waybar_custom_sound
|
||||||
|
- src: waybar_temperature_freebsd.bash
|
||||||
|
dest: /usr/local/bin/waybar_custom_temperature
|
||||||
|
Loading…
Reference in New Issue
Block a user