Advertisement
Guest User

Untitled

a guest
Jul 4th, 2015
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. #!/bin/bash
  2. # Very Mickey Mouse as when a bash script is run as a background task in a putty session it doesn't receive SIGWINCH
  3. # so you'd need to send the signal to the script's pid using kill -28. But i hardly ever resize a putty session
  4. # so no biggy. I think xterm does receive it though.
  5. # Print temp & power status in the top right-hand corner of the tty/console/terminal window
  6. # using vcgencmd for temp & Gordon henderson's gpio utility for power.
  7.  
  8. export XPos
  9. trap 'get_xposition' SIGWINCH
  10. get_xposition() {
  11. tput clear
  12. columns=`tput cols`
  13. export XPos=$(($columns-14))
  14. }
  15. get_xposition
  16. gpio -g mode 35 input
  17. OkColour=`tput setaf 2`
  18. UhOhColour=`tput setaf 1`
  19. Reset=`tput sgr0`
  20.  
  21. while :
  22. do
  23. temperature=`vcgencmd measure_temp | awk -F'=' '{print $2}'`
  24. lowpower=`gpio -g read 35`
  25. tput sc
  26. tput cup 0 $XPos
  27. if [ `echo $temperature | awk -F'.' '{print $1}'` -lt 70 ]; then
  28. echo -n $OkColour$temperature $Reset
  29. else
  30. echo -n $UhOhColour$temperature $Reset
  31. fi
  32. if [ $lowpower -eq 0 ]; then
  33. echo -n $UhOhColour"LOW"$Reset
  34. else
  35. echo -n $OkColour" OK"$Reset
  36. fi
  37. tput rc
  38. sleep 1
  39. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement