Lua
January 8, 2026 ยท View on GitHub
Summary
Used as scripting language inside various tools like:
- Hammerspoon - system event handler for macOS
- MPV - video player
Linting
LuaCheck
LuaCheck is the standard linter.
Install it on macOS using Homebrew:
brew install luacheck
Run it against a lua script:
luacheck "$filename.lua"
Output:
Checking resume-conditions.lua OK
Total: 0 warnings / 0 errors in 1 file
LuaCheck HotKey Integration
I call this locally via a hotkey in my
.vimrc and IntelliJ
which both call my generalized
lint.sh script
provided in DevOps-Bash-tools which is in my $PATH.
LuaCheck CI/CD
In CI/CD I use a ready-to-run GitHub Actions reusable workflow from :octocat: HariSekhon/GitHub-Actions:
jobs:
LuaCheck:
name: LuaCheck
uses: HariSekhon/GitHub-Actions/.github/workflows/luacheck.yaml@master
Real World Lua Code
Here is some real world Lua code for you as examples of how I've used this language.
Hammerspoon Event Handler for macOS
I this code to automatically switch macOS sound when AirPods connect to a dual output channel so that I can Shazam songs from Love Island while watching it:
:octocat: HariSekhon/Hammerspoon
More details are in the Mac page's sections:
MPV video player
I use this code to automatically resume playing videos in mpv only if they match the conditions I want, such as videos have to be a certain length and I have to be more than a certain amount of time into the video otherwise you may as well start it from the beginning.
This is impressively flexible to suit your preferences.
:octocat: HariSekhon/DevOps-Bash-tools - configs/.config/mpv/scripts/resume-conditions.lua