Skip to content

Instantly share code, notes, and snippets.

@depau
Last active March 6, 2023 06:40
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save depau/de07e9424abac532d2d11eaeeac99a2b to your computer and use it in GitHub Desktop.
Save depau/de07e9424abac532d2d11eaeeac99a2b to your computer and use it in GitHub Desktop.
Force sound mode on LG C1 OLED webOS TV

Force sound mode on LG C1 OLED webOS TVs

This script works around the annoying feature of LG webOS TVs which automatically change the sound mode to "Game optimizer" when Game optimizer is selected as the video mode.

It works around it by setting it back to a user-selected mode every 5 seconds in case it changed to something else.

To install it your TV needs to be rooted. See RootMyTV and WebOSBrew.

Make sure the TV date and time are up to date.

Then you can connect to your TV using SSH or the WebOSBrew Device Manager app and run the following to install it:

curl -L https://gist.githubusercontent.com/depau/de07e9424abac532d2d11eaeeac99a2b/raw/2-install.sh > /tmp/install.sh && bash /tmp/install.sh

To uninstall it, run instead:

curl -L https://gist.githubusercontent.com/depau/de07e9424abac532d2d11eaeeac99a2b/raw/5-uninstall.sh > /tmp/uninstall.sh && bash /tmp/uninstall.sh

To temporarily pause and restart the mod you can run:

systemctl stop force-sound-mode
systemctl start force-sound-mode
#!/bin/sh
set -eu
SOUND_MODES="aiSoundPlus standard movie news sports music game"
echo "Available sound modes:"
# Print sound modes with index
for i in $(seq 1 7); do
echo "- $i: $(echo "$SOUND_MODES" | cut -d ' ' -f "$i")"
done
# shellcheck disable=SC2039
echo -n "Select sound mode and press enter, or press Ctrl+C to cancel: [1-7] "
read -r SOUND_MODE_IDX
if [ "$SOUND_MODE_IDX" -lt 0 ] || [ "$SOUND_MODE_IDX" -gt 6 ]; then
echo "Invalid sound mode number: $SOUND_MODE_IDX"
exit 1
fi
SOUND_MODE=$(echo "$SOUND_MODES" | cut -d ' ' -f "$SOUND_MODE_IDX")
echo "Downloading scripts..."
curl -L https://gist.githubusercontent.com/depau/de07e9424abac532d2d11eaeeac99a2b/raw/3-force_sound_mode.sh \
| sed "s/NEEDLE/$SOUND_MODE/g" >/var/lib/webosbrew/force_sound_mode.sh
chmod +x /var/lib/webosbrew/force_sound_mode.sh
curl -L https://gist.githubusercontent.com/depau/de07e9424abac532d2d11eaeeac99a2b/raw/4-20-force-sound-mode.sh \
>/var/lib/webosbrew/init.d/20-force-sound-mode
chmod +x /var/lib/webosbrew/init.d/20-force-sound-mode
echo "Starting the mod... (it might disconnect you)"
/var/lib/webosbrew/init.d/20-force-sound-mode
echo "Done!"
#!/bin/bash
set -o nounset
# Available modes:
# - aiSoundPlus
# - standard
# - movie
# - news
# - sports
# - music
# - game
sound_mode="NEEDLE"
function get_sound_mode() {
luna-send -f -q settings.soundMode -n 1 'luna://com.webos.settingsservice//getSystemSettings' '{"category":"sound"}' \
| grep soundMode \
| cut -d ':' -f 2 \
| tr -d ' "'
}
function set_sound_mode() {
luna-send -f -n 1 'luna://com.webos.settingsservice//setSystemSettings' '{"category":"sound","settings":{"soundMode":"'"$1"'"}}'
}
while true; do
if [[ "$(get_sound_mode)" != "$sound_mode" ]]; then
set_sound_mode "$sound_mode"
fi
sleep 5
done
#!/bin/bash
if ! [[ -x /var/lib/webosbrew/force_sound_mode.sh ]]; then
echo "force_sound_mode.sh script not found or not executable!"
exit 1
fi
cat > /run/systemd/system/force-sound-mode.service << EOF
[Service]
[Unit]
Description=Force the TV audio mode to a user preset
[Service]
ExecStart=/var/lib/webosbrew/force_sound_mode.sh
Restart=on-failure
RestartSec=5
EOF
systemctl daemon-reload
systemctl restart force-sound-mode
#!/bin/bash
systemctl stop force-sound-mode
rm -f /var/lib/webosbrew/force_sound_mode.sh
rm -f /var/lib/webosbrew/init.d/20-force-sound-mode
@lucca
Copy link

lucca commented Mar 6, 2023

Thanks! This was a huge pain point for me, at least until I finally get an external speaker setup lol.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment