Skip to content

Instantly share code, notes, and snippets.

@gaearon
Last active December 19, 2025 16:00
Show Gist options
  • Select an option

  • Save gaearon/9c4469fb8e4376bab32bd5bda942861b to your computer and use it in GitHub Desktop.

Select an option

Save gaearon/9c4469fb8e4376bab32bd5bda942861b to your computer and use it in GitHub Desktop.
Unfuck Sony hotel TV picture mode
#!/bin/bash
# Note: Connect to the TV's wifi network first
MY_IP=$(ipconfig getifaddr en0)
SUBNET=$(echo $MY_IP | cut -d. -f1-3)
TV_IP=""
echo "πŸ” Scanning $SUBNET.0/24 for Sony TV..."
for ip in $(nmap -sn $SUBNET.0/24 -oG - 2>/dev/null | grep "Up" | awk '{print $2}'); do
if [[ "$ip" != "$MY_IP" && "$ip" != "$SUBNET.1" && "$ip" != "$SUBNET.254" ]]; then
RESPONSE=$(curl -s --connect-timeout 2 -X POST http://$ip/sony/system \
-H "Content-Type: application/json" \
-d '{"method":"getSystemInformation","id":1,"params":[],"version":"1.0"}' 2>/dev/null)
if echo "$RESPONSE" | grep -q "BRAVIA"; then
TV_IP=$ip
MODEL=$(echo "$RESPONSE" | python3 -c "import sys,json; print(json.load(sys.stdin)['result'][0]['model'])" 2>/dev/null)
echo "βœ… Found $MODEL at $TV_IP"
break
fi
fi
done
if [[ -z "$TV_IP" ]]; then
echo "❌ No Sony TV found"
exit 1
fi
apply() {
curl -s -X POST http://$TV_IP/sony/video \
-H "Content-Type: application/json" \
-d "{\"method\":\"setPictureQualitySettings\",\"id\":1,\"params\":[{\"settings\":$1}],\"version\":\"1.0\"}" > /dev/null
}
MODE=$(curl -s -X POST http://$TV_IP/sony/video \
-H "Content-Type: application/json" \
-d '{"method":"getPictureQualitySettings","id":1,"params":[{"target":"pictureMode"}],"version":"1.0"}')
if echo "$MODE" | grep -q "dv"; then
echo "🎬 Dolby Vision β€” applying dvDark + sharpness 20"
apply '[{"value":"dvDark","target":"pictureMode"},{"value":"20","target":"sharpness"}]'
else
echo "🎬 Standard β€” applying IMAX + sharpness 20"
apply '[{"value":"imax","target":"pictureMode"},{"value":"20","target":"sharpness"}]'
fi
echo "βœ… Done. Enjoy."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment