diff options
author | Que Quotion | 2020-03-28 07:16:10 +0900 |
---|---|---|
committer | Que Quotion | 2020-03-28 07:31:01 +0900 |
commit | 66b7a222f55add806eb2590d1f4bd40460b14a5b (patch) | |
tree | 8c94f8a0bbea2d6df60ba8a4b403ab96b8dc83a3 | |
parent | 153b9e512cea8c5a58ffadd0661f5fdd9dec5c63 (diff) | |
download | aur-66b7a222f55add806eb2590d1f4bd40460b14a5b.tar.gz |
Separate throttle from indicator-powersave
-rw-r--r-- | .SRCINFO | 41 | ||||
-rw-r--r-- | PKGBUILD | 64 | ||||
-rw-r--r-- | com.ubuntu.indicator.policy.in.patch | 60 | ||||
-rw-r--r-- | indicator-cpufreq-selector.patch | 81 | ||||
-rw-r--r-- | indicator-cpufreq.rules | 46 | ||||
-rw-r--r-- | indicator.py.patch | 208 | ||||
-rw-r--r-- | no-cpufreq.patch | 211 | ||||
-rwxr-xr-x | throttlectl (renamed from throttle) | 0 |
8 files changed, 21 insertions, 690 deletions
@@ -1,51 +1,26 @@ -pkgbase = indicator-powersave - pkgdesc = User discretion power managment utility forked from CPU frequency indicator (bzr version) - pkgver = r98.10 +pkgbase = throttlectl + pkgdesc = Command-line user discretion power managment utility + pkgver = 1 pkgrel = 1 - url = https://launchpad.net/indicator-cpufreq - arch = i686 - arch = x86_64 + url = https://bbs.archlinux.org/viewtopic.php?id=180762 + arch = any license = GPL - makedepends = python2-distutils-extra - makedepends = bzr - depends = libappindicator3 - depends = python2 - depends = python2-dbus - depends = python2-gobject - depends = pygtk - depends = polkit-gnome - depends = indicator-application + depends = bash optdepends = x86_energy_perf_policy optdepends = hdparm optdepends = nvidia-utils optdepends = iw optdepends = ethtool - provides = indicator-cpufreq - provides = indicator-cpufreq-bzr - conflicts = indicator-cpufreq - conflicts = indicator-cpufreq-bzr backup = etc/throttle.d/powersave backup = etc/throttle.d/performance - source = bzr+lp:indicator-cpufreq - source = indicator-cpufreq.rules - source = com.ubuntu.indicator.policy.in.patch - source = indicator-cpufreq-selector.patch - source = indicator.py.patch - source = no-cpufreq.patch - source = throttle + source = throttlectl source = throttle-cut.service source = powersave source = performance - sha512sums = SKIP - sha512sums = 5427f1dcd51fe7fb43bbce1bc020a32312e2f82ccf643129b9887262730989197e2ce2cd4494922df058e78bdb8fbe220eccd69588ff917a891d5a56b3366a24 - sha512sums = 9b57d18ef9edc6b609b24f6a62c93c472bc2b72dd158728af1a1d0833a308a72457b0ad32c2d51b357650fa69c0f7f595fa55901ea490a7a3fda3c7c998de2bd - sha512sums = 7e30098e35a72d66a885290a2be2aaf86b72f0242fd4d7ed62e81f9f6e7da378d70c7f7ef54701374dd1440f64173330457cdaf58a3a9bca35a59a57b29123a7 - sha512sums = 1b8b56a841e736d5531632a1c4c229508e1c8a5c840cd2d172e2d89e7aa3a00d549bcd941b209692f8e09bff3739f28f971a1028d3acd4c37cc9176b9425e2a1 - sha512sums = 2b1229ad56651a8d55590256785119da4eba2a2f8d74e57475a8303dc076d5e9067a6481e3245d05557ea0f983d8fa1f1ac02f705fe695f4a4ef79fa86b00b89 sha512sums = 48fac136a0ff11bec6c7c5fc840f81dc2f04dea5fe1132b4af735940e1360cc320f6a59cac573a356bf7ab25166bbc2da6fb9faf981644196d277824a2219337 sha512sums = 0b2de8aa79a837e399684164b29992ae0ab8a2c07412fe837c920e8d3905620ac98d700ee9ee0e8328d398e1d64aea3b01962f0ba573f9a8ff5a41fea5628ace sha512sums = 3d487961bf86254817fd099b888d6245bbf1e57622166dc8df378d639bfb1c0fc105646038be6093183be102294394b88cde382fe961f7606b68619af4a00595 sha512sums = d11ed5f4344f07507497e816ccd7612ffc6df70636ca5f4817a9ce6e3b190b3a17fb02c44c4bf648359f640e4c63cc0b0134968ff4d3d989ad05fa4c095b03d3 -pkgname = indicator-powersave +pkgname = throttlectl @@ -1,68 +1,30 @@ # Maintainer: Que Quotion <quequotion@mailinator.com> -# Contributor: Xiao-Long Chen <chenxiaolongcxl.epac.to> -pkgname=indicator-powersave -pkgver=r98.10 +pkgname=throttlectl +pkgver=1 pkgrel=1 -pkgdesc="User discretion power managment utility forked from CPU frequency indicator (bzr version)" -arch=('i686' 'x86_64') -url="https://launchpad.net/indicator-cpufreq" +pkgdesc="Command-line user discretion power managment utility" +arch=('any') +url="https://bbs.archlinux.org/viewtopic.php?id=180762" license=('GPL') -depends=('libappindicator3' 'python2' 'python2-dbus' 'python2-gobject' 'pygtk' 'polkit-gnome' 'indicator-application') +depends=('bash') optdepends=('x86_energy_perf_policy' 'hdparm' 'nvidia-utils' 'iw' 'ethtool') -makedepends=('python2-distutils-extra' 'bzr') -provides=('indicator-cpufreq' 'indicator-cpufreq-bzr') -conflicts=('indicator-cpufreq' 'indicator-cpufreq-bzr') backup=(etc/throttle.d/{powersave,performance}) -source=("bzr+lp:indicator-cpufreq" - 'indicator-cpufreq.rules' - 'com.ubuntu.indicator.policy.in.patch' - 'indicator-cpufreq-selector.patch' - 'indicator.py.patch' - 'no-cpufreq.patch' - 'throttle' +source=('throttlectl' 'throttle-cut.service' 'powersave' 'performance') -sha512sums=('SKIP' - '5427f1dcd51fe7fb43bbce1bc020a32312e2f82ccf643129b9887262730989197e2ce2cd4494922df058e78bdb8fbe220eccd69588ff917a891d5a56b3366a24' - '9b57d18ef9edc6b609b24f6a62c93c472bc2b72dd158728af1a1d0833a308a72457b0ad32c2d51b357650fa69c0f7f595fa55901ea490a7a3fda3c7c998de2bd' - '7e30098e35a72d66a885290a2be2aaf86b72f0242fd4d7ed62e81f9f6e7da378d70c7f7ef54701374dd1440f64173330457cdaf58a3a9bca35a59a57b29123a7' - '1b8b56a841e736d5531632a1c4c229508e1c8a5c840cd2d172e2d89e7aa3a00d549bcd941b209692f8e09bff3739f28f971a1028d3acd4c37cc9176b9425e2a1' - '2b1229ad56651a8d55590256785119da4eba2a2f8d74e57475a8303dc076d5e9067a6481e3245d05557ea0f983d8fa1f1ac02f705fe695f4a4ef79fa86b00b89' - '48fac136a0ff11bec6c7c5fc840f81dc2f04dea5fe1132b4af735940e1360cc320f6a59cac573a356bf7ab25166bbc2da6fb9faf981644196d277824a2219337' +sha512sums=('48fac136a0ff11bec6c7c5fc840f81dc2f04dea5fe1132b4af735940e1360cc320f6a59cac573a356bf7ab25166bbc2da6fb9faf981644196d277824a2219337' '0b2de8aa79a837e399684164b29992ae0ab8a2c07412fe837c920e8d3905620ac98d700ee9ee0e8328d398e1d64aea3b01962f0ba573f9a8ff5a41fea5628ace' '3d487961bf86254817fd099b888d6245bbf1e57622166dc8df378d639bfb1c0fc105646038be6093183be102294394b88cde382fe961f7606b68619af4a00595' 'd11ed5f4344f07507497e816ccd7612ffc6df70636ca5f4817a9ce6e3b190b3a17fb02c44c4bf648359f640e4c63cc0b0134968ff4d3d989ad05fa4c095b03d3') -pkgver() { - cd indicator-cpufreq - - printf "r%s" "$(bzr revno).10" -} - -prepare() { - cd "${srcdir}/indicator-cpufreq" - - #Indicator-Powersave - patch -Np0 < "${srcdir}/com.ubuntu.indicator.policy.in.patch" - patch -Np0 < "${srcdir}/indicator-cpufreq-selector.patch" - patch -Np0 < "${srcdir}/indicator.py.patch" - patch -Np0 < "${srcdir}/no-cpufreq.patch" - -} - package() { - cd "${srcdir}/indicator-cpufreq" - python2 setup.py install --root="${pkgdir}/" --optimize=1 - - install -dm750 -o polkitd "${pkgdir}/usr/share/polkit-1/rules.d/" - install -m644 "${srcdir}/indicator-cpufreq.rules" \ - "${pkgdir}/usr/share/polkit-1/rules.d/" + install -Dm755 {${srcdir},${pkgdir}/usr/bin}/throttlectl + install -Dm644 {${srcdir},${pkgdir}/etc/throttle.d}/powersave + install -Dm644 {${srcdir},${pkgdir}/etc/throttle.d}/performance - install -Dm755 "${srcdir}/throttle" "${pkgdir}/usr/bin/throttle" - install -Dm755 "${srcdir}/powersave" "${pkgdir}/etc/throttle.d/powersave" - install -Dm755 "${srcdir}/performance" "${pkgdir}/etc/throttle.d/performance" + install -Dm644 {${srcdir},${pkgdir}/etc/systemd/system}/throttle-cut.service + #install -Dm644 {${srcdir},${pkgdir}/etc/udev/rules.d}/throttle-runtime-pm.rules - install -Dm644 "${srcdir}/throttle-cut.service" "${pkgdir}/etc/systemd/system/throttle-cut.service" } diff --git a/com.ubuntu.indicator.policy.in.patch b/com.ubuntu.indicator.policy.in.patch deleted file mode 100644 index f6b356b5d398..000000000000 --- a/com.ubuntu.indicator.policy.in.patch +++ /dev/null @@ -1,60 +0,0 @@ ---- indicator_cpufreq/com.ubuntu.indicatorcpufreq.policy.in 2014-12-27 02:48:58.330816000 +0900 -+++ 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> - diff --git a/indicator-cpufreq-selector.patch b/indicator-cpufreq-selector.patch deleted file mode 100644 index 4b7a937eca57..000000000000 --- a/indicator-cpufreq-selector.patch +++ /dev/null @@ -1,81 +0,0 @@ -=== modified file 'bin/indicator-cpufreq-selector' ---- bin/indicator-cpufreq-selector 2013-01-25 14:15:03 +0000 -+++ bin/indicator-cpufreq-selector 2017-04-04 16:48:53 +0000 -@@ -21,7 +21,7 @@ - import dbus.service - import dbus.mainloop.glib - --from indicator_cpufreq import cpufreq -+import subprocess - - class PermissionDeniedByPolicy(dbus.DBusException): - _dbus_error_name = 'com.ubuntu.DeviceDriver.PermissionDeniedByPolicy' -@@ -42,24 +42,49 @@ - self._package_operation_in_progress = False - - @dbus.service.method(dbus_interface='com.ubuntu.IndicatorCpufreqSelector', -- in_signature='auu', -- out_signature='', -- sender_keyword='sender', -- connection_keyword='conn') -- def SetFrequency(self, cpus, frequency, sender=None, conn=None): -- self._check_polkit_privilege(sender, conn, 'com.ubuntu.indicatorcpufreqselector.setfrequencyscaling') -- for cpu in cpus: -- error = cpufreq.set_frequency(cpu, frequency) -- -- @dbus.service.method(dbus_interface='com.ubuntu.IndicatorCpufreqSelector', -- in_signature='aus', -- out_signature='', -- sender_keyword='sender', -- connection_keyword='conn') -- def SetGovernor(self, cpus, governor, sender=None, conn=None): -- self._check_polkit_privilege(sender, conn, 'com.ubuntu.indicatorcpufreqselector.setfrequencyscaling') -- for cpu in cpus: -- error = cpufreq.modify_policy_governor(cpu, governor) -+ 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='as', -+ out_signature='', -+ sender_keyword='sender', -+ connection_keyword='conn') -+ def SetGovernor(self, governor, sender=None, conn=None): -+ self._check_polkit_privilege(sender, conn, 'com.ubuntu.indicatorcpufreqselector.setfrequencyscaling') -+ error = subprocess.Popen(["/bin/sh", "throttle", 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. - diff --git a/indicator-cpufreq.rules b/indicator-cpufreq.rules deleted file mode 100644 index c0c6bfaf2b0b..000000000000 --- a/indicator-cpufreq.rules +++ /dev/null @@ -1,46 +0,0 @@ -/* 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.py.patch b/indicator.py.patch deleted file mode 100644 index bdc27a50b250..000000000000 --- a/indicator.py.patch +++ /dev/null @@ -1,208 +0,0 @@ -=== modified file 'indicator_cpufreq/indicator.py' ---- indicator_cpufreq/indicator.py 2013-02-20 03:47:48 +0000 -+++ indicator_cpufreq/indicator.py 2017-04-04 16:49:04 +0000 -@@ -23,12 +23,15 @@ - import locale - import dbus - --from indicator_cpufreq import cpufreq -- - import gettext - from gettext import gettext as _ - #gettext.textdomain('indicator-cpufreq') - -+import glob -+ -+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) -@@ -37,9 +40,9 @@ - return label - - governor_names = { -+ 'schedutil': _("Scheduler"), - 'conservative': _("Conservative"), - 'ondemand': _("Ondemand"), -- #'userspace': _("Userspace"), - 'powersave': _("Powersave"), - 'performance': _("Performance"), - } -@@ -50,6 +53,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 -@@ -66,33 +78,81 @@ - self.select_items = {} - group = [] - -- maxcpu = 0 -- while cpufreq.cpu_exists(maxcpu) == 0: -- maxcpu += 1 -- self.cpus = range(maxcpu) -- -- # frequency menu items -- #freqs = cpufreq.get_available_frequencies(self.cpus[0]) -- freqs = reversed(sorted(set(cpufreq.get_available_frequencies(self.cpus[0])))) -- for freq in freqs: -- menu_item = Gtk.RadioMenuItem.new_with_label(group, readable_frequency(freq)) -+ # 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() -- menu.append(menu_item) -- menu_item.connect("activate", self.select_activated, 'frequency', freq) -- self.select_items[freq] = menu_item -+ 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()) - - # governor menu items -- governors = cpufreq.get_available_governors(self.cpus[0]) -- for governor in governors: -- if governor == 'userspace': -- continue -+ govFile = open("/sys/devices/system/cpu/cpufreq/policy0/scaling_available_governors") -+ governors = govFile.readline().strip("\n") -+ govList = governors.split(" ") -+ govmenu = Gtk.Menu() -+ govm = Gtk.MenuItem("CPU Governor") -+ govm.set_submenu(govmenu) -+ for governor in govList: -+ if governor == 'performance': -+ toggle = 'full' -+ else: -+ toggle = 'cut' - menu_item = Gtk.RadioMenuItem.new_with_label(group, readable_governor(governor)) - group = menu_item.get_group() -- menu.append(menu_item) -- menu_item.connect('activate', self.select_activated, 'governor', governor) -+ govmenu.append(menu_item) -+ menu_item.connect('activate', self.select_activated, 'governor', toggle) - self.select_items[governor] = menu_item -+ menu.append(govm) -+ govFile.close -+ -+ # 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) -@@ -107,13 +167,29 @@ - for i in self.select_items.values(): - i.handler_block_by_func(self.select_activated) - -- fmin, fmax, governor = cpufreq.get_policy(self.cpus[0]) -+ govFile = open("/sys/devices/system/cpu/cpufreq/policy0/scaling_governor", 'r') -+ governor = govFile.readline().strip("\n") -+ fmnFile = open("/sys/devices/system/cpu/cpufreq/policy0/cpuinfo_min_freq", 'r') -+ fmin = int(fmnFile.readline().strip("\n")) -+ fmxFile = open("/sys/devices/system/cpu/cpufreq/policy0/cpuinfo_max_freq", 'r') -+ fmax = int(fmxFile.readline().strip("\n")) - # use the highest freq among cores for display -- freq = max([cpufreq.get_freq_kernel(cpu) for cpu in self.cpus]) -+ freq_list = glob.glob('/sys/devices/system/cpu/cpufreq/policy*/scaling_cur_freq') -+ freqs = [] -+ for cur_freq in freq_list: -+ f = open(cur_freq, 'r') -+ freqs.append(int(f.readline().strip("\n"))) -+ f.close -+ -+ freq = max(freqs) - - ratio = min([25, 50, 75, 100], key=lambda x: abs((fmax - fmin) * x / 100.0 - (freq - fmin))) - if freq < fmax and ratio == 100: - ratio = 75 -+ -+ govFile.close -+ fmnFile.close -+ fmxFile.close - - #self.set_icon(get_data_file('media', 'indicator-cpufreq-%d.png' % ratio)) - self.ind.set_icon('indicator-cpufreq-%d' % ratio) -@@ -133,12 +209,21 @@ - if menuitem.get_active(): - 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': -- proxy.SetFrequency(cpus, dbus.UInt32(value), -+ #cpus = [dbus.UInt32(cpu) for cpu in self.cpus] -+ if select == 'throttle': -+ proxy.SetThrottle(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, -+ proxy.SetGovernor("gov-" + value, - dbus_interface='com.ubuntu.IndicatorCpufreqSelector') - - def can_set(self): - diff --git a/no-cpufreq.patch b/no-cpufreq.patch deleted file mode 100644 index 794491624578..000000000000 --- a/no-cpufreq.patch +++ /dev/null @@ -1,211 +0,0 @@ ---- indicator_cpufreq/cpufreq.py 2017-04-05 01:11:16.147391000 +0900 -+++ /dev/null 2017-04-05 01:32:18.574219424 +0900 -@@ -1,208 +0,0 @@ --# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- --### BEGIN LICENSE --# Copyright (C) 2010 Artem Popov <artfwo@gmail.com> --# This program is free software: you can redistribute it and/or modify it --# under the terms of the GNU General Public License version 3, as published --# by the Free Software Foundation. --# --# This program is distributed in the hope that it will be useful, but --# WITHOUT ANY WARRANTY; without even the implied warranties of --# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR --# PURPOSE. See the GNU General Public License for more details. --# --# You should have received a copy of the GNU General Public License along --# with this program. If not, see <http://www.gnu.org/licenses/>. --### END LICENSE -- --from ctypes import * --from ctypes.util import find_library -- --_libcpufreq = cdll.LoadLibrary(find_library("cpufreq")) -- --class _cpufreq_policy(Structure): -- _fields_ = [ -- ("min", c_ulong), -- ("max", c_ulong), -- ("governor", c_char_p)] -- --class _cpufreq_available_governors(Structure): -- pass --_cpufreq_available_governors._fields_ = [ -- ("governor", c_char_p), -- ("next", POINTER(_cpufreq_available_governors)), -- ("first", POINTER(_cpufreq_available_governors))] -- --class _cpufreq_available_frequencies(Structure): -- pass --_cpufreq_available_frequencies._fields_ = [ -- ("frequency", c_ulong), -- ("next", POINTER(_cpufreq_available_frequencies)), -- ("first", POINTER(_cpufreq_available_frequencies))] -- --class _cpufreq_affected_cpus(Structure): -- pass --_cpufreq_affected_cpus._fields_ = [ -- ("cpu", c_uint), -- ("next", POINTER(_cpufreq_affected_cpus)), -- ("first", POINTER(_cpufreq_affected_cpus))] -- --class _cpufreq_stats(Structure): -- pass --_cpufreq_stats._fields_ = [ -- ("frequency", c_ulong), -- ("time_in_state", c_ulonglong), -- ("next", POINTER(_cpufreq_stats)), -- ("first", POINTER(_cpufreq_stats))] -- --############################################################################### -- --_libcpufreq.cpufreq_cpu_exists.argtypes = [c_uint] --_libcpufreq.cpufreq_cpu_exists.restype = c_int -- --_libcpufreq.cpufreq_get_freq_kernel.argtypes = [c_uint] --_libcpufreq.cpufreq_get_freq_kernel.restype = c_ulong -- --_libcpufreq.cpufreq_get_freq_hardware.argtypes = [c_uint] --_libcpufreq.cpufreq_get_freq_hardware.restype = c_ulong -- --_libcpufreq.cpufreq_get_transition_latency.argtypes = [c_uint] --_libcpufreq.cpufreq_get_transition_latency.restype = c_ulong -- --_libcpufreq.cpufreq_get_hardware_limits.argtypes = [c_uint, POINTER(c_ulong), POINTER(c_ulong)] --_libcpufreq.cpufreq_get_hardware_limits.restype = c_int -- --_libcpufreq.cpufreq_get_driver.argtypes = [c_uint] --_libcpufreq.cpufreq_get_driver.restype = c_char_p --#extern void cpufreq_put_driver(char * ptr); -- --_libcpufreq.cpufreq_get_policy.argtypes = [c_uint] --_libcpufreq.cpufreq_get_policy.restype = POINTER(_cpufreq_policy) --#extern void cpufreq_put_policy(struct cpufreq_policy *policy); -- --_libcpufreq.cpufreq_get_available_governors.argtypes = [c_uint] --_libcpufreq.cpufreq_get_available_governors.restype = POINTER(_cpufreq_available_governors) --#extern void cpufreq_put_available_governors(struct _cpufreq_available_governors *first); -- --_libcpufreq.cpufreq_get_available_frequencies.argtypes = [c_uint] --_libcpufreq.cpufreq_get_available_frequencies.restype = POINTER(_cpufreq_available_frequencies) --#extern void cpufreq_put_available_frequencies(struct _cpufreq_available_frequencies *first); -- --_libcpufreq.cpufreq_get_affected_cpus.argtypes = [c_uint] --_libcpufreq.cpufreq_get_affected_cpus.restype = POINTER(_cpufreq_affected_cpus) --#extern void cpufreq_put_affected_cpus(struct _cpufreq_affected_cpus *first); -- --_libcpufreq.cpufreq_get_related_cpus.argtypes = [c_uint] --_libcpufreq.cpufreq_get_related_cpus.restype = POINTER(_cpufreq_affected_cpus) --#extern void cpufreq_put_related_cpus(struct _cpufreq_affected_cpus *first); -- --_libcpufreq.cpufreq_get_stats.argtypes = [c_uint, POINTER(c_ulonglong)] --_libcpufreq.cpufreq_get_stats.restype = POINTER(_cpufreq_stats) --#extern void cpufreq_put_stats(struct _cpufreq_stats *stats); -- --_libcpufreq.cpufreq_get_transitions.argtypes = [c_uint] --_libcpufreq.cpufreq_get_transitions.restype = c_ulong -- --_libcpufreq.cpufreq_set_policy.argtypes = [c_uint, POINTER(_cpufreq_policy)] --_libcpufreq.cpufreq_set_policy.restype = c_int -- --_libcpufreq.cpufreq_modify_policy_min.argtypes = [c_uint, c_ulong] --_libcpufreq.cpufreq_modify_policy_min.restype = c_int -- --_libcpufreq.cpufreq_modify_policy_max.argtypes = [c_uint, c_ulong] --_libcpufreq.cpufreq_modify_policy_max.restype = c_int -- --_libcpufreq.cpufreq_modify_policy_governor.argtypes = [c_uint, c_char_p] --_libcpufreq.cpufreq_modify_policy_governor.restype = c_int -- --_libcpufreq.cpufreq_set_frequency.argtypes = [c_uint, c_ulong] --_libcpufreq.cpufreq_set_frequency.restype = c_int -- --def cpu_exists(cpu): -- return _libcpufreq.cpufreq_cpu_exists(cpu) -- --def get_freq_kernel(cpu): -- return _libcpufreq.cpufreq_get_freq_kernel(cpu) -- --def get_freq_hardware(cpu): -- return _libcpufreq.cpufreq_get_freq_hardware(cpu) -- --def get_transition_latency(cpu): -- return _libcpufreq.cpufreq_get_transition_latency(cpu) -- --def get_hardware_limits(cpu): -- min = c_ulong() -- max = c_ulong() -- _libcpufreq.cpufreq_get_hardware_limits(cpu, byref(min), byref(max)) -- return (min.value, max.value) -- --def get_driver(cpu): -- return _libcpufreq.cpufreq_get_driver(cpu).decode() -- --def get_policy(cpu): -- p = _libcpufreq.cpufreq_get_policy(cpu) -- policy = (p.contents.min, p.contents.max, p.contents.governor.decode()) -- _libcpufreq.cpufreq_put_policy(p) -- return policy -- --def _marshall_structs(first, field, decode=False): -- values = [] -- p = first -- while p: -- if decode: -- values.append(getattr(p.contents, field).decode()) -- else: -- values.append(getattr(p.contents, field)) -- p = p.contents.next -- return values -- --def get_available_governors(cpu): -- structs = _libcpufreq.cpufreq_get_available_governors(cpu) -- values = _marshall_structs(structs, 'governor', decode=True) -- _libcpufreq.cpufreq_put_available_governors(structs) -- return values -- --def get_available_frequencies(cpu): -- structs = _libcpufreq.cpufreq_get_available_frequencies(cpu) -- values = _marshall_structs(structs, 'frequency') -- _libcpufreq.cpufreq_put_available_frequencies(structs) -- return values -- --def get_affected_cpus(cpu): -- structs = _libcpufreq.cpufreq_get_affected_cpus(cpu) -- values = _marshall_structs(structs, 'cpu') -- _libcpufreq.cpufreq_put_affected_cpus(structs) -- return values -- --def get_related_cpus(cpu): -- structs = _libcpufreq.cpufreq_get_related_cpus(cpu) -- values = _marshall_structs(structs, 'cpu') -- _libcpufreq.cpufreq_put_related_cpus(structs) -- return values -- --def get_stats(cpu): -- total_time = c_ulonglong() -- p = _libcpufreq.cpufreq_get_stats(cpu, byref(total_time)) -- stats = [] -- while p: -- stats.append((p.contents.frequency, p.contents.time_in_state)) -- p = p.contents.next -- _libcpufreq.cpufreq_put_stats(p) -- return total_time.value, stats -- --def get_transitions(cpu): -- return _libcpufreq.cpufreq_get_transitions(cpu) -- --def set_policy(cpu, min, max, governor): -- return _libcpufreq.cpufreq_set_policy(cpu, _cpufreq_policy(min, max, governor)) -- --def modify_policy_min(cpu, min_freq): -- return _libcpufreq.cpufreq_modify_policy_min(cpu, min_freq) -- --def modify_policy_min(cpu, max_freq): -- return _libcpufreq.cpufreq_modify_policy_max(cpu, max_freq) -- --def modify_policy_governor(cpu, governor): -- return _libcpufreq.cpufreq_modify_policy_governor(cpu, governor.encode()) -- --def set_frequency(cpu, target_frequency): -- return _libcpufreq.cpufreq_set_frequency(cpu, target_frequency) diff --git a/throttle b/throttlectl index 9f1656a6b954..9f1656a6b954 100755 --- a/throttle +++ b/throttlectl |