The potential best way to do this is to have a thread that just runs a function which is the "TUI daemon". It can just have a loop running every second and checking if there is a start_daemon.flag that has existed for more than 5 seconds. Then it needs to call a subprocess command to run it.