mirror of
https://codeberg.org/tmayoff/.dotfiles.git
synced 2025-12-06 08:48:34 -05:00
Reorganized
This commit is contained in:
parent
4cd0255ba4
commit
e42e996e75
21 changed files with 2397 additions and 965 deletions
33
dot_config/flake/home/waybar/mechabar/scripts/cpu-usage.sh
Executable file
33
dot_config/flake/home/waybar/mechabar/scripts/cpu-usage.sh
Executable file
|
|
@ -0,0 +1,33 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Get CPU model (removed "(R)", "(TM)", and clock speed)
|
||||
model=$(awk -F ': ' '/model name/{print $2}' /proc/cpuinfo | head -n 1 | sed 's/@.*//; s/ *\((R)\|(TM)\)//g; s/^[ \t]*//; s/[ \t]*$//')
|
||||
|
||||
# Get CPU usage percentage
|
||||
load=$(vmstat 1 2 | tail -1 | awk '{print 100 - $15}')
|
||||
|
||||
# Determine CPU state based on usage
|
||||
if [ "$load" -ge 80 ]; then
|
||||
state="Critical"
|
||||
elif [ "$load" -ge 60 ]; then
|
||||
state="High"
|
||||
elif [ "$load" -ge 25 ]; then
|
||||
state="Moderate"
|
||||
else
|
||||
state="Low"
|
||||
fi
|
||||
|
||||
# Set color based on CPU load
|
||||
if [ "$load" -ge 80 ]; then
|
||||
# If CPU usage is >= 80%, set color to #f38ba8
|
||||
text_output="<span color='#f38ba8'> ${load}%</span>"
|
||||
else
|
||||
# Default color
|
||||
text_output=" ${load}%"
|
||||
fi
|
||||
|
||||
tooltip="${model}"
|
||||
tooltip+="\nCPU Usage: ${state}"
|
||||
|
||||
# Module and tooltip
|
||||
echo "{\"text\": \"$text_output\", \"tooltip\": \"$tooltip\"}"
|
||||
Loading…
Add table
Add a link
Reference in a new issue