-
Notifications
You must be signed in to change notification settings - Fork 1
/
set-tdp
42 lines (34 loc) · 852 Bytes
/
set-tdp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/bash
# Description: This script sets tdp for ryzen processors using ryzenadj.
# Dependency: ryzenadj(https://github.com/FlyGoat/RyzenAdj)
# checks whether ryzenadj is installed
if ! command -v ryzenadj >/dev/null 2>&1; then
echo "Error: 'ryzenadj' is not installed. Please install it."
exit 1
fi
# Prints an help message
print_help() {
echo "set-tdp, sets tdp for ryzen processors"
echo " Set a tdp:"
echo " set-tdp [value]"
echo " example: set-tdp 15"
}
case "${1:-}" in
# Exit with code 0 only if help was explicitly requested
-h|--help)
print_help
exit 0
;;
'')
print_help
exit 1
;;
esac
# checks the argument is integer
if [[ $1 =~ ^[0-9]+$ ]]; then
tdp=$1
# sets tdp using ryzenadj
sudo ryzenadj --stapm-limit=$tdp --fast-limit=$tdp --slow-limit=$tdp
else
print_help
fi