2023-04-20 13:59:54 +02:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
# setting the locale, some users have issues with different locales, this forces the correct one
|
|
|
|
export LC_ALL=en_US.UTF-8
|
|
|
|
|
|
|
|
#wrapper script for running weather on interval
|
|
|
|
|
|
|
|
fahrenheit=$1
|
|
|
|
location=$2
|
|
|
|
fixedlocation=$3
|
|
|
|
|
2023-12-21 03:32:56 +01:00
|
|
|
DATAFILE=/tmp/.kanagawa-tmux-data
|
|
|
|
LAST_EXEC_FILE="/tmp/.kanagawa-tmux-weather-last-exec"
|
2023-04-20 13:59:54 +02:00
|
|
|
RUN_EACH=1200
|
|
|
|
TIME_NOW=$(date +%s)
|
|
|
|
TIME_LAST=$(cat "${LAST_EXEC_FILE}" 2>/dev/null || echo "0")
|
|
|
|
|
|
|
|
main()
|
|
|
|
{
|
|
|
|
current_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
|
|
|
|
|
|
if [ "$(expr ${TIME_LAST} + ${RUN_EACH})" -lt "${TIME_NOW}" ]; then
|
|
|
|
# Run weather script here
|
2024-01-04 02:59:02 +01:00
|
|
|
$current_dir/weather.sh $fahrenheit $location "$fixedlocation" > "${DATAFILE}"
|
2023-04-20 13:59:54 +02:00
|
|
|
echo "${TIME_NOW}" > "${LAST_EXEC_FILE}"
|
|
|
|
fi
|
|
|
|
|
|
|
|
cat "${DATAFILE}"
|
|
|
|
}
|
|
|
|
|
|
|
|
#run main driver function
|
|
|
|
main
|