xsay: add support for sselp and xclip; output error message
[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 # Latest change: Mit Apr 20 00:06:21 CEST 2005 [mika]
8 ################################################################################
9
10 if [ -r /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq ] ; then
11   TMP=`cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq` && \
12   CUR="`echo "scale=0; $TMP/1000" | bc -l` / "
13 else
14   [ -z "$CUR" ] && CUR=''
15 fi
16
17 if ! [ -d /proc ] ; then
18   echo "no /proc" && exit
19 else
20   if [ -r /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq ] ; then
21     TMP=`cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq` && \
22     MHZ=`echo "scale=0; $TMP/1000" | bc -l`
23   else
24     MHZ=$(grep 'cpu MHz' /proc/cpuinfo | sed 's/.*: // ; s/\..*//')
25   fi
26   MULT=$(echo "$MHZ" | wc -l)
27   if [ $MULT -gt 1 ] ; then
28     RESULT=$(echo "$MHZ" | head -1)
29     echo "$CUR${RESULT}*${MULT}"
30   else
31     echo "$CUR$MHZ"
32   fi
33 fi
34
35 ## END OF FILE #################################################################