Last active
May 5, 2023 08:51
-
-
Save fosron/665a0b06cf8cd4cae906a6b4cbb387cf to your computer and use it in GitHub Desktop.
streamdeck_monitor.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Replace this with the correct path to the Stream Deck app | |
STREAMDECK_APP_PATH="/Applications/Stream Deck.app" | |
# Vendor and product ID for Stream Deck (Elgato Stream Deck MK2) | |
VENDOR_ID="0fd9" | |
PRODUCT_ID="0080" | |
# Function to check if the Stream Deck is connected | |
streamdeck_connected() { | |
system_profiler SPUSBDataType -xml | grep -q -E "idVendor|idProduct" -e "${VENDOR_ID}" -e "${PRODUCT_ID}" | |
return $? | |
} | |
# Function to check if the Stream Deck app is running | |
streamdeck_app_running() { | |
pgrep -q -x "Stream Deck" | |
return $? | |
} | |
# Main loop | |
while true; do | |
if streamdeck_connected; then | |
echo "Stream Deck MK2 connected." | |
if ! streamdeck_app_running; then | |
echo "Starting Stream Deck app." | |
open "${STREAMDECK_APP_PATH}" | |
fi | |
else | |
echo "Stream Deck MK2 not connected." | |
if streamdeck_app_running; then | |
echo "Stopping Stream Deck app." | |
pkill -x "Stream Deck" | |
fi | |
fi | |
# Check again in 5 seconds | |
sleep 5 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment