added script to send midi messages
This commit is contained in:
parent
7a1a56140d
commit
5354f40f4a
1 changed files with 22 additions and 0 deletions
22
send-midi.sh
Executable file
22
send-midi.sh
Executable file
|
@ -0,0 +1,22 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# author: Daniel Sommer <daniel.sommer@velvettear.de>
|
||||
# license: MIT
|
||||
|
||||
dir="$(dirname $(realpath "$0"))"
|
||||
|
||||
. "$dir/config.env"
|
||||
|
||||
function checkVariable() {
|
||||
[[ -z "$1" ]] && printf "${FONT_BOLD}error: ${FONT_NORMAL}no $2 given\n" && exit 1
|
||||
! [ "$1" -eq "$1" ] 2> /dev/null && printf "${FONT_BOLD}error: ${FONT_NORMAL}given $2 \'$1\' is not a number\n" && exit 1
|
||||
}
|
||||
|
||||
checkVariable "$1" "midi channel"
|
||||
checkVariable "$2" "midi controller"
|
||||
checkVariable "$3" "value"
|
||||
|
||||
url="$(""$dir"/url.sh" "/midi")"
|
||||
|
||||
printf "> sending POST request to \'$url\'...${FONT_BOLD}"
|
||||
[ "$(curl -X POST -s -f -w "\n%{http_code}" "$url" -d "channel=$1" -d "controller=$2" -d "value=$3" | tail -n1)" -ne 200 ] && printf " error!\n" || printf " done!\n"
|
Loading…
Reference in a new issue