You are not logged in.
I use the wmii tiling window manager and its status bar abilities. The status bar all works fine except the section for getting the CPUMhz (CPU frequency). It does not get updated properly every 2 seconds as it should.
My code is here:
# Status Bar Info
status() {
echo -n 'CPUTemp:' `expr $(sensors | grep temp1 | awk '{print $2}' | cut -c2-3) + 15` '|' 'CPUMHz:' $(cat /proc/cpuinfo | grep MHz | awk '{printf "%.0f\n", $4}') '|' '/home:' $(df -h | grep sda5 | awk '{print $3}') '|' '/:' $(df -h | grep sda1 | awk '{print $3}') '|' 'RAM:' $(free -m | grep -i /cache | awk '{print $3}') 'MB |' $(uptime | sed 's/.*://; s/,//g') '|' $(date +"%a %b %d %H:%M")
}If anyone can point out my mistake it would be greatly appreciated.
Philosophy is looking for a black cat in a dark room. Metaphysics is looking for a black cat in a dark room that isn't there. Religion is looking for a black cat in a dark room that isn't there and shouting "I found it!". Science is looking for a black cat in a dark room with a flashlight.
Offline
Are you sure that the CPUMHz is causing your problem? When I do
$ sensorson my machine, I get 2 lines containing 'temp1'. If that is happening on your machine, then the `expr $(sensors ...) + 15` of your CPUTemp part will not work as you expect.
Other than that, I don't know what is causing your problem, but you could replace
...'CPUMHz: ' $(cat /proc/cpuinfo | grep MHz | awk '{printf "%.0f\n", $4}')...with
..."CPUMHz: $(awk '/MHz/ { printf "%.0f", $4}' /proc/cpuinfo)"...If that doesn't help, you could try
..."CPUMHz: $(( $(</sys/bus/cpu/devices/cpu0/cpufreq/cpuinfo_cur_freq) / 1000 ))"...although on my system, that file is readable only by root. I don't know why it is set up that way.
You could also break up that long line so that it is easier to read.
status() {
echo -n "CPUTemp: $(( $(sensors | awk '/temp1/ {print $2}' | cut -c2-3) + 15 )) | "
echo -n "CPUMHz: $(awk '/MHz/ { printf "%.0f", $4}' /proc/cpuinfo) | "
echo -n "$(df -h | awk '/sda[15]/ {printf "%s: %s | ", $6, $3}')"
echo -n "RAM: $(free -m | awk '/\/cache/ {print $3}') MB | "
echo -n "$(uptime | sed 's/.*://; s/,//g') | "
echo -n "$(date +"%a %b %d %H:%M")"
}Offline