Last active
September 14, 2018 23:34
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" |
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.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ok, thanks for input. I will start coding it, and will commit when ready - may take a week or two.
You can help by pushing it into homebrew: https://github.com/Homebrew/homebrew-head-only/pull/172 - I cannot comment on that thread, unfortunately. Thanks!