The Linux version of Spotify provides a way to control the music using the DBus org.mpris.MediaPlayer2.spotify service. This lets you skip tracks, play, and pause the music. It doesn't let you change the volume though.

If you are using PulseAudio or PipeWire then you can use the pactl command to...