summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorQue Quotion2022-02-20 17:31:57 +0900
committerQue Quotion2022-02-20 17:31:57 +0900
commit98f1770efa950a57210cd555a2fa3525cd42cc6f (patch)
tree51bfcd17597567f0f98585c2e20041b563ad7fae
parentb4e1f5ba36c3e7fedce9a1eb6e385524cb6adf3c (diff)
downloadaur-98f1770efa950a57210cd555a2fa3525cd42cc6f.tar.gz
Remove legacy indicator-powersave infrastructure; add no-overlap system devices option
-rw-r--r--.SRCINFO4
-rw-r--r--PKGBUILD4
-rwxr-xr-xthrottlectl132
3 files changed, 71 insertions, 69 deletions
diff --git a/.SRCINFO b/.SRCINFO
index 1b15e1c7e0cd..ec8d1994541c 100644
--- a/.SRCINFO
+++ b/.SRCINFO
@@ -1,6 +1,6 @@
pkgbase = throttlectl
pkgdesc = Command-line user discretion power managment utility
- pkgver = 6
+ pkgver = 7
pkgrel = 1
url = https://bbs.archlinux.org/viewtopic.php?id=180762
arch = any
@@ -19,7 +19,7 @@ pkgbase = throttlectl
source = powersave
source = performance
source = systemstate
- sha512sums = 73ae5d0ec300466921e8e48114d860a684716ecb8fc22e95aeacb59d516dbdc7563325ab8a7b9bd689a13d11dd7249a0efa4b2bc702b2ac8cd16db967e6a6014
+ sha512sums = 0d5de42e2d79ac6535516f7bf079c3d4bd5d572799b23682bef793bf9a63ffdf3542c3150832bb136dd23d4197c39e812aae06263af6c19d42e02077f9d30974
sha512sums = 6254e73446a91ea7945b9e4db1a1047eb2055d93aee315006857711ab21cba140da3badcf5834d2628e4799494a069647d11aa378a9bac67691df8d8b3adc12f
sha512sums = 926f7c787aea8c1027f331fe2e9417ba8e4f15a79f51610baafeed5d0de86d8f41da92f4460c29a5ce251e7cc110e26c2c344931af91949dc529595cc18c0f0e
sha512sums = 0d90ae4c0b9600f50ffd3e2c1a03b49d2fbdb9a2d14c8211e86463787549ada156498f68989d851952fe34660daaacc11242f5ee9e9e318f3d2a3eba0971eb53
diff --git a/PKGBUILD b/PKGBUILD
index 14070dfe0812..8dfa9326bac1 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -1,7 +1,7 @@
# Maintainer: Que Quotion <quequotion@mailinator.com>
pkgname=throttlectl
-pkgver=6
+pkgver=7
pkgrel=1
pkgdesc="Command-line user discretion power managment utility"
arch=('any')
@@ -15,7 +15,7 @@ source=('throttlectl'
'powersave'
'performance'
'systemstate')
-sha512sums=('73ae5d0ec300466921e8e48114d860a684716ecb8fc22e95aeacb59d516dbdc7563325ab8a7b9bd689a13d11dd7249a0efa4b2bc702b2ac8cd16db967e6a6014'
+sha512sums=('0d5de42e2d79ac6535516f7bf079c3d4bd5d572799b23682bef793bf9a63ffdf3542c3150832bb136dd23d4197c39e812aae06263af6c19d42e02077f9d30974'
'6254e73446a91ea7945b9e4db1a1047eb2055d93aee315006857711ab21cba140da3badcf5834d2628e4799494a069647d11aa378a9bac67691df8d8b3adc12f'
'926f7c787aea8c1027f331fe2e9417ba8e4f15a79f51610baafeed5d0de86d8f41da92f4460c29a5ce251e7cc110e26c2c344931af91949dc529595cc18c0f0e'
'0d90ae4c0b9600f50ffd3e2c1a03b49d2fbdb9a2d14c8211e86463787549ada156498f68989d851952fe34660daaacc11242f5ee9e9e318f3d2a3eba0971eb53'
diff --git a/throttlectl b/throttlectl
index f94cb049014a..202ed0dea277 100755
--- a/throttlectl
+++ b/throttlectl
@@ -10,11 +10,12 @@ throttle_help() {
"${0} {{cut,full}} - system-wide runtime powersaving\n"\
"${0} {check} - inspect runtime powersaving\n"\
"\nPer-component power management:\n" \
- "${0} gov {cut,full} - CPU Governor\n"\
+ "${0} sys {cut,full} - System devices\n"\
"${0} turbo {on,off} - Intel P-State Turbo\n"\
"${0} ht {on,off} - Hyperthreads\n"\
- "${0} backlight {0,1,2} - Backlight brightness (laptops only?)\n" \
+ "${0} gov {cut,full} - CPU Governor\n"\
"${0} gpu {cut,full} - GPU runtime powersaving (only Nvidia ATM)\n"\
+ "${0} backlight {0,1,2} - Backlight brightness (laptops only?)\n" \
"\nAll options are stackable and take {{cut,powersave,start},{full,performace,stop},{check,status}}\n"
exit
}
@@ -150,6 +151,9 @@ throttle_system() {
# LEDs
for i in /sys/class/leds/*/brightness; do \
printf "${LEDBRIGHT}" > "${i}" & done &
+
+ # Save state for frontend
+ printf "$SYSTEM" > /etc/throttle.d/systemstate &
}
check_system() {
@@ -207,85 +211,85 @@ check_system() {
printf " ${i}\n$(cat ${i})\n"; done | sed 's|/sys/class/leds/||g; s|/brightness||g; s|/.*||g; N;s|\n|\t|'
}
-#Find the number of physical cores (for hyperthreading control)
-CORES="$(grep "^core id" /proc/cpuinfo | sort -u | wc -l)"
-
while (( "$#" )); do
case "$1" in
- ht*)
- case "${1}" in \
- ht-on) HYPERTHREADS="on" ;; \
- ht-off) HYPERTHREADS="off" ;; esac
+ sys)
+ case "${2}" in
+ cut|off|powersave|start)
+ [[ -f /etc/throttle.d/powersave ]] && . /etc/throttle.d/powersave || config_help; SYSTEM="0"
+ ;;
+ full|on|performance|stop)
+ [[ -f /etc/throttle.d/performance ]] && . /etc/throttle.d/performance || config_help; SYSTEM="1"
+ ;;
+ check|status)
+ check_system
+ ;;
+ esac
+ [[ -n "$SYSTEM" ]] && throttle_system
+ shift "2"
+ unset ENERGYPERF LAPTOP DIRTYWBC NMIDOG POLICY APM AAM CONTROL AUTOSUSPEND POWERSAVE CONTROLLER \
+ WLPOWERSAVE WOLA WOLB LEDBRIGHT SYSTEM
+ ;;
+ turbo)
+ [[ -z "${XPSTURBO}" ]] && \
+ case "${2}" in \
+ cut|off|powersave|start) XPSTURBO="1" ;; \
+ full|on|performance|stop) XPSTURBO="0" ;; \
+ check|status) check_turbo ;; esac
+ [[ -n "${XPSTURBO}" ]] && throttle_turbo
+ shift "2"
+ unset XPSTURBO
+ ;;
+ ht)
[[ -z "${HYPERTHREADS}" ]] && \
case "${2}" in \
- cut|off|powersave|start) HYPERTHREADS="off"; SHIFT="2" ;; \
- full|on|performance|stop) HYPERTHREADS="on"; SHIFT="2" ;; \
- check|status) check_ht; SHIFT="2" ;; esac
+ cut|off|powersave|start) HYPERTHREADS="off" ;; \
+ full|on|performance|stop) HYPERTHREADS="on" ;; \
+ check|status) check_ht ;; esac
[[ -n "${HYPERTHREADS}" ]] && throttle_ht
- [[ -n "${SHIFT}" ]] && shift "${SHIFT}" || shift
- unset HYPERTHREADS SHIFT
+ shift "2"
+ unset HYPERTHREADS
;;
- gov*|cpu)
- case "${1}" in \
- gov-full) GOVERNOR="performance" ;; \
- gov-cut) GOVERNOR="powersave" ;; esac
+ gov|cpu)
[[ -z "${GOVERNOR}" ]] && \
case "${2}" in \
- cut|off|powersave|start) GOVERNOR="powersave"; SHIFT="2" ;; \
- full|on|performance|stop) GOVERNOR="performance"; SHIFT="2" ;; \
- check|status) check_gov; SHIFT="2" ;; esac
+ cut|off|powersave|start) GOVERNOR="powersave" ;; \
+ full|on|performance|stop) GOVERNOR="performance" ;; \
+ check|status) check_gov ;; esac
[[ -n "${GOVERNOR}" ]] && throttle_gov
- [[ -n "${SHIFT}" ]] && shift "${SHIFT}" || shift
- unset GOVERNOR SHIFT
+ shift "2"
+ unset GOVERNOR
;;
- turbo*)
- case "${1}" in \
- turbo-on) XPSTURBO="0" ;; \
- turbo-off) XPSTURBO="1" ;; esac
- [[ -z "${XPSTURBO}" ]] && \
+ gpu)
+ [[ -z "${NVPM}" ]] && \
case "${2}" in \
- cut|off|powersave|start) XPSTURBO="1"; SHIFT="2" ;; \
- full|on|performance|stop) XPSTURBO="0"; SHIFT="2" ;; \
- check|status) check_turbo; SHIFT="2" ;; esac
- [[ -n "${XPSTURBO}" ]] && throttle_turbo
- [[ -n "${SHIFT}" ]] && shift "${SHIFT}" || shift
- unset XPSTURBO SHIFT
+ cut|off|powersave|start) NVPM="0" ;; \
+ full|on|performance|stop) NVPM="1" ;; \
+ check|status) check_nvpm ;; esac
+ [[ -n "${NVPM}" ]] && throttle_nvpm
+ shift "2"
+ unset NVPM
;;
backlight)
- case "${2}" in \
- cut|off|0|powersave|start) BACKLIGHT="0"; SHIFT="2" ;; \
- full|on|1|performance|stop) BACKLIGHT="1"; SHIFT="2" ;; \
- 2) BACKLIGHT="2"; SHIFT="2" ;; \
- check|status) check_backlight; SHIFT="2" ;; esac
- [[ -n "${BACKLIGHT}" ]] && throttle_backlight
- [[ -n "${SHIFT}" ]] && shift "${SHIFT}" || shift
- unset BACKLIGHT SHIFT
- ;;
- gpu*)
- case "${1}" in \
- gpu-full) NVPM="1" ;; \
- gpu-cut) NVPM="0" ;; esac
- [[ -z "${NVPM}" ]] && \
+ [[ -z "${BACKLIGHT}" ]] && \
case "${2}" in \
- cut|off|powersave|start) NVPM="0"; SHIFT="2" ;; \
- full|on|performance|stop) NVPM="1"; SHIFT="2" ;; \
- check|status) check_nvpm; SHIFT="2" ;; esac
- [[ -n "${NVPM}" ]] && throttle_nvpm
- [[ -n "${SHIFT}" ]] && shift "${SHIFT}" || shift
- unset NVPM SHIFT
+ cut|off|0|powersave|start) BACKLIGHT="0" ;; \
+ full|on|1|performance|stop) BACKLIGHT="1" ;; \
+ 2) BACKLIGHT="2" ;; \
+ check|status) check_backlight ;; esac
+ [[ -n "${BACKLIGHT}" ]] && throttle_backlight
+ shift "2"
+ unset BACKLIGHT
;;
- full|performance|start|cut|powersave|stop)
+ full|on|performance|start|cut|off|powersave|stop)
case "${1}" in
- cut|powersave|start)
- [[ -f /etc/throttle.d/powersave ]] && . /etc/throttle.d/powersave || config_help
- printf "0" > /etc/throttle.d/systemstate &
+ cut|off|powersave|start)
+ [[ -f /etc/throttle.d/powersave ]] && . /etc/throttle.d/powersave || config_help; SYSTEM="1"
;;
- full|performance|stop)
- [[ -f /etc/throttle.d/performance ]] && . /etc/throttle.d/performance || config_help
- printf "1" > /etc/throttle.d/systemstate &
+ full|on|performance|stop)
+ [[ -f /etc/throttle.d/performance ]] && . /etc/throttle.d/performance || config_help; SYSTEM="0"
;;
esac
-
throttle_ht
throttle_gov
throttle_turbo
@@ -295,7 +299,7 @@ while (( "$#" )); do
shift
unset GOVERNOR XPSTURBO HYPERTHREADS ENERGYPERF BACKLIGHT LAPTOP DIRTYWBC NMIDOG \
POLICY APM AAM CONTROL AUTOSUSPEND POWERSAVE CONTROLLER \
- WLPOWERSAVE WOLA WOLB LEDBRIGHT NVPM
+ WLPOWERSAVE WOLA WOLB LEDBRIGHT NVPM SYSTEM
;;
check|status)
check_ht
@@ -314,5 +318,3 @@ while (( "$#" )); do
[[ -z "${1}" ]] || wait # Hey, let's stop! :) *stops* ... YAY! =D
done
-
-unset CORES