Polish up TDP script
This commit is contained in:
parent
877fb21eaa
commit
2494d24dde
34
tdp
34
tdp
|
@ -10,26 +10,29 @@ Usage:
|
||||||
${command_name} COMMAND [ARGUMENTS]
|
${command_name} COMMAND [ARGUMENTS]
|
||||||
|
|
||||||
Command:
|
Command:
|
||||||
check [ARG] Checks current TDP and prints it in watts
|
check [ARGS] Checks current TDP and prints it in watts
|
||||||
set WATT Setts TDP to the requested number in watts
|
set WATTS [ARGS] Setts TDP to the requested number in watts
|
||||||
help Prints this help text
|
help Prints this help text
|
||||||
COMMAND help Prints help for specified command"
|
COMMAND --help Prints help for specified command"
|
||||||
|
|
||||||
check_help_text="${command_name} check [ARG]
|
check_help_text="${command_name} check [ARG]
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
${command_name} check --detail
|
${command_name} check --detail
|
||||||
|
${command_name} c -d
|
||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
--detail, -d Prints PL2 as well as PL1
|
--detail, -d Prints PL2 as well as PL1
|
||||||
--help Prints this help text"
|
--help Prints this help text"
|
||||||
|
|
||||||
set_help_text="${command_name} set WATT
|
set_help_text="${command_name} set WATT [ARGUMENTS]
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
${command_name} set 15
|
${command_name} set 10 --detail
|
||||||
|
${command_name} s 10 -d
|
||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
|
--detail, -d Prints PL2 as well as PL1
|
||||||
--help Prints this help text"
|
--help Prints this help text"
|
||||||
|
|
||||||
print_help () {
|
print_help () {
|
||||||
|
@ -54,7 +57,7 @@ print_unknown () {
|
||||||
|
|
||||||
# Retrieves current TDP and prints it
|
# Retrieves current TDP and prints it
|
||||||
check_tdp () {
|
check_tdp () {
|
||||||
if [ "$1" == "--detail" ] || [ "$1" == "-d" ]; then
|
if [[ "$@" == *"--detail"* ]] || [[ "$@" == *"-d"* ]]; then
|
||||||
echo "Placeholder"
|
echo "Placeholder"
|
||||||
echo "Extra placeholder"
|
echo "Extra placeholder"
|
||||||
|
|
||||||
|
@ -72,17 +75,20 @@ check_tdp () {
|
||||||
# Sets TDP to number provided as first argument
|
# Sets TDP to number provided as first argument
|
||||||
set_tdp () {
|
set_tdp () {
|
||||||
if [ -z "$1" ]; then
|
if [ -z "$1" ]; then
|
||||||
print_unknown
|
echo "Please specify wattage"
|
||||||
exit
|
exit
|
||||||
elif [ "$1" == "--help" ]; then
|
elif [ "$1" == "--help" ]; then
|
||||||
print_help "set"
|
print_help "set"
|
||||||
exit
|
exit
|
||||||
|
elif ! [[ $1 =~ ^-?[0-9]+$ ]]; then
|
||||||
|
echo "TDP is not a number or argument unknown!)"
|
||||||
|
print_unknown
|
||||||
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! [[ $1 =~ ^-?[0-9]+$ ]]; then
|
if [ $1 -lt 5 ] || [ $1 -gt 30 ]; then
|
||||||
echo "TDP must be a plain number!)"
|
echo "TDP too high or low, should be between 5W and 30W"
|
||||||
elif [[ ! "$@" == *"--force"* ]] || [ $1 -lt 8 ] || [ $1 -gt 28 ]; then
|
echo "This is a sanity limit to prevent you from throttling to a near unusable state"
|
||||||
echo "TDP too high or low, should be between 8W and 28W"
|
|
||||||
else
|
else
|
||||||
#PL1
|
#PL1
|
||||||
local watts=$1
|
local watts=$1
|
||||||
|
@ -94,18 +100,20 @@ set_tdp () {
|
||||||
|
|
||||||
echo $uwatts
|
echo $uwatts
|
||||||
echo "PL1 is now ${watts}W (Long-term)"
|
echo "PL1 is now ${watts}W (Long-term)"
|
||||||
|
if [[ "$@" == *"--detail"* ]] || [[ "$@" == *"-d"* ]]; then
|
||||||
echo "PL2 is now ${watts2}W (Short-term)"
|
echo "PL2 is now ${watts2}W (Short-term)"
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Command handler
|
# Command handler
|
||||||
case $1 in
|
case $1 in
|
||||||
|
|
||||||
"check")
|
"check" | "c")
|
||||||
check_tdp "${@:2}"
|
check_tdp "${@:2}"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
"set")
|
"set" | "s")
|
||||||
set_tdp "${@:2}"
|
set_tdp "${@:2}"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue