Background detection through environment variables and a custom background toggle script