-
-
Save underscorebrody/09a9ce5abbc4c5f0165b8fc29c3b0d58 to your computer and use it in GitHub Desktop.
This is script to auto on/off a Logitech light when the webcam is on/off in Mac. It requires hidapitester. Modified to support multiple lights.
This file contains 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
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<dict> | |
<key>Label</key> | |
<string>litra-auto-on</string> | |
<key>ProgramArguments</key> | |
<array><string>/Library/LaunchDaemons/litra-auto-on.sh</string></array> | |
<key>RunAtLoad</key> | |
<true/> | |
</dict> | |
</plist> |
This file contains 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 | |
# Download both files and https://github.com/todbot/hidapitester to /Library/LaunchDaemons/ | |
# Execute the following commands to launch it on login | |
# sudo chown root:wheel /Library/LaunchDaemons/litra-auto-on.plist | |
# sudo chmod 600 /Library/LaunchDaemons/litra-auto-on.plist | |
# sudo launchctl load -w /Library/LaunchDaemons/litra-auto-on.plist | |
# sudo chmod 0744 /Library/LaunchDaemons/litra-auto-on.sh | |
# sudo chown root:wheel /Library/LaunchDaemons/litra-auto-on.sh | |
# sudo launchctl bootstrap system /Library/LaunchDaemons/litra-auto-on.plist | |
# For test it: | |
# launchctl start litra-auto-on | |
# For logs add to the plist: | |
# <key>StandardErrorPath</key> | |
# <string>/tmp/litra.auto.err</string> | |
# <key>StandardOutPath</key> | |
# <string>/tmp/litra.auto.out</string> | |
# Use 046D/C900 for older models | |
model="046D/C900" | |
# serial numbers for multiple lights | |
serial01="SERIALONE" | |
serial02="SERIALTWO" | |
# Change to your own path | |
hidapitester="/Library/LaunchDaemons/hidapitester" | |
on="0x11,0xff,0x04,0x1c,0x01" | |
off="0x11,0xff,0x04,0x1c" | |
log stream --predicate 'subsystem contains "com.apple.UVCExtension" and composedMessage contains "Post PowerLog"' | while read LOGLINE; do | |
if [[ "${LOGLINE}" == *"On;"* ]]; then | |
eval "$hidapitester --serial $serial01 --open --length 20 --send-output $on" | |
eval "$hidapitester --serial $serial02 --open --length 20 --send-output $on" | |
elif [[ "${LOGLINE}" == *"Off;"* ]]; then | |
eval "$hidapitester --serial $serial01 --open --length 20 --send-output $off" | |
eval "$hidapitester --serial $serial02 --open --length 20 --send-output $off" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment