Skip to content

Instantly share code, notes, and snippets.

@zthxxx
Last active July 12, 2023 15:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zthxxx/522cd6d2f8de01284c7f4a1a9a894662 to your computer and use it in GitHub Desktop.
Save zthxxx/522cd6d2f8de01284c7f4a1a9a894662 to your computer and use it in GitHub Desktop.
My Hammerspoon config
function shell(command)
ok, result = hs.osascript.applescript(string.format('do shell script "%s"', command))
return result
end
function sleep(n)
os.execute('sleep ' .. tonumber(n))
end
-- https://github.com/smudge/nightlight
function nightlight(command)
return shell('/usr/local/bin/nightlight ' .. command)
end
function rerunNightlight()
if (string.match(nightlight('status'), 'on until')) then
nightlight('off')
sleep(0.2)
nightlight('on')
end
end
function caffeinateCallback(eventType)
if (eventType == hs.caffeinate.watcher.screensDidUnlock) then
rerunNightlight()
end
end
caffeinateWatcher = hs.caffeinate.watcher.new(caffeinateCallback)
caffeinateWatcher:start()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment