Fix the background agent for the weather script #203
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation for the change
The weather daemon isn't spawned when you start Tmux.
In the condition to launch the
sleep_weather.sh
we have a check for atmux session
before starting while loop.But Tmux on startup waiting for this script to finish before proceeding and creating the session.
When the session is spawned we will have weather data now because it'll be fetched by the script before the while loop is reached. After initial weather retrieval, it won't be updated anymore.
I've changed this behavior and the weather script will be triggered by the Tmux status line. It's recording the time of the last execution. If the delta between the current time and of the time of the last execution is bigger than the 1200s (default value) it won't do anything. With this change, we'll not be needed a background agent at all.
Also,
sleep_weather.sh
didn't honor theme options on the first execution (the first weather retrieval is happening without passing those options to the script). So, this PR will fix #181Change tested on the MacOS aarch64.