Last active
November 18, 2016 22:09
-
-
Save ah-itagile/64d5ff4c88860f02fdfffeb0d4806f8a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
oldUsage=0 | |
while true | |
do | |
usage=`ps -e -o %cpu | awk '{s+=$1} END {print int(s)}'` | |
echo " Usage=" $usage | |
if [ "$usage" -gt 99 ]; | |
then | |
usage=99 | |
elif [ "$usage" -gt 70 ]; | |
then | |
usage=50 | |
else | |
usage=10 | |
fi | |
echo " outputlevel=" $usage | |
if [ "$oldUsage" != "$usage" ]; | |
then | |
pidold=$pid | |
oldUsage=$usage | |
afplay rainforest.mp3 -v 0."$usage" & | |
sleep 1 | |
pid=`echo $!` | |
if [ ! -z "$pidold" ]; | |
then | |
echo "killing pid=" $pidold | |
kill $pidold | |
fi | |
fi | |
sleep 3 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment