我的桌面一直开着。它充当服务器并执行其他半必需的家务。在白天,它使用 OnDemand CPU 设置。这基本上只是根据需要调整 CPU 频率,这对我来说非常有效。
到了晚上,它四处飞来飞去。当然,大多数时候它以低功率空转,但偶尔,它会加速做某事。我宁愿它留在 PowerSave 上,而任务只是被迫花更长的时间来完成。
此外,我有一张 Nvidia 卡 (GTX 580),它消耗的电量与一个非洲小村庄一年想要使用的电量大致相同(盯着 Minecraft 看)。由于未知的原因(毫无疑问,桌面上发生了一些事情),这种情况逐渐增加,风扇听起来像是在充电以将激光发射到太空中。在夜间,我想尽可能地将卡降频。
我考虑过一个简单的 root 运行 cron 脚本来推动这些,但我的工作时间是可变的。上周我每周工作近 70 小时,所以我每天起得很早,但仍然很晚。如果系统在超低频率模式下按喇叭,我会很生气。有什么我可以说的,“在以下情况下降频:
如果这些条件之一不成立,则降频需要立即恢复。我不想等待 cron 脚本出现将计算机从沉睡中唤醒。同样,一旦所有这些都成为现实,它就应该重新进入睡眠状态。
我有哪些选择?
Ste*_*zzo 19
这是一个可以执行您想要的操作的程序:
#!/usr/bin/env python
# coding: utf8
import time
import sys
import commands
USER = commands.getoutput("cat /var/log/auth.log | grep " +
sys.argv[0]).split("sudo:")[1].split()[0].strip()
def is_idle():
return int(commands.getoutput("xprintidle")) >= 10 * 60 * 1000
def is_night():
return time.localtime().tm_hour in (22, 23, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9)
def is_stumm():
return "RUNNING" not in commands.getoutput(("sudo -u %s pacmd " +
"list-sinks | grep RUNNING") % USER)
def main():
powersave = False
while 1:
if is_idle() and is_night() and is_stumm():
if not powersave:
print "going into powersave mode"
commands.getoutput("echo powersave > " +
"/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor")
powersave = True
else:
if powersave:
print "going into ondemand mode"
commands.getoutput("echo ondemand > " +
"/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor")
powersave = False
time.sleep(0.5)
if __name__ == '__main__':
assert commands.getstatusoutput("xprintidle")[0] == 0, (
"you need to `sudo apt-get install xprintidle`")
assert commands.getoutput("whoami") == "root", (
"you need to be root to run this program")
main()
Run Code Online (Sandbox Code Playgroud)
请注意您的偏好:
... >= 10 * 60 * 1000
... tm_hour in (22, 23, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9)
和"RUNNING" not in ...
我正在使用pulseaudio来确定是否正在播放电影。这也会影响音乐。
您可以使用以下方法强制 CPU 缩放:
cpufreq-selector -f [frequency]
Run Code Online (Sandbox Code Playgroud)
还有更多选项(即特定的 cpu,或选择治理而不是速度)这确实假设您的主板/cpu 允许 Ubuntu 手动控制缩放(显然情况并非总是如此。)
其余的可以使用脚本来应用,但是您对它的要求很高^_^。如果您需要即时响应,我认为您必须定期轮询您的系统。根据我的一些有限的知识,没有任何东西可以宣布您指定的条件。
然而,开始调查的地方是屏幕保护程序。这会在一段时间不活动(晚上 10 点至上午 9 点也是如此)后打开,并且可以被电影播放器禁止。如果您制作了一个在初始化时按比例缩小 CPU 并在唤醒时恢复它的屏幕保护程序,那么您将拥有您想要的东西。
不幸的是,这就是我所能带给你的,对屏幕保护程序及其工作原理一无所知。
祝你好运。
归档时间: |
|
查看次数: |
2339 次 |
最近记录: |