Skip to content

Instantly share code, notes, and snippets.

@c4pone
Created November 8, 2018 18:26
Show Gist options
  • Save c4pone/c0cacc5a4c971d64fc361e8da262c460 to your computer and use it in GitHub Desktop.
Save c4pone/c0cacc5a4c971d64fc361e8da262c460 to your computer and use it in GitHub Desktop.
Quick and simpe way to get a regulate your chromecast audio over the menu tray
import rumps # rumps==0.2.1a0
import pychromecast # PyChromecast==2.3.0
chromecast = None
def get_chromecast(device_name):
chromecasts = pychromecast.get_chromecasts()
for chromecast in chromecasts:
if chromecast.device.friendly_name == device_name:
return chromecast
raise Exception("could not find chromecast")
def change_volume(sender):
volume = sender.value
chromecast.set_volume(volume)
if __name__ == "__main__":
chromecast = get_chromecast("Living Room speaker")
app = rumps.App("Chromecast Volume", title=chromecast.device.friendly_name)
app.menu = [
rumps.SliderMenuItem("Volume", 0, 0, 1, callback=change_volume),
]
app.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment