Indicator displaying current CPU frequency and usage
Solution 1
You may use indicator-sysmonitor for such custom indicator
-
Install
indicator-sysmonitor
sudo add-apt-repository ppa:fossfreedom/indicator-sysmonitor sudo apt-get update sudo apt-get install indicator-sysmonitor
Run it
- Click on its indicator → Preferences → Advanced tab
-
Click New:
Sensor:
freq
Command:awk '/cpu MHz/{printf(" %d",$4)}' /proc/cpuinfo
- Change the new sensor to label:
cpu: {cpu} mem: {mem} freq:{freq}
. -
Save
References:
Solution 2
You can use indicator-multiload
to set a custom indicator:
-
Install
indicator-sysmonitor
:sudo apt-get install indicator-multiload
Run it
Click on its Indicator → Preferences → Indicator Items
-
Click Add and enter:
freq $(frequency(cpufreq.cur1))
Move it to the very top.
Add another
freq
without a value.Close by clicking Close
Solution 3
I followed this tutorial on creating indicator applets:
http://conjurecode.com/create-indicator-applet-for-ubuntu-unity-with-python/
And came up with following script. It displays an indicator with frequency of each core based on cpuinfo output. Not very robust but seems to do the job.
#!/usr/bin/env python
import sys
import gtk
import appindicator
import random
import time
import os
import re
PING_FREQUENCY_MS = 1000
INDICATOR_NAME = "cpu-indicator"
ICON_PATH = "/usr/share/unity/icons/panel-shadow.png"
APP_CATHEGORY = appindicator.CATEGORY_APPLICATION_STATUS
def cpu_freqs_string():
return os.popen("cat /proc/cpuinfo | grep MHz").read()
def extract_freqs(s):
return re.sub("[^(0-9|\t|.)]", "", s).strip().split("\t")
def cpu_freqs():
freqs_only = extract_freqs(cpu_freqs_string())
freqs_in_ghz = [float(x) / 1000 for x in freqs_only if x != ""]
return " | ".join(["%.1f" % freq for freq in freqs_in_ghz])
class CpuIndicator:
def __init__(self):
self.ind = appindicator.Indicator(INDICATOR_NAME, ICON_PATH, APP_CATHEGORY)
self.ind.set_status(appindicator.STATUS_ACTIVE)
self.ind.set_menu(gtk.Menu())
def main(self):
gtk.timeout_add(PING_FREQUENCY_MS, self.update_value)
gtk.main()
def update_value(self):
self.ind.set_label(cpu_freqs())
return True
def quit(self, widget):
sys.exit(0)
indicator = CpuIndicator()
indicator.main()
By the way, an idea of extending indicator-multiload to display usage per core can be found here:
https://bugs.launchpad.net/ubuntu/+source/indicator-multiload/+bug/1173972
Not implemented 2 year after request but maybe one day...
Related videos on Youtube
Legat
Updated on September 18, 2022Comments
-
Legat over 1 year
Unfortunately, it seems that cpufreq indicator is only showing an icon indicating proportional frequency instead of precise number I would like to see.
Is there any indicator showing actual CPU frequency real time? Maybe for each core?
Ideally I would like to see both the frequency and usage per core but answers to this question:
Is there an application indicator for CPU usage by core?
suggest that usage per core is out for reach right now.