Files
hammerspoon/init.lua
T

111 lines
3.9 KiB
Lua

-- Allow external apps like Raycast to execute custom Hammerspoon Lua functions
hs.allowAppleScript(true)
-- ========================================================================
-- HEADLESS WORKSPACE BACKGROUND ENGINE (FORCED AT BOOT)
-- ========================================================================
hs.menuIcon(false)
hs.dockIcon(false)
hs.ipc.cliInstall("/opt/homebrew")
hs.alert.show("Hammerspoon Headless Daemon Active", 2)
-- ~/.hammerspoon/init.lua
-- Load Config First
-- config = require("Config")
--
-- Load your HyperKey
require("HyperKey")
require('SearchWindows')
require('Caffeine')
require('AppBorders')
-- CRITICAL FOR RAYCAST INTERACTION: Bind the return value to a global variable
LayoutSelector = require('LayoutSelector')
-- require('System_Tweaks') -- Used for Time Machine Throttle Disable
-- require("Focus") -- Does not work with layout saver - Not needed if using Monocle - Focusdim is better than Monocle
-- require("FocusMode") -- Removed since I am using Focusdim
--
-- Network Center is currently disabled since menus are not working in Hammerspoon - Will re-enable once I can fix the menu issues
-- Network = require("NetworkCenter")
--
require("modules.mouseJiggle").start()
-- Load the window management module
local windowMgr = require("WindowManager")
local productivity = require("productivity")
-- For Affine
local quickNote = require("affine_quick_note")
quickNote.init()
require("affine_clipper"):init()
-- Load Spoon Files
hs.loadSpoon('SpoonInstall')
hs.loadSpoon('SpeedMenu')
hs.loadSpoon('BrewInfo')
-- ==========================================
-- SPOON CONFIGURATION
-- ==========================================
---- SpeedMenu Config
if spoon.SpeedMenu then
-- Define the Fix Function (includes MAC and IPv6)
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 shell
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
-- Hook the rescan method
local oldRescan = spoon.SpeedMenu.rescan
spoon.SpeedMenu.rescan = function(self)
oldRescan(self)
applyFullMenuFix()
end
-- Toggle Logic (Starts as OFF)
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() -- This puts it in the menu bar
applyFullMenuFix() -- This populates the data
hs.alert.show("SpeedMenu Started")
end
speedMenuRunning = not speedMenuRunning
end)
end
---- SpeedMenu Config END
---- BrewInfo
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
---- BrewInfo END
hs.alert.show("Hammerspoon Config Reloaded")