Hey there I have a (for me atleast) complicated question.
I have a script that interacts with the plex (and sonarr but that isn’t important) api. I made it look and work like an interface. See the pictures:
I run the script and this is the first thing I see:
I choose to interact with the plex api and get to see the following page:
There appears to be an update available for pms so I select “update”:
But someone is watching a movie or series. So it doesn’t update because updating shuts down pms which would stop the stream of that person. So I made the script show that message when that happens (instead of updating). It shows it for 10 seconds and after that you go back to the menu in picture 2.
When nobody is streaming, it just goes through the update process and after that brings you back to
Home page Plex API.
Now comes the question
I want to make an option called notify (an option like I could choose “plex” and “update” and now I want “notify”). So at the bottom of the message in picture 3, I would have
exit | back | notify: (instead of sleeping 10s and going to
Home page Plex API).
When I choose that option, it needs to run some code in the background. So it immediately goes back to
Home page Plex API but in the background, it checks every 2 minutes if there’s still anybody watching. And when there isn’t anymore, it sets a variable to
But the problem for me is “in the background”. I want to run that piece of code in the background so that I could use the script in the mean time. So I choose “notify” and am then immediately able to use the script again. I can do (aka choose options/access parts of the api) anything I want, while in the background that part of code is running. And after it detects that that variable is set to false, it stops running in the background.
Do you have any idea how to do this?
Normally I’m already trying things and testing out if something works but with this problem, I really don’t know what to do/where to begin.