My i3 configurations and scripts.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

33 lines
737 B

#!/bin/sh
echo "{\"version\":1}"
INFO='#E9F1FF'
NORMAL='#B3FF6C'
WARNING='#FF6836'
CRITICAL='#FF474A'
echo "[[]"
while true; do
(
echo -n ",["
ps ux --sort -%cpu | head -n 30 | sed 's/\s\{2,\}/ /g' | cut -d" " -f3,11 | uniq | grep -v uniq | egrep -v '^0.0' | egrep '^[0-9.]* [a-z]' | while read cpu bin; do
if [ $(echo "if (${cpu} < 3 ) 1 else 0" | bc) -eq 1 ]; then
COLOR=$INFO
elif [ $(echo "if (${cpu} < 40.0 ) 1 else 0" | bc) -eq 1 ]; then
COLOR=$NORMAL
elif [ $(echo "if (${cpu} < 70.0 ) 1 else 0" | bc) -eq 1 ]; then
COLOR=$WARNING
else
COLOR=$CRITICAL
fi
echo -n "{\"full_text\": \" $bin ($cpu%) \", \"color\": \"$COLOR\"},"
done
echo "]"
) | sed 's/,\]/]/'
sleep 5
done