I tried this but I didn't work. When I googled it, I found out that Apple has disabled this in BigSur.
Here is the link to it: https://developer.apple.com/forums/thread/106768
(I'd really wanted to write a bash script, this seemed like a good option.)
For example: https://news.ycombinator.com/item?id=26062315
Or, another solution that looks promising: https://news.ycombinator.com/item?id=26062553
That solution looks clean and simple, though I've not tried it. It might work for you!
Could you try if it works on your Apple device?