scratch_gpio
scratch_gpio copied to clipboard
cleaner startup script scratch_gpio2.sh
The following version of the startup script is cleaner in a few ways:
- it uses /bin/sh (dash) instead of bash, which uses less memory and is faster to start
- it uses pkill instead of a long pipeline to kill old copies of the python script
- it uses trap to kill the current copy of the python script when the program exits
- it doesn't put scratch into the background, so that when scratch ends the trap command will be executed.
#!/bin/sh
#Version 0.2 - add in & to allow simulatenous running of handler and Scratch
#Version 0.3 - change sp launches rsc.sb from "/home/pi/Documents/Scratch Projects"
#Version 0.4 - 20Mar13 meltwater - change to use provided name for home
sudo pkill -9 -f scratch_gpio_handler2.py
trap 'sudo pkill -9 -f scratch_gpio_handler2.py' 0 1 2 3 7 9 11 13 15
sudo python /home/pi/simplesi_scratch_handler/scratch_gpio_handler2.py &
scratch --document "/home/pi/Documents/Scratch Projects/rsc.sb"