From 304c05da485a5ccb5269e47ca160ff6c76b4d9b5 Mon Sep 17 00:00:00 2001 From: vierlijner Date: Thu, 10 Nov 2022 21:47:29 +0100 Subject: [PATCH] Make wClock.sh Made the wClock.sh from @plotn and enhanced it. But it give a messages that we needed a __main__ --- README.md | 1 + wClock.sh | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 wClock.sh 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