Skip to content

Instantly share code, notes, and snippets.

@aleksandersumowski
aleksandersumowski / media-keys.py
Created February 29, 2024 16:51
Python script to emulate media keys on mac
#!/opt/homebrew/bin/python3
# CLI program to control the mediakeys on OS X. Used to emulate the mediakey on a keyboard with no such keys.
# Easiest used in combination with a launcher/trigger software such as Quicksilver.
# Main part taken from http://stackoverflow.com/questions/11045814/emulate-media-key-press-on-mac
# Glue to make it into cli program by Fredrik Wallner http://www.wallner.nu/fredrik/
# requires installing `pyobjc` eg via `/opt/homebrew/bin/pip3 install -U pyobjc`
import Quartz
import sys