Thanks to how the snap has been prepared, this is easy to realize.
The snap package of Foobar defines several contextual actions for the launcher. Inspecting the launcher, /snap/foobar2000/242/usr/share/applications/foobar2000.desktop
, you can see the command you can use to implement these global shortcut. This is the relevant section of the .desktop file.
[Desktop Action PlayPause]
Name=Play/Pause
Exec=foobar2000 -playpause
[Desktop Action Stop]
Name=Stop
Exec=foobar2000 -stop
[Desktop Action Next]
Name=Next
Exec=foobar2000 -next
[Desktop Action Prev]
Name=Prev
Exec=foobar2000 -prev
[Desktop Action Random]
Name=Random
Exec=foobar2000 -rand
[Desktop Action Config]
Name=Preferences
Exec=foobar2000 -config
The command which foobar2000
shows you that the executable is located in /snap/bin
. To define your shortcut to start/pauze playing, use the command
/snap/bin/foobar2000 -playpause