summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorPedro Gabriel Drumond Pereira2015-07-26 19:16:21 -0300
committerPedro Gabriel Drumond Pereira2015-07-26 19:16:21 -0300
commite14ec91050dfe038716672f01564ef8de8d9ee32 (patch)
treec48e77c28cac95db1d73893a0be929879ff03ee8
downloadaur-e14ec91050dfe038716672f01564ef8de8d9ee32.tar.gz
Initial import
-rw-r--r--.SRCINFO34
-rw-r--r--0001_Use_cpupower.patch12
-rw-r--r--PKGBUILD66
-rw-r--r--indicator-cpufreq.rules46
-rw-r--r--indicator-powersave.patch268
-rwxr-xr-xthrottle274
-rw-r--r--throttle-cut.service11
7 files changed, 711 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO
new file mode 100644
index 000000000000..a2525163b796
--- /dev/null
+++ b/.SRCINFO
@@ -0,0 +1,34 @@
+pkgbase = indicator-powersave
+ pkgdesc = User discretion power managment utility forked from CPU frequency indicator (bzr version)
+ pkgver = r97
+ pkgrel = 4
+ url = https://launchpad.net/indicator-cpufreq
+ arch = any
+ license = GPL
+ makedepends = python2-distutils-extra
+ depends = cpupower
+ depends = libappindicator-gtk3
+ depends = python-dbus
+ depends = python-gobject
+ depends = pygtk
+ depends = polkit-gnome
+ depends = gtk-update-icon-cache
+ provides = indicator-cpufreq
+ provides = indicator-cpufreq-bzr
+ conflicts = indicator-cpufreq
+ conflicts = indicator-cpufreq-bzr
+ source = bzr+lp:indicator-cpufreq
+ source = indicator-cpufreq.rules
+ source = 0001_Use_cpupower.patch
+ source = indicator-powersave.patch
+ source = throttle
+ source = throttle-cut.service
+ sha512sums = SKIP
+ sha512sums = 99bf1e503baf936cd621c282d468903220e3e445a399a72f66d035dc4ad960d63d311ec9a52fabcd94116bc406b7a77e4414f1b5166d0c92af164b2d939ee940
+ sha512sums = 8aad00c00a95d71f221647263422eef89a0207bdb55d883520f3871f28551c316860560207c96144e22dda2ab5f5fc9b8c7bfa0fc642283de160bfd61458b8c0
+ sha512sums = 66cb9af6cbd6ab477851e59eb971e21afc7acaba9668dfb77d055ff1f80822e489a1a0f4ae96a7404a89701da03972af43e8b34f72269d9ce8211c61d2cf487a
+ sha512sums = 29b20b6312e1a3afbf955be11d51b3a3ef096cecb265f34e05c56a145a518285c464c99a812293eea7a3fe30a5344837dec2efddad9f1ef7953480645dca9168
+ sha512sums = d94cac93cb8593c59f4e7d4eb5bb2991bc0484f47e430645bcea989d1b89aaf9669470d2bcd36beabaf3822526d8902f43648f6a021fa10c56cf1adaedecfced
+
+pkgname = indicator-powersave
+
diff --git a/0001_Use_cpupower.patch b/0001_Use_cpupower.patch
new file mode 100644
index 000000000000..73c2588caace
--- /dev/null
+++ b/0001_Use_cpupower.patch
@@ -0,0 +1,12 @@
+diff -Nru indicator-cpufreq-0.1.4.orig/indicator_cpufreq/cpufreq.py indicator-cpufreq-0.1.4/indicator_cpufreq/cpufreq.py
+--- indicator-cpufreq-0.1.4.orig/indicator_cpufreq/cpufreq.py 2012-10-23 17:26:18.919464853 -0400
++++ indicator-cpufreq-0.1.4/indicator_cpufreq/cpufreq.py 2012-10-23 17:26:44.372792374 -0400
+@@ -17,7 +17,7 @@
+ from ctypes import *
+ from ctypes.util import find_library
+
+-_libcpufreq = cdll.LoadLibrary(find_library("cpufreq"))
++_libcpufreq = cdll.LoadLibrary(find_library("cpupower"))
+
+ class _cpufreq_policy(Structure):
+ _fields_ = [
diff --git a/PKGBUILD b/PKGBUILD
new file mode 100644
index 000000000000..4a051e434a07
--- /dev/null
+++ b/PKGBUILD
@@ -0,0 +1,66 @@
+# Maintainer: Pedro Gabriel <pedrogabriel@dcc.ufmg.br>
+# Contributor: Que Quotion <quequotion@mailinator.com>
+# Contributor: Xiao-Long Chen <chenxiaolongcxl.epac.to>
+
+pkgname=indicator-powersave
+pkgver=r97
+pkgrel=4
+pkgdesc="User discretion power managment utility forked from CPU frequency indicator (bzr version)"
+arch=('any')
+url="https://launchpad.net/indicator-cpufreq"
+license=('GPL')
+depends=('cpupower' 'libappindicator-gtk3' 'python-dbus' 'python-gobject' 'pygtk' 'polkit-gnome' 'gtk-update-icon-cache')
+makedepends=('python2-distutils-extra')
+provides=('indicator-cpufreq' 'indicator-cpufreq-bzr')
+conflicts=('indicator-cpufreq' 'indicator-cpufreq-bzr')
+source=("bzr+lp:indicator-cpufreq"
+ 'indicator-cpufreq.rules'
+ '0001_Use_cpupower.patch'
+ 'indicator-powersave.patch'
+ 'throttle'
+ 'throttle-cut.service')
+sha512sums=('SKIP'
+ '99bf1e503baf936cd621c282d468903220e3e445a399a72f66d035dc4ad960d63d311ec9a52fabcd94116bc406b7a77e4414f1b5166d0c92af164b2d939ee940'
+ '8aad00c00a95d71f221647263422eef89a0207bdb55d883520f3871f28551c316860560207c96144e22dda2ab5f5fc9b8c7bfa0fc642283de160bfd61458b8c0'
+ '66cb9af6cbd6ab477851e59eb971e21afc7acaba9668dfb77d055ff1f80822e489a1a0f4ae96a7404a89701da03972af43e8b34f72269d9ce8211c61d2cf487a'
+ '29b20b6312e1a3afbf955be11d51b3a3ef096cecb265f34e05c56a145a518285c464c99a812293eea7a3fe30a5344837dec2efddad9f1ef7953480645dca9168'
+ 'd94cac93cb8593c59f4e7d4eb5bb2991bc0484f47e430645bcea989d1b89aaf9669470d2bcd36beabaf3822526d8902f43648f6a021fa10c56cf1adaedecfced')
+
+pkgver() {
+ cd indicator-cpufreq
+ printf "r%s" "$(bzr revno)"
+}
+
+prepare() {
+ cd "${srcdir}/indicator-cpufreq"
+
+ patch -Np1 -i "${srcdir}/0001_Use_cpupower.patch"
+ patch -Np1 -i "${srcdir}/indicator-powersave.patch"
+}
+
+package() {
+ cd "${srcdir}/indicator-cpufreq"
+ python setup.py install --root="${pkgdir}/" --optimize=1
+
+ install -dm700 -o polkitd:root "${pkgdir}/usr/share/polkit-1/rules.d/"
+ install -m644 "${srcdir}/indicator-cpufreq.rules" \
+ "${pkgdir}/usr/share/polkit-1/rules.d/"
+
+ # Don't install throttle script if user has a personalized copy
+ if [ ! -f "/usr/local/sbin/throttle" ]; then
+ install -Dm755 "${srcdir}/throttle" "${pkgdir}/usr/bin/throttle"
+ fi
+ install -Dm644 "${srcdir}/throttle-cut.service" "${pkgdir}/etc/systemd/system/throttle-cut.service"
+}
+
+post_install() {
+ gtk-update-icon-cache -q -t -f usr/share/icons/hicolor
+}
+
+post_upgrade() {
+ post_install $1
+}
+
+post_remove() {
+ post_install $1
+}
diff --git a/indicator-cpufreq.rules b/indicator-cpufreq.rules
new file mode 100644
index 000000000000..dc28dd7895a9
--- /dev/null
+++ b/indicator-cpufreq.rules
@@ -0,0 +1,46 @@
+/* Original:
+ * [Change CPU Frequency scaling]
+ * Identity=unix-group:wheel
+ * Action=com.ubuntu.indicatorcpufreqselector.setfrequencyscaling
+ * ResultActive=yes
+ */
+
+polkit.addRule(function(action, subject) {
+ if ((action.id == "com.ubuntu.indicatorcpufreqselector.setthrottle")
+ && subject.local
+ && subject.active {
+ return polkit.Result.YES;
+ }
+});
+
+polkit.addRule(function(action, subject) {
+ if ((action.id == "com.ubuntu.indicatorcpufreqselector.setfrequencyscaling")
+ && subject.local
+ && subject.active {
+ return polkit.Result.YES;
+ }
+});
+
+polkit.addRule(function(action, subject) {
+ if ((action.id == "com.ubuntu.indicatorcpufreqselector.setpsturbo")
+ && subject.local
+ && subject.active {
+ return polkit.Result.YES;
+ }
+});
+
+polkit.addRule(function(action, subject) {
+ if ((action.id == "com.ubuntu.indicatorcpufreqselector.sethyperthreads")
+ && subject.local
+ && subject.active {
+ return polkit.Result.YES;
+ }
+});
+
+polkit.addRule(function(action, subject) {
+ if ((action.id == "com.ubuntu.indicatorcpufreqselector.setgputhrottle")
+ && subject.local
+ && subject.active {
+ return polkit.Result.YES;
+ }
+});
diff --git a/indicator-powersave.patch b/indicator-powersave.patch
new file mode 100644
index 000000000000..2762b2e514a1
--- /dev/null
+++ b/indicator-powersave.patch
@@ -0,0 +1,268 @@
+--- indicator-cpufreq/bin/indicator-cpufreq-selector 2014-12-27 02:48:58.330816000 +0900
++++ indicator-cpufreq/bin/indicator-cpufreq-selector 2014-12-27 02:25:45.903998358 +0900
+@@ -21,6 +21,8 @@
+ import dbus.service
+ import dbus.mainloop.glib
+
++import subprocess
++
+ from indicator_cpufreq import cpufreq
+
+ class PermissionDeniedByPolicy(dbus.DBusException):
+@@ -42,6 +44,15 @@
+ self._package_operation_in_progress = False
+
+ @dbus.service.method(dbus_interface='com.ubuntu.IndicatorCpufreqSelector',
++ in_signature='as',
++ out_signature='',
++ sender_keyword='sender',
++ connection_keyword='conn')
++ def SetThrottle(self, throttle, sender=None, conn=None):
++ self._check_polkit_privilege(sender, conn, 'com.ubuntu.indicatorcpufreqselector.setthrottle')
++ error = subprocess.Popen(["/bin/sh", "throttle", throttle])
++
++ @dbus.service.method(dbus_interface='com.ubuntu.IndicatorCpufreqSelector',
+ in_signature='auu',
+ out_signature='',
+ sender_keyword='sender',
+@@ -61,6 +72,33 @@
+ for cpu in cpus:
+ error = cpufreq.modify_policy_governor(cpu, governor)
+
++ @dbus.service.method(dbus_interface='com.ubuntu.IndicatorCpufreqSelector',
++ in_signature='as',
++ out_signature='',
++ sender_keyword='sender',
++ connection_keyword='conn')
++ def SetPSTurbo(self, psturbo, sender=None, conn=None):
++ self._check_polkit_privilege(sender, conn, 'com.ubuntu.indicatorcpufreqselector.setpsturbo')
++ error = subprocess.Popen(["/bin/sh", "throttle", psturbo])
++
++ @dbus.service.method(dbus_interface='com.ubuntu.IndicatorCpufreqSelector',
++ in_signature='as',
++ out_signature='',
++ sender_keyword='sender',
++ connection_keyword='conn')
++ def SetHyperthreads(self, hyperthreads, sender=None, conn=None):
++ self._check_polkit_privilege(sender, conn, 'com.ubuntu.indicatorcpufreqselector.sethyperthreads')
++ error = subprocess.Popen(["/bin/sh", "throttle", hyperthreads])
++
++ @dbus.service.method(dbus_interface='com.ubuntu.IndicatorCpufreqSelector',
++ in_signature='as',
++ out_signature='',
++ sender_keyword='sender',
++ connection_keyword='conn')
++ def SetGPUThrottle(self, gputhrottle, sender=None, conn=None):
++ self._check_polkit_privilege(sender, conn, 'com.ubuntu.indicatorcpufreqselector.setgputhrottle')
++ error = subprocess.Popen(["/bin/sh", "throttle", gputhrottle])
++
+ def _check_polkit_privilege(self, sender, conn, privilege):
+ '''Verify that sender has a given PolicyKit privilege.
+
+--- indicator-cpufreq/indicator_cpufreq/com.ubuntu.indicatorcpufreq.policy.in 2014-12-27 02:48:58.330816000 +0900
++++ indicator-cpufreq/indicator_cpufreq/com.ubuntu.indicatorcpufreq.policy.in 2014-12-27 02:29:19.809678757 +0900
+@@ -13,13 +13,55 @@
+ <vendor_url>https://launchpad.net/indicator-cpufreq</vendor_url>
+ <icon_name>indicator-cpufreq</icon_name>
+
++ <action id="com.ubuntu.indicatorcpufreqselector.setthrottle">
++ <_description>Change device powersaving settings</_description>
++ <_message>System policy prevents you from changing system throttle.</_message>
++
++ <defaults>
++ <allow_inactive>no</allow_inactive>
++ <allow_active>yes</allow_active>
++ </defaults>
++ </action>
++
+ <action id="com.ubuntu.indicatorcpufreqselector.setfrequencyscaling">
+ <_description>Change CPU frequency scaling</_description>
+ <_message>System policy prevents you from changing CPU frequency scaling.</_message>
+
+ <defaults>
+ <allow_inactive>no</allow_inactive>
+- <allow_active>auth_admin_keep</allow_active>
++ <allow_active>yes</allow_active>
++ </defaults>
++ </action>
++
++ <action id="com.ubuntu.indicatorcpufreqselector.setpsturbo">
++ <_description>Change Intel P-State Turbo settings</_description>
++ <_message>System policy prevents you from changing P-State Turbo.</_message>
++
++ <defaults>
++ <allow_inactive>no</allow_inactive>
++ <allow_active>yes</allow_active>
++ </defaults>
++ </action>
++
++ <action id="com.ubuntu.indicatorcpufreqselector.sethyperthreads">
++ <_description>Change hyperthreading settings</_description>
++ <_message>System policy prevents you from changing hyperthreading.</_message>
++
++ <defaults>
++ <allow_inactive>no</allow_inactive>
++ <allow_active>yes</allow_active>
+ </defaults>
+ </action>
++
++ <action id="com.ubuntu.indicatorcpufreqselector.setgputhrottle">
++ <_description>Change GPU throttle settings</_description>
++ <_message>System policy prevents you from changing GPU throttle.</_message>
++
++ <defaults>
++ <allow_inactive>no</allow_inactive>
++ <allow_active>yes</allow_active>
++ </defaults>
++ </action>
++
++
+ </policyconfig>
+--- indicator-cpufreq/indicator_cpufreq/indicator.py 2014-12-27 02:48:58.330816000 +0900
++++ indicator-cpufreq/indicator_cpufreq/indicator.py 2014-12-27 02:47:58.102868291 +0900
+@@ -29,6 +29,10 @@
+ from gettext import gettext as _
+ #gettext.textdomain('indicator-cpufreq')
+
++
++def readable_throttle(t):
++ return t
++
+ def readable_frequency(f):
+ # temp hack for properly displaying intel turbo mode (actual freq + 1000kHz)
+ label = _("%s GHz") % locale.format(_("%.2f"), f / 1.0e6)
+@@ -50,6 +54,15 @@
+ else:
+ return g
+
++def readable_psturbo(t):
++ return t
++
++def readable_hyperthreads(h):
++ return h
++
++def readable_gputhrottles(gt):
++ return gt
++
+ class MyIndicator(object):
+ def __init__(self, show_frequency=False):
+ self.show_frequency = show_frequency
+@@ -70,29 +83,91 @@
+ while cpufreq.cpu_exists(maxcpu) == 0:
+ maxcpu += 1
+ self.cpus = range(maxcpu)
+
++ # throttle menu items
++ throttles = ['full', 'cut']
++ throtmenu = Gtk.Menu()
++ throtm = Gtk.MenuItem("System Throttle")
++ throtm.set_submenu(throtmenu)
++ for toggle in throttles:
++ menu_item = Gtk.RadioMenuItem.new_with_label(group, readable_throttle(toggle))
++ group = menu_item.get_group()
++ throtmenu.append(menu_item)
++ menu_item.connect('activate', self.select_activated, 'throttle', toggle)
++ self.select_items[toggle] = menu_item
++ menu.append(throtm)
++
++ menu.append(Gtk.SeparatorMenuItem())
++
+ # frequency menu items
+ #freqs = cpufreq.get_available_frequencies(self.cpus[0])
+ freqs = reversed(sorted(set(cpufreq.get_available_frequencies(self.cpus[0]))))
++ freqmenu = Gtk.Menu()
++ freqm = Gtk.MenuItem("CPU Frequency")
++ freqm.set_submenu(freqmenu)
+ for freq in freqs:
+ menu_item = Gtk.RadioMenuItem.new_with_label(group, readable_frequency(freq))
+ group = menu_item.get_group()
+- menu.append(menu_item)
++ freqmenu.append(menu_item)
+ menu_item.connect("activate", self.select_activated, 'frequency', freq)
+ self.select_items[freq] = menu_item
++ menu.append(freqm)
+
+- menu.append(Gtk.SeparatorMenuItem())
+-
+ # governor menu items
+ governors = cpufreq.get_available_governors(self.cpus[0])
++ govmenu = Gtk.Menu()
++ govm = Gtk.MenuItem("CPU Governor")
++ govm.set_submenu(govmenu)
+ for governor in governors:
+ if governor == 'userspace':
+ continue
+ menu_item = Gtk.RadioMenuItem.new_with_label(group, readable_governor(governor))
+ group = menu_item.get_group()
+- menu.append(menu_item)
++ govmenu.append(menu_item)
+ menu_item.connect('activate', self.select_activated, 'governor', governor)
+ self.select_items[governor] = menu_item
++ menu.append(govm)
++
++ # p-state turbo menu items
++ psturbo = ['on', 'off']
++ pstmenu = Gtk.Menu()
++ pstm = Gtk.MenuItem("P-State Turbo")
++ pstm.set_submenu(pstmenu)
++ for toggle in psturbo:
++ menu_item = Gtk.RadioMenuItem.new_with_label(group, readable_psturbo(toggle))
++ group = menu_item.get_group()
++ pstmenu.append(menu_item)
++ menu_item.connect('activate', self.select_activated, 'psturbo', toggle)
++ self.select_items[toggle] = menu_item
++ menu.append(pstm)
++
++ # hyperthreading menu items
++ hyperthreads = ['on', 'off']
++ htmenu = Gtk.Menu()
++ htm = Gtk.MenuItem("Hyperthreads")
++ htm.set_submenu(htmenu)
++ for toggle in hyperthreads:
++ menu_item = Gtk.RadioMenuItem.new_with_label(group, readable_hyperthreads(toggle))
++ group = menu_item.get_group()
++ htmenu.append(menu_item)
++ menu_item.connect('activate', self.select_activated, 'hyperthreads', toggle)
++ self.select_items[toggle] = menu_item
++ menu.append(htm)
++
++ menu.append(Gtk.SeparatorMenuItem())
++
++ # gpu runtime pm menu items
++ gputhrottles = ['full', 'cut']
++ gpumenu = Gtk.Menu()
++ gpum = Gtk.MenuItem("GPU Throttle")
++ gpum.set_submenu(gpumenu)
++ for toggle in gputhrottles:
++ menu_item = Gtk.RadioMenuItem.new_with_label(group, readable_gputhrottles(toggle))
++ group = menu_item.get_group()
++ gpumenu.append(menu_item)
++ menu_item.connect('activate', self.select_activated, 'gputhrottle', toggle)
++ self.select_items[toggle] = menu_item
++ menu.append(gpum)
+
+ menu.show_all()
+ self.ind.set_menu(menu)
+@@ -134,9 +210,21 @@
+ bus = dbus.SystemBus()
+ proxy = bus.get_object("com.ubuntu.IndicatorCpufreqSelector", "/Selector", introspect=False)
+ cpus = [dbus.UInt32(cpu) for cpu in self.cpus]
+- if select == 'frequency':
++ if select == 'throttle':
++ proxy.SetThrottle(value,
++ dbus_interface='com.ubuntu.IndicatorCpufreqSelector')
++ elif select == 'frequency':
+ proxy.SetFrequency(cpus, dbus.UInt32(value),
+ dbus_interface='com.ubuntu.IndicatorCpufreqSelector')
++ elif select == 'psturbo':
++ proxy.SetPSTurbo("turbo-" + value,
++ dbus_interface='com.ubuntu.IndicatorCpufreqSelector')
++ elif select == 'hyperthreads':
++ proxy.SetHyperthreads("ht-" + value,
++ dbus_interface='com.ubuntu.IndicatorCpufreqSelector')
++ elif select == 'gputhrottle':
++ proxy.SetGPUThrottle("gpu-" + value,
++ dbus_interface='com.ubuntu.IndicatorCpufreqSelector')
+ else:
+ proxy.SetGovernor(cpus, value,
+ dbus_interface='com.ubuntu.IndicatorCpufreqSelector')
diff --git a/throttle b/throttle
new file mode 100755
index 000000000000..a96c49e8c04a
--- /dev/null
+++ b/throttle
@@ -0,0 +1,274 @@
+#!/bin/bash
+
+while (( "$#" )); do
+ #Find the number of physical cores (for hyperthreading control)
+ CORES="$(grep "^core id" /proc/cpuinfo | sort -u | wc -l)"
+ case "$1" in
+ full|performance|cut|powersave)
+ case "$1" in
+ full|performance)
+ GOVERNOR="performance"
+ XPSTURBO="0"
+ HYPERTHREADS="1"
+ ENERGYPERF="0"
+ LAPTOP="0"
+ DIRTYWBC="500"
+ NMIDOG="0" # Always off
+ POLICY="max_performance"
+ APM="255"
+ AAM="254"
+ CONTROL="on"
+ AUTOSUSPEND="-1"
+ POWERSAVE="0"
+ CONTROLLER="N"
+ WLPOWERSAVE="off"
+ WOLA="g"
+ WOLB="enabled"
+ LEDBRIGHT="255"
+ NVPM="1"
+ ;;
+ cut|powersave)
+ GOVERNOR="powersave"
+ XPSTURBO="1"
+ HYPERTHREADS="0"
+ ENERGYPERF="15"
+ LAPTOP="5"
+ DIRTYWBC="1500"
+ NMIDOG="0"
+ POLICY="min_power"
+ APM="1"
+ AAM="128"
+ CONTROL="auto"
+ AUTOSUSPEND="1"
+ POWERSAVE="1"
+ CONTROLLER="Y"
+ WLPOWERSAVE="on"
+ WOLA="d"
+ WOLB="disabled"
+ LEDBRIGHT="0"
+ NVPM="0"
+ ;;
+ esac
+
+ # CPU Governor
+ for i in /sys/bus/cpu/drivers/processor/cpu*/cpufreq/scaling_governor; do [[ -f "${i}" ]] && \
+ printf "${GOVERNOR}" > "${i}" & done &
+
+ # Disable Intel P-State Turbo
+ [[ -f /sys/devices/system/cpu/intel_pstate/no_turbo ]] && \
+ printf "${XPSTURBO}" > /sys/devices/system/cpu/intel_pstate/no_turbo &
+
+ # Hyperthreads
+ for i in /sys/devices/system/cpu/cpu*/online; do [[ -f "${i}" ]] && \
+ [[ "$(printf "${i}" | tr -cd [:digit:])" -ge "${CORES}" ]] && \
+ printf "${HYPERTHREADS}" > "${i}" & done &
+ wait # for cpus on/off
+
+ # ENERGY_PERF_BIAS
+ [[ -n "$(command -v x86_energy_perf_policy)" ]] && \
+ x86_energy_perf_policy "${ENERGYPERF}" &
+
+ # Virtual Memory (Swap)
+ printf "${LAPTOP}" > /proc/sys/vm/laptop_mode &
+ printf "${DIRTYWBC}" > /proc/sys/vm/dirty_writeback_centisecs &
+ printf "${DIRTYWBC}" > /proc/sys/vm/dirty_expire_centisecs &
+
+ # NMI watchdog
+ [[ -f /proc/sys/kernel/watchdog ]] && \
+ printf "${NMIDOG}" > /proc/sys/kernel/watchdog &
+
+ # SATA link power management
+ for i in /sys/class/scsi_host/host*/link_power_management_policy; do [[ -f "${i}" ]] && \
+ printf "${POLICY}" > "${i}" & done &
+
+ # Hard drives
+ [[ -n "$(command -v hdparm)" ]] && \
+ hdparm -qB "${APM}" -qM "${AAM}" /dev/[hs]d[a-z] 2> /dev/null &
+
+ # Runtime power management for devices (by class and bus)
+ for i in /sys/{class/*,bus/*/devices}/*/power/control; do [[ -f "${i}" ]] && \
+ printf "$CONTROL" > "${i}" & done &
+
+ # USB Autosuspend (may disable some older devices!)
+ for i in /sys/bus/usb/devices/*/power/autosuspend{,_delay_ms}; do [[ -f "${i}" ]] && \
+ printf "$AUTOSUSPEND" > "${i}" & done &
+
+ # Powersaving for modules
+ for i in /sys/module/*/parameters/power_save; do \
+ printf "${POWERSAVE}" > "${i}" & done &
+ for i in /sys/module/*/parameters/power_save_controller; do \
+ printf "${CONTROLLER}" > "${i}" & done &
+
+ # Network powersaving
+ for i in /sys/class/net/wl*; do [[ -d "${i}" ]] && \
+ [[ -n "$(command -v iw)" ]] && \
+ iw dev "$(printf "${i}" | sed 's/^.*wl/wl/')" set power_save "${WLPOWERSAVE}" 2> /dev/null & done &
+ for i in /sys/class/net/e*; do [[ -d "${i}" ]] && \
+ [[ -n "$(command -v ethtool)" ]] && \
+ ethtool -s "$(printf "${i}" | sed 's/^.*e/e/')" wol "${WOLA}" 2> /dev/null & done &
+ for i in /sys/class/net/*/device/power/wakeup; do [[ -f "${i}" ]] && \
+ printf "${WOLB}" > "${i}" & done &
+
+ # LEDs
+ for i in /sys/class/leds/*/brightness; do [[ -f "${i}" ]] && \
+ printf "${LEDBRIGHT}" > "${i}" & done &
+
+ # Nvidia PowerMizer
+ [[ -n "$(command -v nvidia-settings)" ]] && \
+ DISPLAY=":0.0" nvidia-settings -a [gpu:0]/GPUPowerMizerMode="${NVPM}" > /dev/null &
+
+ wait # Hey, let's stop! :) *stops* ... YAY! =D
+ shift
+ unset GOVERNOR XPSTURBO HYPERTHREADS ENERGYPERF LAPTOP DIRTYWBC NMIDOG \
+ POLICY APM AAM CONTROL AUTOSUSPEND POWERSAVE CONTROLLER \
+ WLPOWERSAVE WOLA WOLB LEDBRIGHT NVPM
+ ;;
+ gov*)
+ case "${1}" in \
+ gov-full) GOVERNOR="performance" ;; \
+ gov-cut) GOVERNOR="powersave" ;; esac
+ [[ -z "${GOVERNOR}" ]] && \
+ case "${2}" in \
+ full|performance) GOVERNOR="performance"; SHIFT="2" ;; \
+ cut|powersave) GOVERNOR="powersave"; SHIFT="2" ;; esac
+ [[ -z "${GOVERNOR}" ]] && \
+ printf "${0} gov {cut,full} - CPU Governor\n" || \
+ for i in /sys/bus/cpu/drivers/processor/cpu*/cpufreq/scaling_governor; do [[ -f "${i}" ]] && \
+ printf "${GOVERNOR}" > ${i} & done &
+ shift "${SHIFT}"
+ wait
+ unset GOVERNOR SHIFT
+ ;;
+ turbo*)
+ case "${1}" in \
+ turbo-on) XPSTURBO="0" ;; \
+ turbo-off) XPSTURBO="1" ;; esac
+ [[ -z "${XPSTURBO}" ]] && \
+ case "${2}" in \
+ on|performance) XPSTURBO="0"; SHIFT="2" ;; \
+ off|powersave) XPSTURBO="1"; SHIFT="2" ;; esac
+ [[ -z "${XPSTURBO}" ]] && \
+ printf "${0} turbo {on,off} - Intel P-State Turbo\n" || \
+ [[ -f /sys/devices/system/cpu/intel_pstate/no_turbo ]] && \
+ printf "${XPSTURBO}" > /sys/devices/system/cpu/intel_pstate/no_turbo &
+ shift "${SHIFT}"
+ wait
+ unset XPSTURBO SHIFT
+ ;;
+ ht*)
+ case "${1}" in \
+ ht-on) HYPERTHREADS="1" ;; \
+ ht-off) HYPERTHREADS="0" ;; esac
+ [[ -z "${HYPERTHREADS}" ]] && \
+ case "${2}" in \
+ on|performance) HYPERTHREADS="1"; SHIFT="2" ;; \
+ off|powersave) HYPERTHREADS="0"; SHIFT="2" ;; esac
+ [[ -z "${HYPERTHREADS}" ]] && \
+ printf "${0} ht {on,off} - Hyperthreads\n" || \
+ for i in /sys/devices/system/cpu/cpu*/online; do [[ -f "${i}" ]] && \
+ [[ "$(printf "${i}" | tr -cd [:digit:])" -ge "${CORES}" ]] && \
+ printf "${HYPERTHREADS}" > "${i}" & done &
+ shift "${SHIFT}"
+ wait
+ unset HYPERTHREADS SHIFT
+ ;;
+ gpu*)
+ case "${1}" in \
+ gpu-full) NVPM="1" ;; \
+ gpu-cut) NVPM="0" ;; esac
+ [[ -z "${NVPM}" ]] && \
+ case "${2}" in \
+ full|performance) NVPM="1"; SHIFT="2" ;; \
+ cut|powersave) NVPM="0"; SHIFT="2" ;; esac
+ [[ -z "${NVPM}" ]] && \
+ printf "${0} gpu {cut,full} - GPU runtime powersaving (only Nvidia ATM)\n" || \
+ [[ -z "$(command -v nvidia-settings)" ]] && \
+ printf "nvidia-settings not found; only nvidia currently supported" || \
+ DISPLAY=":0.0" nvidia-settings -a [gpu:0]/GPUPowerMizerMode="${NVPM}" > /dev/null &
+ shift "${SHIFT}"
+ wait
+ unset NVPM SHIFT
+ ;;
+ check)
+ printf "\nCPU Governor\n/sys/bus/cpu/drivers/processor/cpu*/cpufreq/scaling_governor\n"
+ for i in /sys/bus/cpu/drivers/processor/cpu*/cpufreq/scaling_governor; do [[ -f "${i}" ]] && \
+ printf "${i}\n$(cat ${i})\n"; done | sed 's|/sys/bus/cpu/drivers/processor/||g; s|/.*||g; N;s|\n|\t|'
+
+ [[ -f /sys/devices/system/cpu/intel_pstate/no_turbo ]] && \
+ printf "\nDisable Intel P-State Turbo\n/sys/devices/system/cpu/intel_pstate/no_turbo\n"; \
+ printf "no_turbo\n$(cat /sys/devices/system/cpu/intel_pstate/no_turbo)\n" | sed 'N;s|\n|\t|'
+
+ printf "\nHyperthreads\n/sys/devices/system/cpu/cpu*/online\n"
+ for i in /sys/devices/system/cpu/cpu*/online; do [[ -f "${i}" ]] && \
+ [[ $(printf "${i}" | tr -cd [:digit:]) -ge "$CORES" ]] && \
+ printf "${i}\n$(cat ${i})\n"; done | sed 's|/sys/devices/system/cpu/||g; s|/.*||g; N;s|\n|\t|'
+
+ [[ -z "$(command -v x86_energy_perf_policy)" ]] && \
+ printf "\nEnergy Perf Bias\n" && \
+ x86_energy_perf_policy -r #SUID
+
+ printf "\nVirtual Memory (Swap)\n/proc/sys/vm/\n"
+ printf "laptop_mode\t$(cat /proc/sys/vm/laptop_mode)\n"
+ printf "dirty_writeback_centisecs\t$(cat /proc/sys/vm/dirty_writeback_centisecs)\n"
+ printf "dirty_expire_centisecs\t$(cat /proc/sys/vm/dirty_expire_centisecs)\n"
+
+ [[ -f /proc/sys/kernel/watchdog ]] && \
+ printf "\nNMI watchdog\n" && \
+ printf "/proc/sys/kernel/watchdog\t$(cat /proc/sys/kernel/watchdog)\n"
+
+ printf "\nSATA link power management\n/sys/class/scsi_host/host*/link_power_management_policy\n"
+ for i in /sys/class/scsi_host/host*/link_power_management_policy; do [[ -f "${i}" ]] && \
+ printf "${i}\n$(cat ${i})\n"; done | sed 's|/sys/class/scsi_host/||g; s|/.*||g; N;s|\n|\t|'
+
+ [[ -n "$(command -v hdparm)" ]] && \
+ printf "\nHard drives\n/dev/[hs]d[a-z]\n" && \
+ hdparm -B -M /dev/[hs]d[a-z] 2> /dev/null | sed 'N;s|\n||g; s|/dev/||g; s|\t| |g;' #SUID
+
+ printf "\nRuntime power management\n/sys/{class,bus}/*/{*,devices/*}/power/control\n"
+ for i in /sys/{class,bus}/*/{*,devices/*}/power/control; do [[ -f "${i}" ]] && \
+ printf "${i}\n$(cat ${i})\n"; done | sed 's|/sys/class/||g; s|/sys/bus/||g; s|/devices||g; s|/power/control||g; N;s|\n|\t|'
+
+ printf "\nUSB Autosuspend (may disable some older devices!)\n/sys/bus/usb/devices/*/power/autosuspend{,_delay_ms}\n"
+ for i in /sys/bus/usb/devices/*/power/autosuspend{,_delay_ms}; do [[ -f "${i}" ]] && \
+ printf "${i}\n$(cat ${i})\n"; done | sed 's|/sys/bus/usb/devices/||g; s|/.*||g; N;s|\n|\t|'
+
+ printf "\nPower saving for modules\n/sys/module/*/parameters/power_save{,_controller}\n"
+ for i in /sys/module/*/parameters/power_save{,_controller}; do [[ -f "${i}" ]] && \
+ printf "${i}\n$(cat ${i})\n"; done | sed 's|/sys/module/||g; s|/parameters/.*||g; s|/.*||g; N;s|\n|\t|'
+
+ printf "\nNetwork device powersaving\n/sys/class/net/{wl*,e*,*/device/power/wakeup}\n";
+ [[ -n "$(command -v iw)" ]] && \
+ for i in /sys/class/net/wl*; do [[ -d "${i}" ]] && \
+ printf "${i}\n$(iw dev $(printf ${i} | sed 's/^.*wl/wl/') get power_save)"; done | sed 's|^\t| |g;s|/sys/class/net/||g; s|/.*||g'
+ [[ -n "$(command -v ethtool)" ]] && \
+ for i in /sys/class/net/e*; do [[ -d "${i}" ]] && \
+ printf "${i}\n$(ethtool $(printf ${i} | sed 's/^.*e/e/') | grep Wake-on)"; done | sed 's|^\t| |g;s|/sys/class/net/||g; s|/.*||g'
+ for i in /sys/class/net/*/device/power/wakeup; do [[ -f "${i}" ]] && \
+ printf "${i}\n$(cat ${i})\n"; done | sed 's|/sys/class/net/||g; s|/device/power/wakeup||g; s|/.*||g; N;s|\n|\t|'
+
+ printf "\nLEDs\n/sys/class/leds/*/brightness\n"
+ for i in /sys/class/leds/*/brightness; do [[ -f "${i}" ]] && \
+ printf "${i}\n$(cat ${i})\n"; done | sed 's|/sys/class/leds/||g; s|/brightness||g; s|/.*||g; N;s|\n|\t|'
+
+ [[ -n "$(command -v nvidia-settings)" ]] && \
+ printf "\nNvidia PowerMizer\n" && \
+ DISPLAY=":0.0" nvidia-settings -q [gpu:0]/GPUPowerMizerMode | grep "Attribute" | sed 's|.*\[||g;s|\]):||g;s| |\t|g;s|\.$||g'
+ shift
+ ;;
+ *|help)
+ [[ ! "${1}" == "help" ]] && \
+ printf "Invalid input: $@\n"
+ printf "\nRuntime power management:\n"
+ printf "${0} {cut,full} - system-wide runtime powersaving\n"
+ printf "${0} check - inspect runtime powersaving\n"
+ printf "\nExtras:\n"
+ printf "${0} gov {cut,full} - CPU Governor\n"
+ printf "${0} turbo {on,off} - Intel P-State Turbo\n"
+ printf "${0} ht {on,off} - Hyperthreads\n"
+ printf "${0} gpu {cut,full} - GPU runtime powersaving (only Nvidia ATM)\n"
+ printf "\nOptions can take {performace,powersave} and are stackable:\n"
+ printf "\n${0} powersave gov full turbo on gpu full ht on check\n"
+ exit
+ ;;
+ esac
+done
diff --git a/throttle-cut.service b/throttle-cut.service
new file mode 100644
index 000000000000..f87ef8671b0a
--- /dev/null
+++ b/throttle-cut.service
@@ -0,0 +1,11 @@
+[Unit]
+Description=Throttle Cut
+[Service]
+Type=oneshot
+RemainAfterExit=no
+ExecStart=/usr/bin/bash "/usr/local/sbin/throttle cut"
+StandardOutput=null
+StandardError=journal
+
+[Install]
+WantedBy=multi-user.target