Keyboard / Touchbar media keys not working
This app is great, but one final piece is missing, ability to pause/resume or switch radio staton with media keys on keyboard or touchbar. Also in Big Sur currently playing has been introduced to menubar and radiobar is not present there with it's playback. Finally bluetooth headphones have media controls and they are not working with radiobar.
You can send commands through a TCP connection on port 65432 on localhost. E.g. you can use the commands 'on' 'off' or any number that corresponds with your radio presets. Below is an example script which I use with an Alfred workflow to issue the commands (this is similar to remote.py in the repository). Also check the explanation in the README.
import socket
import sys
import time
import subprocess
import errno
from socket import error as socket_error
HOST = '127.0.0.1' # The server's hostname or IP address
PORT = 65432 # The port used by the server
def connect():
try:
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((HOST, PORT))
return s
except socket_error as serr:
if serr.errno != errno.ECONNREFUSED:
raise serr
subprocess.Popen(["open","/Applications/RadioBar.app"])
time.sleep(5)
return connect()
try:
s = connect()
s.sendall(sys.argv[1])
data = s.recv(1024)
print(data)
except socket_error as serr:
print(serr)
sys.exit(1)
Thank you for reply. How are you plugging such script to keys? Are you able to control other media apps once they are playing after assigning these keys to radiobar?
Take a look at apps like Alfred, Keyboard Maestro or Fastscripts.