Bluetoothctl in Linux.
Have done exactly this 15 years ago to find my lost phone (:
Also wrote a cheap 30 line shell script to allow playing videos and music to “follow me” from one room to another with well placed raspberry pi’s, 11 years ago