diff options
author | dreieck | 2023-02-20 16:13:29 +0100 |
---|---|---|
committer | dreieck | 2023-02-20 16:13:29 +0100 |
commit | 3d8e774f1772b6961ba82e69c770a904c20c8c53 (patch) | |
tree | d4df909e79190396a35a13c3ef99d835287042f8 /phc-intel.sh | |
download | aur-3d8e774f1772b6961ba82e69c770a904c20c8c53.tar.gz |
Initial commit.
Diffstat (limited to 'phc-intel.sh')
-rw-r--r-- | phc-intel.sh | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/phc-intel.sh b/phc-intel.sh new file mode 100644 index 000000000000..cce4bf96ad91 --- /dev/null +++ b/phc-intel.sh @@ -0,0 +1,55 @@ +#!/bin/bash -e +shopt -s nullglob + +case "$1" in +start) + . /etc/default/phc-intel + if [ -z "$VIDS" ]; then + echo '=> Please edit /etc/default/phc-intel' + exit 1 + fi + echo ':: Setting PHC VIDs' + for i in /sys/devices/system/cpu/cpu*/cpufreq/phc_vids; do + echo $VIDS > "$i" + done + ;; +stop) + echo ':: Resetting default PHC VIDs' + for i in /sys/devices/system/cpu/cpu*/cpufreq/phc_vids; do + cp "${i%vids}default_vids" "$i" + done + ;; +status) + check_off () { + for i in /sys/devices/system/cpu/cpu*/cpufreq/phc_vids; do + [ "$(< "$i")" = "$(< "${i%vids}default_vids")" ] || return; + done + } + check_on () { + for i in /sys/devices/system/cpu/cpu*/cpufreq/phc_vids; do + [[ "$(< "$i")" =~ "$VIDS" ]] || return; + done + } + echo -n 'PHC status: ' + . /etc/default/phc-intel + if check_off; then + echo 'inactive' + elif check_on; then + echo 'active' + else + echo 'unknown' + fi + ;; +set) + . /etc/default/phc-intel + [ -z "$VIDS" ] && exit + for i in $(< /proc/cmdline); do + [ $i = nophc ] && exit + done + for i in /sys/devices/system/cpu/cpu*/cpufreq/phc_vids; do + echo $VIDS > "$i" + done + ;; +*) + echo "usage: $0 {start|stop|status|set}" +esac |