Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # Very Mickey Mouse as when a bash script is run as a background task in a putty session it doesn't receive SIGWINCH
- # so you'd need to send the signal to the script's pid using kill -28. But i hardly ever resize a putty session
- # so no biggy. I think xterm does receive it though.
- # Print temp & power status in the top right-hand corner of the tty/console/terminal window
- # using vcgencmd for temp & Gordon henderson's gpio utility for power.
- export XPos
- trap 'get_xposition' SIGWINCH
- get_xposition() {
- tput clear
- columns=`tput cols`
- export XPos=$(($columns-14))
- }
- get_xposition
- gpio -g mode 35 input
- OkColour=`tput setaf 2`
- UhOhColour=`tput setaf 1`
- Reset=`tput sgr0`
- while :
- do
- temperature=`vcgencmd measure_temp | awk -F'=' '{print $2}'`
- lowpower=`gpio -g read 35`
- tput sc
- tput cup 0 $XPos
- if [ `echo $temperature | awk -F'.' '{print $1}'` -lt 70 ]; then
- echo -n $OkColour$temperature $Reset
- else
- echo -n $UhOhColour$temperature $Reset
- fi
- if [ $lowpower -eq 0 ]; then
- echo -n $UhOhColour"LOW"$Reset
- else
- echo -n $OkColour" OK"$Reset
- fi
- tput rc
- sleep 1
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement