Last active
January 31, 2022 04:39
-
-
Save dardo82/52799ae762e8673c8726 to your computer and use it in GitHub Desktop.
Morse code 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 | |
# Flash a message in Morse code with an USB light | |
uhubctl -a 1; sleep 4.0 | |
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 }') | |
uhubctl -a 0 ${=UHCOPTS} | |
alias dit="uhubctl -a 1 $UHCOPTS; sleep 0.1; uhubctl -a 0 $UHCOPTS" | |
alias dah="uhubctl -a 1 $UHCOPTS; sleep 0.6; uhubctl -a 0 $UHCOPTS" | |
alias sbs="sleep 0.25" | |
alias sbl="sleep 0.75" | |
eval "$(morse $1 | sed 's/\./dit;sbs;/g; s/-/dah;sbs;/g; s/ /sbl;/g' | sed 's/sbs;/& /g; s/sbs; sbl;/sbl; /g')" | |
unalias dit dah | |
unalias sbs sbl |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment