Skip to content

Automatically wake/sleep and change the input of your LG TV when used as a monitor on macOS

Notifications You must be signed in to change notification settings

alimbada/lg-tv-control-macos

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

61 Commits
 
 
 
 

Repository files navigation

LG TV Control for macOS

Automatically wake/sleep and change the input of your LG TV when used as a monitor on macOS.

This script uses Hammerspoon to detect system events such as power off, sleep, and wake.

Requirements

Installing Requirements

This assumes that you already have Homebrew installed. If you don't, get it first.

Installing Hammerspoon

brew install --cask hammerspoon

Installing Python & LGWebOSRemote

# You can skip this if you already have Python installed and know what you're doing.
brew install [email protected]
pip install pipx

# Then install LGWebRemote...
pipx install git+https://github.com/klattimer/LGWebOSRemote.git
pipx ensurepath

Removing old versions of LGWebOSRemote

If you had previously installed LGWebOSRemote with pip (rather than pipx), you can remove the old version by running:

rm -fr ~/opt/lgtv

Configuring LGWebOSRemote

By now, you should be able to run

lgtv scan ssl

and see some info about your TV. Grab your TV's IP address from the output. Then:

lgtv auth <ip_address_here> MyTV --ssl

and follow the instructions on your TV.

Now, try the following:

lgtv --name MyTV --ssl swInfo
lgtv --name MyTV --ssl screenOff

If everything is working as expected, your screen should turn off.

Installing the Hammerspoon script

  1. Copy lgtv_init.luafrom this repo to ~/.hammerspoon
  2. Run the following
mkdir -p ~/.hammerspoon
touch ~/.hammerspoon/init.lua
echo "require \"lgtv_init\"" >> ~/.hammerspoon/init.lua
  1. Change the HDMI input at the top of the Lua script, if needed.

Special Thanks

Thanks to @greyshi for extending upon my initial Wake On LAN gist and introducing LGWebOSRemote.

About

Automatically wake/sleep and change the input of your LG TV when used as a monitor on macOS

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Lua 100.0%