[UP] add many more ion3 cfg -_-, powerfull, and add thinkpad xorg.conf/.Xmodmap,...
[arrow.git] / archlinux_conf / etc / ion3 / statusd_cpufreq.lua
blob0cb17322008cb3a4c52b053139f7938628fb3749
1 -- statusd_cpufreq.lua
2 --
3 -- Public domain
4 --
5 -- Use the key "cpufreq_[KMG]" to get the current CPU frequency in
6 -- K/M/GHz, according to /sys/devices/system/cpu/cpuX/cpufreq/. (This
7 -- has the advantage of being a much "rounder" number than the one in
8 -- /proc/cpuinfo, as provided by statusd_cpuspeed.lua.)
9 --
10 -- The "cpu" option to the statusd settings for cpufreq modifies which
11 -- cpu we look at.
13 local defaults={ update_interval=2*1000, cpu=0 }
14 local settings=table.join(statusd.get_config("cpufreq"), defaults)
16 function get_cpufreq()
17 local f=io.open('/sys/devices/system/cpu/cpu'.. settings.cpu ..'/cpufreq/scaling_cur_freq')
18 local cpufreq_K = f:read('*a')
19 f:close()
21 local cpufreq_M = cpufreq_K / 1000
22 local cpufreq_G = cpufreq_M / 1000
24 return tostring(cpufreq_K), tostring(cpufreq_M), tostring(cpufreq_G)
25 end
27 function update_cpufreq()
28 local cpufreq_K, cpufreq_M, cpufreq_G = get_cpufreq()
29 statusd.inform("cpufreq_K", cpufreq_K)
30 statusd.inform("cpufreq_M", cpufreq_M)
31 statusd.inform("cpufreq_G", cpufreq_G)
32 cpufreq_timer:set(settings.update_interval, update_cpufreq)
33 end
35 cpufreq_timer = statusd.create_timer()
36 update_cpufreq()