linux_gamemode.sh - randomcrap - random crap programs of varying quality
(HTM) git clone git://git.codemadness.org/randomcrap
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
linux_gamemode.sh (1126B)
---
1 #!/bin/sh
2 # adjust CPU governor and GPU clock frequencies for performance.
3 # NOTE: the "Feral game mode" software is bloated.
4 #
5 # use at your own risk!!!
6 #
7 # my system: old Intel CPU, AMD RX480 (amdgpu + RADV driver).
8
9 profile_normal() {
10 cpugov="ondemand"
11 gpuperf="auto"
12 }
13
14 profile_gaming() {
15 cpugov="performance"
16 gpuperf="high"
17 }
18
19 show() {
20 echo "CPU governor:"
21 for f in /sys/devices/system/cpu/cpufreq/policy*/scaling_governor; do
22 echo " $f: $(cat $f)"
23 done
24
25 # AMD
26 echo ""
27 echo "GPU:"
28 find /sys -name "power_dpm_force_performance_level" 2>/dev/null | while read -r f; do
29 echo " $f: $(cat $f)"
30 done
31 }
32
33 applyprofile() {
34 # CPU: apply to all cores.
35 for f in /sys/devices/system/cpu/cpufreq/policy*/scaling_governor; do
36 echo "$cpugov" > "$f"
37 done
38
39 # GPU: apply to all GPUs.
40 find /sys -name "power_dpm_force_performance_level" 2>/dev/null | while read -r f; do
41 echo "$gpuperf" > "$f"
42 done
43 }
44
45 usage() {
46 echo "$0 [on|off]" >&2
47 }
48
49 case "$1" in
50 "on")
51 show
52 profile_gaming
53 set -x
54 applyprofile
55 set +x
56 show;;
57 "off")
58 show
59 profile_normal
60 set -x
61 applyprofile
62 set +x
63 show;;
64 "")
65 show;;
66 *)
67 usage;;
68 esac
69