60 lines
2.4 KiB
Lua
60 lines
2.4 KiB
Lua
-- ========================================================================
|
|
-- SPOON RUNTIME CONFIGURATION MODULE
|
|
-- ========================================================================
|
|
|
|
---- SpeedMenu Implementation
|
|
if spoon.SpeedMenu then
|
|
-- Define the Fix Function (includes MAC and IPv6 parsing via shell)
|
|
local function applyFullMenuFix()
|
|
local interface = spoon.SpeedMenu.interface or "en0"
|
|
local ssid = hs.wifi.currentNetwork() or "Disconnected"
|
|
local details = hs.network.interfaceDetails(interface)
|
|
|
|
local ipv4 = (details and details.IPv4) and details.IPv4.Addresses[1] or "N/A"
|
|
local ipv6 = (details and details.IPv6) and details.IPv6.Addresses[1] or "N/A"
|
|
|
|
-- Get MAC Address via native shell pipe
|
|
local macaddr = hs.execute('ifconfig ' .. interface .. ' | grep ether | awk \'{print $2}\''):gsub("%s+", "")
|
|
|
|
local menuitems = {
|
|
{ title = "SSID: " .. ssid, fn = function() hs.pasteboard.setContents(ssid) end },
|
|
{ title = "IPv4: " .. ipv4, fn = function() hs.pasteboard.setContents(ipv4) end },
|
|
{ title = "IPv6: " .. ipv6, fn = function() hs.pasteboard.setContents(ipv6) end },
|
|
{ title = "MAC: " .. macaddr, fn = function() hs.pasteboard.setContents(macaddr) end },
|
|
{ title = "-" },
|
|
{ title = "Rescan Network Interfaces", fn = function() spoon.SpeedMenu:rescan() end }
|
|
}
|
|
spoon.SpeedMenu.menubar:setMenu(menuitems)
|
|
end
|
|
|
|
-- Overwrite the baseline rescan hook cleanly
|
|
local oldRescan = spoon.SpeedMenu.rescan
|
|
spoon.SpeedMenu.rescan = function(self)
|
|
oldRescan(self)
|
|
applyFullMenuFix()
|
|
end
|
|
|
|
-- Toggle Engine State Manager
|
|
local speedMenuRunning = false
|
|
hs.hotkey.bind({"cmd", "alt", "ctrl"}, "W", function()
|
|
if speedMenuRunning then
|
|
spoon.SpeedMenu:stop()
|
|
hs.alert.show("SpeedMenu Stopped")
|
|
else
|
|
spoon.SpeedMenu:start()
|
|
applyFullMenuFix()
|
|
hs.alert.show("SpeedMenu Started")
|
|
end
|
|
speedMenuRunning = not speedMenuRunning
|
|
end)
|
|
end
|
|
|
|
---- BrewInfo Implementation
|
|
if spoon.BrewInfo then
|
|
hs.hotkey.bind({"cmd", "alt", "ctrl"}, "I", function()
|
|
spoon.BrewInfo:showBrewInfo()
|
|
end)
|
|
hs.hotkey.bind({"cmd", "alt", "ctrl"}, "J", function()
|
|
spoon.BrewInfo:showBrewInfoCurSel()
|
|
end)
|
|
end |