You are not logged in.

#1 2008-10-01 01:48:04

dmlawrence
Member
Registered: 2008-10-01
Posts: 21

CPU frequency widget in Awesome

I am using the Awesome window manager (version 3) and CPU frequency scaling. I created a widget that displays the current CPU frequency. In order to update the widget, the following code is called periodically:

io.input("/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq")
cpufreq = tonumber(io.read("*all")) / 1000
cpuwidget.text = " " .. cpufreq .. " MHz "

The problem is that by default, root permissions are required to read from the /sys filesystem.
If I run the command

chmod a+r /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq

the widget works, but only until the next restart.

Is there a more permanent solution to this problem?

Offline

#2 2008-10-01 22:39:45

byte
Member
From: Düsseldorf (DE)
Registered: 2006-05-01
Posts: 2,046

Re: CPU frequency widget in Awesome

Your could use /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq or run 'cpufreq-info -f' instead.

Last edited by byte (2008-10-01 22:41:24)


1000

Offline

#3 2008-10-02 17:32:07

kett
Member
Registered: 2008-04-21
Posts: 104

Re: CPU frequency widget in Awesome

It would work better if you just ran it like this:

cpufreq=io.popen("cpufreq-info -f"):lines)(){1}
cpuwidget.text = " " .. cpufreq/1000 .. " MHz "

Last edited by kett (2008-10-02 17:32:51)

Offline

#4 2008-10-02 18:03:42

dmlawrence
Member
Registered: 2008-10-01
Posts: 21

Re: CPU frequency widget in Awesome

Thanks, works great (but without that extra parenthesis).

Last edited by dmlawrence (2008-10-02 18:10:25)

Offline

Board footer

Powered by FluxBB