From ab4754b16e3685ff7758f2628bc432726242132d Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Mon, 12 Nov 2018 09:16:07 -0800 Subject: add power usage to my menu bar in osx --- hammerspoon/init.lua | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'hammerspoon') diff --git a/hammerspoon/init.lua b/hammerspoon/init.lua index f72699d..2f6b836 100644 --- a/hammerspoon/init.lua +++ b/hammerspoon/init.lua @@ -134,14 +134,20 @@ end) enter_bindings(hs.application.frontmostApplication():name()) current_application_watcher:start() -menubar = hs.menubar.new() +cpu_usage_bar = hs.menubar.new() timer = hs.timer.doEvery(1, function() hs.host.cpuUsage(function(cpu) local cpuUsage = cpu["overall"]["active"] - menubar:setTitle(math.floor(cpuUsage + 0.5) .. "%") + cpu_usage_bar:setTitle(math.floor(cpuUsage + 0.5) .. "%") end) end) +power_usage_bar = hs.menubar.new() +timer = hs.timer.doEvery(5, function() + local watts = hs.execute("/Users/doy/.bin/st-doy1.local/power-usage") + power_usage_bar:setTitle(string.gsub(watts, "\n", "") .. "W") +end) + hs.caffeinate.set("systemIdle", true, true) hs.alert("Hammerspoon config reloaded") -- cgit v1.2.3-54-g00ecf