Last active
September 14, 2018 23:34
-
-
Save dardo82/66ab5f1947de0186dfbf to your computer and use it in GitHub Desktop.
FW webcam USB light
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/zsh | |
# Use an USB light to let FW webcam see | |
PATH=$PATH:/usr/local/bin | |
UHCOPTS=$(uhubctl | awk '{ text=text"\n"$0; if ($0~/hub/) text=$0; if (text~/power$/) { print text; text="" } }' \ | |
| awk -F',| |:' -v ORS=" " '{ print $5 }' | awk '{ print "-p "$2" -l "$1 }') | |
if [ -n "$UHCOPTS" ]; then | |
uhubctl -a 0 ${=UHCOPTS} | |
DEVNAME="iSight"; DEVGUID=$(system_profiler SPCameraDataType | awk -v dev="$DEVNAME:" -F':|x|-' '{ if ($0~dev) n=NR; if (NR==n+3 && NR!=3) print $3 }') | |
IOFWUCC=$(ioreg -r -n IOFireWireDevice@$DEVGUID | awk -F'"' '/IOUserClientClass/ { print $4 }') | |
RNUMBER=$(ioreg -r -n IOFireWireDevice@$DEVGUID | awk -F' |>' -v ucc=" $IOFWUCC " '{ if ($0~ucc) { print $17; exit } }') | |
while [ -n "$RNUMBER" ]; do | |
OLDRNUM=$RNUMBER | |
RNUMBER=$(ioreg -r -n IOFireWireDevice@$DEVGUID | awk -F' |>' -v ucc=" $IOFWUCC " '{ if ($0~ucc) { print $17; exit } }') | |
if [ $OLDRNUM -eq 5 -a $RNUMBER -eq 6 ]; then | |
uhubctl -a 1 ${=UHCOPTS} | |
fi | |
if [ $OLDRNUM -eq 6 -a $RNUMBER -eq 5 ]; then | |
uhubctl -a 0 ${=UHCOPTS} | |
fi | |
sleep 1 | |
done | |
fi |
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/sh | |
HL="$HOME/Library"; HLASCLA="$HL/Application Support/Camera Lights Action"; HLLA="$HL/LaunchAgents" | |
chmod a+rx cla.sh; mkdir $HLASCLA; cp cla.sh $HLASCLA; cp it.dardo82.CameraLightsAction.plist $HLLA | |
launchctl load -w "$HLLA/it.dardo82.CameraLightsAction.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
<?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>it.dardo82.CameraLightsAction</string> | |
<key>ProgramArguments</key> | |
<array> | |
<string>/Library/Application Support/Camera Lights Action/cla.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/sh | |
HL="$HOME/Library"; HLASCLA="$HL/Application Support/Camera Lights Action"; HLLA="$HL/LaunchAgents" | |
launchctl unload "$HLLA/it.dardo82.CameraLightsAction.plist" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I can't, too... Sorry. :-/
Anyway, the ports are on by default so we can note which port is that before turning it off and then remember it to turn it on.