hyprdots
hyprdots copied to clipboard
perf: optimize performance of waybar cpuinfo and gpuinfo modules
Icon generation bottleneck
The function to generate icons have been causing performance bottleneck since the beginning of cpuinfo module. The original version (3cf5d2971ba43a71c95bde8c3ec67858dfa12ed2, c.sh
in the screenshot) has been taking around 30.5ms (not absolute, for comparison).
To reduce the performance overhead, the revision (9b9b1ce8cdd5914f243f62f19d38c6c2d457fd8b, d.sh
in the screenshot) have improved the speed to 22.3ms (37% faster than the original version). Here a single jq
has been used to replace multiple forks of awk
to improve the performance.
The original version turns out to run on 6.58ms (364% faster than original and 238% faster than the revised) after minimizing the number of forks and removing all forks to awk
(b.sh
in the screenshot). I also tested possibly the minimal version a.sh
which contains only if branches completed in 5.4ms.
Despite a.sh
is the fastest, I included b.sh
in both gpuinfo and cpuinfo as it follows Object Oriented principles and performance difference is insignificant (1.18ms).
The forks
There are a number of redundant forks throughout script like:
maxfreq=$(lscpu | grep "CPU max MHz" | awk -F: '{ print $2}' | sed -e 's/ //g' -e 's/\.[0-9]*//g')
Which could be improved by substituting with:
maxfreq=$(lscpu | awk '/CPU max MHz/ { sub(/\..*/,"",$4); print $4}')
The number of forks have been minimized completely on cpuinfo.sh
and partially on gpuinfo.sh
.
top
bottleneck
The overall performance of the script wasn't improved significantly even after minimizing forks as the top -bn1
taking almost 260ms as it has to compute information of all running and sleeping processes. The utility mpstat
is a great alternative but it requires the program to be installed on the system. Hence top
is replaced by calculating the utilization levels directly from /proc/stat
which is taking around 15ms, that is 1633% improvement in performance.
Continuous script
As the script has to recalculate values that doesn't change during runtime (like CPU name and max freq), it is inefficient to run on every 5s. Since waybar allows the scripts to be executed in continuous mode which allows significant improvement on performance as the static values doesn't required to be recalculated on each iteration, the cpuinfo.sh has been adjusted to run as a continuous script.
Other changes
Improved accuracy of utilization level as it now prints average between each updates. Also added option to decide whether to print emojis or glyphs by setting an environment variable NO_EMOJI
as the commit: 9b9b1ce8cdd5914f243f62f19d38c6c2d457fd8b converted emojis to glyphs.
Warning to reviewers
The changes included in the commit: a5cfdd0f3f5a94f8dfa0ef4fc27dffbc973a6097 have been included in this PR, but haven't tested as my machine doesn't have AMD CPU. Although, I tried testing with passing faked sensors data and worked well.
Testing
All the unit testing has been done by the script:
python -m timeit -n 10 -s 'import subprocess' "subprocess.call('./test.sh', shell=True)"
The python timeit
is not absolute but is highly precise and useful for comparison. I think strace
or time
gives more accurate results but are not statistical or precise.
Type of change
- [x] Performance improvement (non-breaking change)
- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] Documentation update (non-breaking change; modified files are limited to the documentations)
- [ ] Technical debt (a code change that does not fix a bug or add a feature but makes something clearer for devs)
Checklist
- [x] I have read the CONTRIBUTING document.
- [x] My code follows the code style of this project.
- [x] My commit message follows the commit guidelines.
- [ ] My change requires a change to the documentation.
- [ ] I have updated the documentation accordingly.
- [ ] I have added a changelog entry.
- [x] I have added necessary comments/documentation to my code.
- [ ] I have added tests to cover my changes.
- [x] I have tested my code locally and it works as expected.
- [ ] All new and existing tests passed.
❯ ~/.config/hypr/scripts/gpuinfo.sh
/home/khing/.config/hypr/scripts/gpuinfo.sh: line 127: [: -gt: unary operator expected
/home/khing/.config/hypr/scripts/gpuinfo.sh: line 127: [: -gt: unary operator expected
/home/khing/.config/hypr/scripts/gpuinfo.sh: line 127: [: -gt: unary operator expected
/home/khing/.config/hypr/scripts/gpuinfo.sh: line 127: [: -gt: unary operator expected
/home/khing/.config/hypr/scripts/gpuinfo.sh: line 127: [: -gt: unary operator expected
/home/khing/.config/hypr/scripts/gpuinfo.sh: line 127: [: -gt: unary operator expected
{"text":" 61°C", "tooltip":"Intel CometLake-U GT2\n Temperature: 61°C ❄️\n Power Discharge: 15.203 W\n Utilization: 27.6 %\n Clock Speed: 1799.66/4900 MHz"}
Disclaimer: I did not fully review it yet. Looks good in the description, so I won't dig deeper if this works on my end. 😁
Additionally, I believe you can pass the $NO_EMOJI
variable to the query()
function to avoid making major changes to the JSONC. In the query()
function, there's a file ${gpuQ}
which lists all variables on the script's first execution. You can append the $NO_EMOJI
variable to this list, and it might be invoked by running the script once at startup, like so:
${0} --emoji
My sys info if needed.
Hyprland, built from branch main at commit f27054c13e72598e43771cb3f8bfad8ac6c6668f dirty (flake.nix: override inputs for xdph and hyprlang).
Date: Fri Feb 23 23:48:11 2024
Tag: v0.35.0-88-gf27054c1
flags: (if any)
System Information:
System name: Linux
Node name: ArchLinux
Release: 6.7.6-zen1-1-zen
Version: #1 ZEN SMP PREEMPT_DYNAMIC Fri, 23 Feb 2024 16:32:48 +0000
GPU information:
00:02.0 VGA compatible controller [0300]: Intel Corporation CometLake-U GT2 [UHD Graphics] [8086:9b41] (rev 02) (prog-if 00 [VGA controller])
os-release: NAME="Arch Linux"
PRETTY_NAME="Arch Linux"
ID=arch
BUILD_ID=rolling
ANSI_COLOR="38;2;23;147;209"
HOME_URL="https://archlinux.org/"
DOCUMENTATION_URL="https://wiki.archlinux.org/"
SUPPORT_URL="https://bbs.archlinux.org/"
BUG_REPORT_URL="https://gitlab.archlinux.org/groups/archlinux/-/issues"
PRIVACY_POLICY_URL="https://terms.archlinux.org/docs/privacy-policy/"
LOGO=archlinux-logo
plugins:
hyprgrass by horriblename ver 0.5
hycov by DreamMaoMao ver 0.3
hyprwinwrap by Vaxry ver 1.0
Oh no, The same happening on my machine too O_O
Demn, I forgot to pass the temperature and utilization value to the function. Wait fixing..
Additionally, I believe you can pass the
$NO_EMOJI
variable to thequery()
function to avoid making major changes to the JSONC. In thequery()
function, there's a file${gpuQ}
which lists all variables on the script's first execution. You can append the$NO_EMOJI
variable to this list, and it might be invoked by running the script once at startup
I thought of adding NO_EMOJI
as a env var to make it easier for end users to switch between emoji and glyphs as they can easily see those in waybar module templates. I don't think anyone will notice this option if we add the variable in gpuinfo.sh
as the script is already scaryyy.
I meant like this. You can add a flag for no_emoji.
As having an ENV is too specific and overkill for just a single script haha
so example command might look like this and can be invoke at startup
exec-once = ~/.config/hypr/scripts/gpuinfo.sh --use intel startup no_emoji
Sorry for making that slightly scary, it's the only way I can think of catering all 3 GPUs.
Umm.. I see. It looks great but feels a bit complicated to me . Can you add that to the script if you don't mind or I can try later today.
Sorry for making that slightly scary, it's the only way I can think of catering all 3 GPUs.
No no, don't get me wrong, I was saying shell scripts are scary as a whole.
I fixed the bug you pointed out btw.. please check again.
~EDITED~ Is that fine ? https://github.com/prasanthrangan/hyprdots/pull/952/commits/8ff003653a643a08f4a05a7ebaaeb9649e06b939
Also we have the --reset
so we can override/change the "variables"
Should look like this:
No no, don't get me wrong, I was saying shell scripts are scary as a whole.
Ow, I was afraid this version is not maintainable, but I'm wrong. You guys are Pros. Everything works on my end, BTW. for now
Nah Here's the 293 lines
#!/bin/bash
# shellcheck disable=SC2312
# shellcheck disable=SC1090
gpuQ="/tmp/hyprdots-${UID}-gpuinfo-query"
tired=false
[[ " $* " =~ " tired " ]] && ! grep -q "tired" "${gpuQ}" && echo "tired=true" >>"${gpuQ}"
[[ " $* " =~ " no_emoji " ]] && ! grep -q "NO_EMOJI" "${gpuQ}" && echo "NO_EMOJI=1" >>"${gpuQ}"
if [[ ! " $* " =~ " startup " ]]; then
gpuQ="${gpuQ}$2"
fi
detect() { # Auto detect Gpu used by Hyprland(declared using env = WLR_DRM_DEVICES) Sophisticated?
card=$(echo "${WLR_DRM_DEVICES}" | cut -d':' -f1 | cut -d'/' -f4)
# shellcheck disable=SC2010
slot_number=$(ls -l /dev/dri/by-path/ | grep "${card}" | awk -F'pci-0000:|-card' '{print $2}')
vendor_id=$(lspci -nn -s "${slot_number}" )
declare -A vendors=(["10de"]="nvidia" ["8086"]="intel" ["1002"]="amd")
for vendor in "${!vendors[@]}"; do
if [[ ${vendor_id} == *"${vendor}"* ]]; then
initGPU="${vendors[${vendor}]}"
break
fi
done
if [[ -n ${initGPU} ]]; then
$0 --use "${initGPU}" startup
fi
}
query() {
nvidia_flag=0 amd_flag=0 intel_flag=0
touch "${gpuQ}"
if lsmod | grep -q 'nouveau'; then
echo "nvidia_gpu=\"Linux\"" >>"${gpuQ}" #? Incase If nouveau is installed
echo "nvidia_flag=1 # Using nouveau an open-source nvidia driver" >>"${gpuQ}"
elif command -v nvidia-smi &> /dev/null; then
nvidia_gpu=$(nvidia-smi --query-gpu=gpu_name --format=csv,noheader,nounits | head -n 1)
if [[ -n "${nvidia_gpu}" ]] ; then # Check for NVIDIA GPU
if [[ "${nvidia_gpu}" == *"NVIDIA-SMI has failed"* ]]; then #? Second Layer for dGPU
echo "nvidia_flag=0 # NVIDIA-SMI has failed" >> "${gpuQ}"
else
nvidia_address=$(lspci | grep -Ei "VGA|3D" | grep -i "${nvidia_gpu/NVIDIA /}" | cut -d' ' -f1)
{ echo "nvidia_address=\"${nvidia_address}\""
echo "nvidia_gpu=\"${nvidia_gpu/NVIDIA /}\""
echo "nvidia_flag=1"
} >> "${gpuQ}"
fi
fi
fi
if lspci -nn | grep -E "(VGA|3D)" | grep -iq "1002"; then
amd_gpu="$(lspci -nn | grep -Ei "VGA|3D" | grep -m 1 "1002" | awk -F'Advanced Micro Devices, Inc. ' '{gsub(/ *\[[^\]]*\]/,""); gsub(/ *\([^)]*\)/,""); print $2}')"
amd_address=$(lspci | grep -Ei "VGA|3D" | grep -i "${amd_gpu}" | cut -d' ' -f1)
{ echo "amd_address=\"${amd_address}\""
echo "amd_flag=1" # Check for Amd GPU
echo "amd_gpu=\"${amd_gpu}\""
} >> "${gpuQ}";fi
if lspci -nn | grep -E "(VGA|3D)" | grep -iq "8086"; then
intel_gpu="$(lspci -nn | grep -Ei "VGA|3D" | grep -m 1 "8086" | awk -F'Intel Corporation ' '{gsub(/ *\[[^\]]*\]/,""); gsub(/ *\([^)]*\)/,""); print $2}')"
intel_address=$(lspci | grep -Ei "VGA|3D" | grep -i "${intel_gpu}" | cut -d' ' -f1)
{ echo "intel_address=\"${intel_address}\""
echo "intel_flag=1" # Check for Intel GPU
echo "intel_gpu=\"${intel_gpu}\""
} >>"${gpuQ}"; fi
if ! grep -q "prioGPU=" "${gpuQ}" && [[ -n "${WLR_DRM_DEVICES}" ]]; then
trap detect EXIT
fi
}
toggle() {
if [[ -n "$1" ]]; then
next_prioGPU="$1_flag"
else
# Initialize gpu_flags and prioGPU if they don't exist
if ! grep -q "gpu_flags=" "${gpuQ}"; then
gpu_flags=$(grep "flag=1" "${gpuQ}" | cut -d '=' -f 1 | tr '\n' ' ' | tr -d '#')
echo "" >> "${gpuQ}"
echo "gpu_flags=\"${gpu_flags[*]}\"" >> "${gpuQ}"
fi
if ! grep -q "prioGPU=" "${gpuQ}"; then
gpu_flags=$(grep "gpu_flags=" "${gpuQ}" | cut -d'=' -f 2)
initGPU=$(echo "${gpu_flags}" | cut -d ' ' -f 1)
echo "prioGPU=${initGPU}" >> "${gpuQ}"
fi
mapfile -t anchor < <(grep "flag=1" "${gpuQ}" | cut -d '=' -f 1)
prioGPU=$(grep "prioGPU=" "${gpuQ}" | cut -d'=' -f 2) # Get the current prioGPU from the file
# Find the index of the current prioGPU in the anchor array
for index in "${!anchor[@]}"; do
if [[ "${anchor[${index}]}" = "${prioGPU}" ]]; then
current_index=${index}
fi
done
next_index=$(( (current_index + 1) % ${#anchor[@]} ))
next_prioGPU=${anchor[${next_index}]#\#}
fi
# Set the next prioGPU and remove the '#' character
sed -i 's/^\(nvidia_flag=1\|amd_flag=1\|intel_flag=1\)/#\1/' "${gpuQ}" # Comment out all the gpu flags in the file
sed -i "s/^#${next_prioGPU}/${next_prioGPU}/" "${gpuQ}" # Uncomment the next prioGPU in the file
sed -i "s/prioGPU=${prioGPU}/prioGPU=${next_prioGPU}/" "${gpuQ}" # Update the prioGPU in the file
}
# Thee shalt find the greatest one,
# He who not more than the chosen one
map_floor() {
# From the depths of the string, words arise,
# Keys in pairs, a treasure in disguise.
IFS=', ' read -r -a pairs <<< "$1"
# If the final token stands alone and bold,
# Declare it the default, its worth untold.
if [[ ${pairs[-1]} != *":"* ]]; then
def_val="${pairs[-1]}"
unset 'pairs[${#pairs[@]}-1]'
fi
# Scans the map, a peak it seeks,
# The highest passed, the value speaks.
for pair in "${pairs[@]}"; do
IFS=':' read -r key value <<< "$pair"
# Behold! Thou holds the secrets they seek,
# Declare it and silence the whispers unique.
if [ ${2%%.*} -gt $key ]; then
echo "$value"
return
fi
done
# On this lonely shore, where silence dwells
# Even the waves, echoes words unheard
[ -n "$def_val" ] && echo $def_val || echo " "
}
generate_json() {
# Generate glyphs
icons=$(echo "$(map_floor "$util_lv" $utilization)$(map_floor "$temp_lv" $temperature)")
speedo=$(echo ${icons:0:1})
thermo=$(echo ${icons:1:1})
emoji=$(echo ${icons:2})
local json="{\"text\":\"${thermo} ${temperature}°C\", \"tooltip\":\"${primary_gpu}\n${thermo} Temperature: ${temperature}°C ${emoji}"
#? Soon Add Something incase needed.
declare -A tooltip_parts
if [[ -n "${utilization}" ]]; then tooltip_parts["\n$speedo Utilization: "]="${utilization}%" ; fi
if [[ -n "${current_clock_speed}" ]] && [[ -n "${max_clock_speed}" ]]; then tooltip_parts["\n Clock Speed: "]="${current_clock_speed}/${max_clock_speed} MHz" ; fi
if [[ -n "${gpu_load}" ]]; then tooltip_parts["\n$speedo Utilization: "]="${gpu_load}%" ; fi
if [[ -n "${core_clock}" ]]; then tooltip_parts["\n Clock Speed: "]="${core_clock} MHz" ;fi
if [[ -n "${power_usage}" ]]; then if [[ -n "${power_limit}" ]]; then
tooltip_parts["\n Power Usage: "]="${power_usage}/${power_limit} W"
else
tooltip_parts["\n Power Usage: "]="${power_usage} W"
fi
fi
if [[ -n "${power_discharge}" ]] && [[ "${power_discharge}" != "0" ]]; then tooltip_parts["\n Power Discharge: "]="${power_discharge} W" ;fi
for key in "${!tooltip_parts[@]}"; do
local value="${tooltip_parts[${key}]}"
if [[ -n "${value}" && "${value}" =~ [a-zA-Z0-9] ]]; then
json+="${key}${value}"
fi
done
json="${json}\"}"
echo "${json}"
}
general_query() { # Function to get temperature from 'sensors'
filter=''
temperature=$(sensors | ${filter} grep -m 1 -E "(edge|Package id.*|another keyword)" | awk -F ':' '{print int($2)}') #! We can get json data from sensors too
# gpu_load=$()
# core_clock=$()
for file in /sys/class/power_supply/BAT*/power_now; do
[[ -f "${file}" ]] && power_discharge=$(awk '{print $1*10^-6 ""}' "${file}") && break
done
[[ -z "${power_discharge}" ]] && for file in /sys/class/power_supply/BAT*/current_now; do
[[ -f "${file}" ]] && power_discharge=$(awk -v current="$(cat "${file}")" -v voltage="$(cat "${file/current_now/voltage_now}")" 'BEGIN {print (current * voltage) / 10^12 ""}') && break
done
# power_limit=$()
utilization=$(top -bn1 | grep "Cpu(s)" | sed "s/.*, *\([0-9.]*\)%* id.*/\1/" | awk '{print 100 - $1" "}')
current_clock_speed=$(awk '{sum += $1; n++} END {if (n > 0) print sum / n / 1000 ""}' /sys/devices/system/cpu/cpufreq/policy*/scaling_cur_freq)
max_clock_speed=$(awk '{print $1/1000}' /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq)
}
intel_GPU() { #? Function to query basic intel GPU
primary_gpu="Intel ${intel_gpu}"
general_query
}
nvidia_GPU() { #? Function to query Nvidia GPU
primary_gpu="NVIDIA ${nvidia_gpu}"
if [[ "${nvidia_gpu}" == "Linux" ]]; then general_query ; return ; fi #? Open source driver
#? Tired Flag for not using nvidia-smi if GPU is in suspend mode.
if ${tired}; then is_suspend="$(cat /sys/bus/pci/devices/0000:"${nvidia_address}"/power/runtime_status)"
if [[ ${is_suspend} == *"suspend"* ]]; then
printf '{"text":"", "tooltip":"%s ⏾ Suspended mode"}' "${primary_gpu}"; exit ;fi
fi
gpu_info=$(nvidia-smi --query-gpu=temperature.gpu,utilization.gpu,clocks.current.graphics,clocks.max.graphics,power.draw,power.max_limit --format=csv,noheader,nounits)
# Split the comma-separated values into an array
IFS=',' read -ra gpu_data <<< "${gpu_info}"
# Extract individual values
temperature="${gpu_data[0]// /}"
utilization="${gpu_data[1]// /}"
current_clock_speed="${gpu_data[2]// /}"
max_clock_speed="${gpu_data[3]// /}"
power_usage="${gpu_data[4]// /}"
power_limit="${gpu_data[5]// /}"
}
amd_GPU() { #? Funtion to query amd GPU
primary_gpu="AMD ${amd_gpu}"
# Execute the AMD GPU Python script and use its output
amd_output=$(python3 ~/.config/hypr/scripts/amdgpu.py)
if [[ ! ${amd_output} == *"No AMD GPUs detected."* ]] && [[ ! ${amd_output} == *"Unknown query failure"* ]]; then #! This will be changed if "(python3 ~/.config/hypr/scripts/amdgpu.py)" Changes!
# Extract GPU Temperature, GPU Load, GPU Core Clock, and GPU Power Usage from amd_output
temperature=$(echo "${amd_output}" | jq -r '.["GPU Temperature"]' | sed 's/°C//')
gpu_load=$(echo "${amd_output}" | jq -r '.["GPU Load"]' | sed 's/%//')
core_clock=$(echo "${amd_output}" | jq -r '.["GPU Core Clock"]' | sed 's/ GHz//;s/ MHz//')
power_usage=$(echo "${amd_output}" | jq -r '.["GPU Power Usage"]' | sed 's/ Watts//')
# elif #? Can add another Layer of query if "~/.config/hypr/scripts/amdgpu.py" fails
else
general_query
fi
}
if [[ ! -f "${gpuQ}" ]]; then
query ; echo -e "Initialized Variable:\n$(cat "${gpuQ}")\n\nReboot or '$0 --reset' to RESET Variables"
fi
source "${gpuQ}"
case "$1" in
"--toggle"|"-t")
toggle
echo -e "Sensor: ${next_prioGPU} GPU" | sed 's/_flag//g'
exit
;;
"--use"|"-u")
toggle "$2"
;;
"--reset"|"-rf")
rm -fr "${gpuQ}"*
query
echo -e "Initialized Variable:\n$(cat "${gpuQ}" || true)\n\nReboot or '$0 --reset' to RESET Variables"
exit
;;
*"-"*)
gpu_flags=$(grep "flag=1" "${gpuQ}" | cut -d '=' -f 1 | tr '\n' ' ' | tr -d '#')
cat << EOF
Avalable GPU: ${gpu_flags//_flag/}
[options]
--toggle * Toggle available GPU
--use [GPU] * Only call the specified GPU (Useful for adding specific GPU on waybar)
--reset * Remove & restart all query
[flags]
tired * Adding this option will not query nvidia-smi if gpu is in suspend mode
startup * Useful if you want a certain GPU to be set at startup
no_emoji * Use glyphs instead of emoji
* If ${USER} declared env = WLR_DRM_DEVICES on hyprland then use this as the primary GPU
EOF
exit
;;
esac
# Define glyphs
if [[ $NO_EMOJI -eq 1 ]]; then
temp_lv="85:, 65:, 45:☁, ❄"
else
temp_lv="85:🌋, 65:🔥, 45:☁️, ❄️"
fi
util_lv="90:, 60:, 30:, "
nvidia_flag=${nvidia_flag:-0} intel_flag=${intel_flag:-0} amd_flag=${amd_flag:-0}
#? Based on the flags, call the corresponding function multi flags means multi GPU.
if [[ "${nvidia_flag}" -eq 1 ]]; then
nvidia_GPU
elif [[ "${amd_flag}" -eq 1 ]]; then
amd_GPU
elif [[ "${intel_flag}" -eq 1 ]]; then
intel_GPU
else primary_gpu="Not found"
general_query
fi
generate_json #? AutoGen the Json txt for Waybar
Excellent! Thank you, you saved a lot of my time ❤️
Ow, I was afraid this version is not maintainable, but I'm wrong.
It's true that it is a bit hard to understand (I didn't read most of it) but it's amazing how fast it runs. Initially the cpuinfo took around 320ms but your script runs at around 22ms on my machine. Pure genius.
If remembered correctly, we can just use ~/.config/hypr/scripts/gpuinfo.sh
to get intel and amd cpu temps too. The script uses sensors. ( I only realized recently that sensors
provides JSON we can make it more efficient).
to use the gpuinfo script, we can just call it ~/.config/hypr/scripts/gpuinfo.sh --use intel
For now, we can use this. If we want to query CPU, I can help to add static variables on the already availabe metadata file. These are generated by the gpuinfo script to query first.
This is the reason why the gpuinfo.jsonc have some custom waybar modules available.
For now ~/.config/hypr/scripts/gpuinfo.sh
can handle to query for cpu as long as it has an iGPU. ( a single unit like some intel and AMD)
But if there are devices that CPU and GPU are separated, we should have a separate CPU script or we can modify the gpuinfo.
If remembered correctly, we can just use
~/.config/hypr/scripts/gpuinfo.sh
to get intel and amd cpu temps too. The script uses sensors. ( I only realized recently thatsensors
provides JSON we can make it more efficient).
Oh cool idea, why cant we just show gpu and cpu info in the same module? the script output could be both GPU and CPU temps combined.
Oh cool idea, why cant we just show gpu and cpu info in the same module? the script output could be both GPU and CPU temps combined.
We can, but should we consider integrated GPU temp as the CPU temp too?
I'll try to merge cpuinfo and gpuinfo into a single script, so they should share a single metadata. Then use options to it so that we can still get flexibility
[REF] snippet at the bottom we can change --use
into --gpu
and --cpu
Example syntax With this we can have more options to what to show.
+ $0 --cpu [CPU] --gpu [GPU] # OUTPUT: "text":" 60°C 55°C" ...
+ $0 --gpu [GPU] # OUTPUT: "text":" 55°C " ...
+ $0 --cpu # OUTPUT: "text":" 60°C " ...
- Of course the tooltip should provide both CPU and GPU temp
❯ ~/.config/hyprdots/scripts/gpuinfo.sh -h
Avalable GPU: intel
[options]
--toggle * Toggle available GPU
--use [GPU] * Only call the specified GPU (Useful for adding specific GPU on waybar)
--reset * Remove & restart all query
[flags]
tired * Adding this option will not query nvidia-smi if gpu is in suspend mode
startup * Useful if you want a certain GPU to be set at startup
* If khing declared env = WLR_DRM_DEVICES on hyprland then use this as the primary GPU
Of course, I need help from @mislah to refactor the functions.
We can, but should we consider integrated GPU temp as the CPU temp too?
I'll try to merge cpuinfo and gpuinfo into a single script, so they should share a single metadata. Then use options to it so that we can still get flexibility ..... Of course, I need help from @mislah to refactor the functions.
Excellent, I also thought the same, as they are both quite similar. I'm a little too busy these days. I assure you that I'll help as much as I can, but I'm afraid I might not have enough time.
No rush on this one. Everything is working as intended for now. Will try to prioritize other issues.
I will add a PR @ https://github.com/mislah/hyprdots/tree/waybar/optimize soon.