cpu_speed.sh 329 B

123456789101112131415
  1. #!/usr/bin/env bash
  2. cur_freq="/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq"
  3. class=cpu_speed
  4. speed_mhz=$(cat "$cur_freq")
  5. # speed_ghz=`echo $(($speed_mhz / 1000))`
  6. speed_ghz=$(bc -l <<<"$speed_mhz / 1000000")
  7. info=$(echo "$speed_ghz" | xargs printf "%.*f\n" 2)
  8. echo "{\"text\":\"$info GHz\", \"class\":\"$class\"}"