This guide explains how to automate an Elgato Key Light to turn on when OBS Studio opens and off when it closes, using macOS's launchd
.
- Elgato Key Light connected to the same network as your Mac.
- OBS Studio installed on your Mac.
- Open the Elgato Control Center app on your computer or mobile device.
- Locate your Key Light and find its IP address in the device settings (e.g.,
192.168.50.227
). - Note down this IP address, as we’ll use it in the script.
-
Create the Shell Script to Control the Light:
- Open Terminal and create a new script file:
sudo nano /usr/local/bin/elgato_light
- Paste the following code, replacing
"<Elgato_IP>"
with the actual IP address of your Key Light:#!/bin/bash ELGATO_IP="<Elgato_IP>:9123" if [ "$1" == "on" ]; then curl -X PUT "http://$ELGATO_IP/elgato/lights" \ -H "Content-Type: application/json" \ -d '{"lights":[{"on":1,"brightness":100,"temperature":213}]}' elif [ "$1" == "off" ]; then curl -X PUT "http://$ELGATO_IP/elgato/lights" \ -H "Content-Type: application/json" \ -d '{"lights":[{"on":0}]}' else echo "Usage: elgato_light {on|off}" exit 1 fi
- Save and close the file (
Ctrl + X
, thenY
, thenEnter
).
- Open Terminal and create a new script file:
-
Make the Script Executable:
sudo chmod +x /usr/local/bin/elgato_light
-
Test the Command:
- Run the following commands to ensure they work:
elgato_light on # Turns on the light elgato_light off # Turns off the light
- Run the following commands to ensure they work:
-
Create a Check Script:
- In Terminal, create another script that checks if OBS Studio is running and toggles the light:
nano ~/check_obs_light.sh
- Paste the following code:
#!/bin/bash if pgrep -f "/Applications/OBS.app/Contents/MacOS/OBS" > /dev/null; then /usr/local/bin/elgato_light on else /usr/local/bin/elgato_light off fi
- Save and close the file.
- Please note: the actual path to the application might be different. To locate path run
ps aux | grep -i "obs"
after you launch OBS.
- In Terminal, create another script that checks if OBS Studio is running and toggles the light:
-
Make the Script Executable:
chmod +x ~/check_obs_light.sh
-
Create a
launchd
Property List (plist) File:- This
.plist
file will runcheck_obs_light.sh
at regular intervals to check OBS status. - Create the file with:
nano ~/Library/LaunchAgents/com.user.check_obs_light.plist
- This
-
Add the Following Configuration:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Label</key> <string>com.user.check_obs_light</string> <key>ProgramArguments</key> <array> <string>/bin/bash</string> <string>/Users/YOUR_USERNAME/check_obs_light.sh</string> </array> <key>StartInterval</key> <integer>3</integer> <key>RunAtLoad</key> <true/> </dict> </plist>
- Replace
YOUR_USERNAME
with your actual macOS username.
- Replace
-
Load the
launchd
Agent:- Load the agent to start checking OBS status at intervals:
launchctl load ~/Library/LaunchAgents/com.user.check_obs_light.plist
- Load the agent to start checking OBS status at intervals:
-
To Reload the Agent After Making Changes:
- If you update the
.plist
file (e.g., to change the interval), reload it with:launchctl unload ~/Library/LaunchAgents/com.user.check_obs_light.plist launchctl load ~/Library/LaunchAgents/com.user.check_obs_light.plist
- If you update the
Your setup is now complete. When you open OBS Studio, the Elgato Key Light will turn on, and when you close OBS Studio, it will turn off. This setup works seamlessly without needing a constantly running script.