Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 10 additions & 29 deletions throttler.sh
Original file line number Diff line number Diff line change
@@ -1,50 +1,31 @@
#!/bin/bash

#You can replace HandBrake with any Program you like
# but look for case sensitivity

hbpid=$(pgrep HandBrake)
#-------[ File Description ]-------#
# You can replace HandBrake with any Program you like
# but look for case sensitivity.

echo "This Script must be in the same directory like cputhrottle and
be running with sudo. Alternatively you can add a path at the program call.
If you want to end the script just make twice ctrl+c."

if [ -z "$hbpid" ]
then
echo "No HandBrake running! Exit!"
exit 1
fi

thrpid=$(pgrep cputhrottle)
#echo $thrpid
if [ -n "$thrpid" ]
then
echo "CpuThrottle already running. Exit"
exit 2
fi

#Here you can set your cpuPercentage Value you like
#-------[ Configuration ]-------#
# Here you can set your cpuPercentage Value you like
cpuPerc=600

# Checking time interval (in seconds)
chckInt=5

#-------[ Checking loop ]-------#
while true
do
if [ -z "$hbpid" ]
then
echo "No HandBrake running! Exit!"
exit 1
fi

thrpid=$(pgrep cputhrottle)
#echo $thrpid
if [ -z "$thrpid" ]
then

echo "Starting cputhrottle..."
date
set -e
./cputhrottle $hbpid $cpuPerc || exit 3
set +e
fi

sleep 5
sleep $chckInt
done