doppler.sh: add forecast options, clean code

This commit is contained in:
mollusk 2020-06-17 08:48:38 -07:00
parent 167eaf8c95
commit 6a6616cfbc

View File

@ -1,7 +1,12 @@
#!/bin/sh #!/bin/sh
# doppler.sh
IMAGE_URL="https://radar.weather.gov/lite/N0R/FSX_loop.gif" IMAGE_URL="https://radar.weather.gov/lite/N0R/FSX_loop.gif"
VIDEO_PLAYER=/usr/bin/mpv VIDEO_PLAYER=/usr/bin/mpv
LINK_DOWNLOADER=/usr/bin/curl
FORECAST_URL="wttr.in"
TERMINAL_APP=/usr/bin/xterm
TERMINAL_OPTS="-maximized -hold -e"
if [[ ! -f "${VIDEO_PLAYER}" ]];then if [[ ! -f "${VIDEO_PLAYER}" ]];then
echo "${VIDEO_PLAYER} not found" echo "${VIDEO_PLAYER} not found"
@ -10,5 +15,27 @@ if [[ ! -f "${VIDEO_PLAYER}" ]];then
exit 1 exit 1
fi fi
notify-send "Getting radar image" "please wait..." if [[ ! -f "${LINK_DOWNLOADER}" ]];then
${VIDEO_PLAYER} --loop=inf "${IMAGE_URL}" echo "${VIDEO_PLAYER} not found"
echo "Please install it with your system's package manager"
notify-send "${VIDEO_PLAYER} not found" "Please install it with your system's package manager"
exit 1
fi
case "${1}" in
-f | forecast)
echo "Getting forecast from ${FORECAST_URL}..."
${TERMINAL_APP} ${TERMINAL_OPTS} ${LINK_DOWNLOADER} ${FORECAST_URL}
;;
-h | help | --help)
echo -e "\nUsage: ${0} [-f | forecast ], [-h, help, --help]\n"
;;
*)
notify-send "Getting radar image" "please wait..."
${VIDEO_PLAYER} --loop=inf "${IMAGE_URL}"
;;
esac