diff --git a/README.md b/README.md index 67678e3..a77c1cb 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,7 @@ Terminal=true File 2: wClock.sh With the contents like this (script must be executable sh file): +Or please use the script in the main folder ``` cd /home/plotn/github/weatherClock/ diff --git a/wClock.sh b/wClock.sh new file mode 100644 index 0000000..d660261 --- /dev/null +++ b/wClock.sh @@ -0,0 +1,27 @@ +# Source taken from README.md by @plotn and modified a little bit. +#cd /home/plotn/github/weatherClock/ + +#Find the location of the python file from weatherClock. +cd /home/ +dir_path=$(dirname $(find ./ -type f -name "weatherClock.py" | head -n 1)) +echo $dir_path + +#Detect python version +version=$(python -c 'import sys; print(".".join(map(str, sys.version_info[:2])))') +echo $version +if [[ -z "$version" ]]; then + echo "No Python detected!" + exit 2 +fi + +#Start the python script if it's not running. +while : +do + if test "$(ps aux | grep python3 | grep weather | wc -l)" -eq "0" + then + python$version $dir_path & disown + else + echo "already started" + fi + sleep 5 +done