-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.lua
36 lines (31 loc) · 856 Bytes
/
init.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
local obj={}
obj.__index = obj
-- Metadata
obj.name = "CPU Temp Menu Display"
obj.version = "1.0"
obj.author = "catskull <[email protected]>"
obj.license = "MIT"
obj.homepage = "https://github.com/catskull/CPUTempMenuDisplay.spoon"
obj.fahrenheit = false
function obj:makeStatsMenu()
if statsMenu == nil then
statsMenu = hs.menubar.new()
statsMenu:setClickCallback(function()
obj.fahrenheit = not obj.fahrenheit
obj.makeStatsMenu()
end)
end
command = "iStats cpu temp --no-graphs --no-labels"
if obj.fahrenheit then
command = command .. " -f"
end
temp, gar1, gar2, gar3 = hs.execute(command, true)
temp = temp:gsub("[\r\n]", "")
statsMenu:setTitle(temp)
end
function obj:start(interval)
obj.makeStatsMenu()
cpuMenuTimer = hs.timer.new((interval or 20), obj.makeStatsMenu)
cpuMenuTimer:start()
end
return obj