-
-
Save mie00/e8d3add9b5463e0bb75d3491deb42e21 to your computer and use it in GitHub Desktop.
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 | |
MAC='0C:62:A6:13:4A:8A' | |
IP='192.168.178.13' | |
[ "$#" == 0 ] && echo 'missing argument, can be one of on, off, toggle' >&2 && exit 1 | |
on () { | |
echo "turning on" | |
python "$HOME"/.bin/wowlan.py $MAC | |
} | |
off () { | |
echo "turning off" | |
key Standby | |
} | |
mute () { | |
echo "mute" | |
post audio/volume '{"muted": true}' | |
} | |
unmute () { | |
echo "unmute" | |
post audio/volume '{"muted": false}' | |
} | |
volume () { | |
echo "volume" | |
post audio/volume '{"current": '$1'}' | |
} | |
key () { | |
post input/key '{"key": "'$1'"}' | |
} | |
post () { | |
curl "http:///$IP:1925/1/$1" -d "$2" | |
} | |
get () { | |
curl --connect-timeout 1 "http:///$IP:1925/1/$1" | |
} | |
ison () { | |
get system/model | |
} | |
stat () { | |
ison && echo 'on' || echo 'off' | |
} | |
fail () { | |
echo $1 >&2 | |
exit 1 | |
} | |
cmd="$1" | |
shift | |
case "$cmd" in | |
"on") | |
on | |
;; | |
"off") | |
off | |
;; | |
"toggle") | |
ison && off || on | |
;; | |
"status") | |
stat | |
;; | |
"mute") | |
mute | |
;; | |
"unmute") | |
unmute | |
;; | |
"volume") | |
v="$1" | |
[ -z "$v" ] && fail "missing volume argument" | |
volume $v | |
;; | |
"post") | |
c="$1" | |
b="$2" | |
[ -z "$c" ] && fail 'missing command' | |
post "$c" "$b" | |
;; | |
"get") | |
c="$1" | |
[ -z "$c" ] && fail ' | |
missing command, can be one of: | |
ambilight/topology | |
ambilight/mode | |
ambilight/measured | |
ambilight/processed | |
ambilight/cached | |
audio/volume | |
channellists | |
channellists/id | |
channels | |
channels/current | |
channels/id | |
sources | |
sources/current | |
system | |
system/country | |
system/name | |
system/menulanguage | |
system/model | |
system/serialnumber | |
system/softwareversion | |
' | |
get "$c" | |
;; | |
*) | |
fail "arguments are on, off, toggle, mute, unmute, volume <volume>. Got $cmd" | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment