There is a feature in the WH-1000XM4 that the current media playing automatically pauses if you remove the headset (read the full description on Sony's website):
When you listen to music while wearing the headset on your ears, the headset will pause music playback automatically if the headset is removed. When the headset is worn again, the headset resumes music playback.
This works on my phone, but doesn't on my Ubuntu Linux. I use Pulse Audio. The Bluetooth connection is fine and all buttons work. If I pause and start once (via tapping on the headset) the upper mentioned automatic pause-play works, however it doesn't "watch" if media is playing or not.
I think the main issue is that the headset doesn't know if media is playing or not. How could I solve this? I will provide any commands outputs as needed.