Если кому надо, улучшайте :) У меня работает - мне достаточно этого. Код некрасивый - просьба не обсуждать. Способ переключения тоже не очень - нужен cpufrequtils
Скриншот: http://home.lx-host.net/tmp/Screenshot.png
Кстати, хост хороший в плане вкусностей и цены...
#!/usr/bin/python
import pygtk
pygtk.require('2.0')
import gtk
import gnomeapplet
import os
def get_active_text(combobox):
model = combobox.get_model()
active = combobox.get_active()
if active < 0:
return None
return model[active][0]
def item_changed(box):
policy = get_active_text(box)
if policy == 'save':
cmd = 'cp /etc/conf.d/cpufrequtils.ondemand /etc/conf.d/cpufrequtils'
os.popen(cmd, 'w')
os.popen('sudo /etc/init.d/cpufrequtils restart')
elif policy == 'fast':
cmd = 'cp /etc/conf.d/cpufrequtils.performance /etc/conf.d/cpufrequtils'
os.popen(cmd, 'w')
os.popen('sudo /etc/init.d/cpufrequtils restart')
def sample_factory(applet, iid):
b = gtk.HBox(True, 0)
label = gtk.Label('battery:')
b.pack_start(label)
applet.set_border_width = 20
box = gtk.combo_box_new_text()
box.append_text('save')
box.append_text('fast')
#find out the policy set
policy = os.popen('cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor').read().strip()
if policy == 'performance':
box.set_active(1)
elif policy == 'ondemand':
box.set_active(0)
box.connect('changed', item_changed)
b.pack_start(box)
applet.add(b)
applet.show_all()
return gtk.TRUE
gnomeapplet.bonobo_factory("OAFIID:GNOME_PysampleApplet_Factory",
gnomeapplet.Applet.__gtype__,
"hello", "0", sample_factory)
if __name__ == '__main__':
win = gtk.Window()
b = gtk.HBox(True, 0)
label = gtk.Label('battery:')
b.pack_start(label)
win.set_border_width = 20
win.set_position(gtk.WIN_POS_CENTER_ALWAYS)
box = gtk.combo_box_new_text()
box.append_text('save')
box.append_text('fast')
#find out the policy set
policy = os.popen('cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor').read().strip()
if policy == 'performance':
box.set_active(1)
elif policy == 'ondemand':
box.set_active(0)
box.connect('changed', item_changed)
b.pack_start(box)
win.add(b)
win.show_all()
gtk.main()