2 ms·
Yeah hammerspoon rocks and is very lightweight and easy to use... This simple example shows how powerful it is for automation: http://www.hammerspoon.org/go/#s
by hipjiveguy 11y ago
Yeah hammerspoon rocks and is very lightweight and easy to use... This simple example shows how powerful it is for automation:
http://www.hammerspoon.org/go/#simplemenubar http://www.hammerspoon.org/go/#simplemenubar
-- Creating a simple menubar item
-- Lots of Mac utilities place a small icon in the system menubar to display their
-- status and let you interact with them. We're going to use two of Hammerspoon's
-- extensions to whip up a very simple replacement for the popular utility Caffeine.
local caffeine = hs.menubar.new()
function setCaffeineDisplay(state)
if state then
caffeine:setTitle("AWAKE")
else
caffeine:setTitle("SLEEPY")
end
end
function caffeineClicked()
setCaffeineDisplay(hs.caffeinate.toggle("displayIdle"))
end
if caffeine then
caffeine:setClickCallback(caffeineClicked)
setCaffeineDisplay(hs.caffeinate.get("displayIdle"))
end