Created
January 20, 2023 19:07
-
-
Save kopiro/161630e5508b449ff7f864ff6acd8a92 to your computer and use it in GitHub Desktop.
HyperHDR on/off binary with WebOS 4.x autostart patch
This file contains hidden or 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 | |
IP="192.168.0.45" | |
MAC="AA-BB-CC-DD-EE-FF" | |
get_status() { | |
/usr/bin/curl -s "http://$IP:8090/json-rpc?request=%7B%22command%22:%22serverinfo%22%7D" | |
} | |
call_autostart() { | |
/usr/local/bin/webostv luna-message "$IP" "$MAC" luna://org.webosbrew.hbchannel.service/autostart '{}' | |
} | |
ensure_autostarted() { | |
if ! get_status; then | |
retries=0 | |
call_autostart | |
while ! get_status; do | |
sleep 2 | |
retries=$((retries+1)) | |
if [ $retries -gt 5 ]; then | |
echo "Timeout" | |
exit 1 | |
fi | |
done | |
fi | |
} | |
if [ "$1" = "on" ]; then | |
ensure_autostarted | |
/usr/bin/curl "http://$IP:8090/json-rpc?request=%7B%22command%22:%22componentstate%22,%22componentstate%22:%7B%22component%22:%22LEDDEVICE%22,%22state%22:true%7D%7D" | |
elif [ "$1" = "off" ]; then | |
ensure_autostarted | |
/usr/bin/curl "http://$IP:8090/json-rpc?request=%7B%22command%22:%22componentstate%22,%22componentstate%22:%7B%22component%22:%22LEDDEVICE%22,%22state%22:false%7D%7D" | |
elif [ "$1" = "status" ]; then | |
if get_status | jq '.info.components[] | select(.name=="LEDDEVICE") | .enabled' | grep -i 'true'; then | |
echo "HyperHDR is on" | |
exit 0 | |
else | |
echo "HyperHDR is off" | |
exit 1 | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment