Symlink notifyd.py to osd_server.py for backward compatibility
[grml-scripts.git] / usr_bin / cpu-screen.sh
1 #!/bin/sh
2 # Filename:      cpu-screen
3 # Purpose:       script for use inside GNU screen
4 # Authors:       grml-team (grml.org), (c) Michael Prokop <mika@grml.org>
5 # Bug-Reports:   see http://grml.org/bugs/
6 # License:       This file is licensed under the GPL v2.
7 ################################################################################
8
9 if [ -r /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq ] ; then
10   TMP=`cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq` && \
11   CUR="`echo "scale=0; $TMP/1000" | bc -l` / "
12 else
13   [ -z "$CUR" ] && CUR=''
14 fi
15
16 if ! [ -d /proc ] ; then
17   echo "no /proc" && exit
18 else
19   if [ -r /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq ] ; then
20     TMP=`cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq` && \
21     MHZ=`echo "scale=0; $TMP/1000" | bc -l`
22   else
23     MHZ=$(grep 'cpu MHz' /proc/cpuinfo | sed 's/.*: // ; s/\..*//')
24   fi
25   MULT=$(echo "$MHZ" | wc -l)
26   if [ $MULT -gt 1 ] ; then
27     RESULT=$(echo "$MHZ" | head -1)
28     echo "$CUR${RESULT}*${MULT}"
29   else
30     echo "$CUR$MHZ"
31   fi
32 fi
33
34 ## END OF FILE #################################################################