Created
April 7, 2016 10:31
-
-
Save dropmeaword/ddf7b5b3a0e81ef1142f446f3f91075a to your computer and use it in GitHub Desktop.
My Hammerspoon configuration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Bring all Finder windows to front | |
function applicationWatcher(appName, eventType, appObject) | |
if (eventType == hs.application.watcher.activated) then | |
if (appName == "Finder") then | |
-- Bring all Finder windows forward when one gets activated | |
appObject:selectMenuItem({"Window", "Bring All to Front"}) | |
end | |
end | |
end | |
local appWatcher = hs.application.watcher.new(applicationWatcher) | |
appWatcher:start() | |
function sleepWatch(eventType) | |
if (eventType == hs.caffeinate.watcher.systemWillSleep) then | |
hs.alert.show("Going to sleep!") | |
elseif (eventType == hs.caffeinate.watcher.systemDidWake) then | |
hs.alert.show("Waking up!") | |
end | |
end | |
local sleepWatcher = hs.caffeinate.watcher.new(sleepWatch) | |
sleepWatcher:start() | |
-- Circle mouse pointer on CMD+ALT+SHIFT+D | |
local mouseCircle = nil | |
local mouseCircleTimer = nil | |
function mouseHighlight() | |
-- Delete an existing highlight if it exists | |
if mouseCircle then | |
mouseCircle:delete() | |
if mouseCircleTimer then | |
mouseCircleTimer:stop() | |
end | |
end | |
-- Get the current co-ordinates of the mouse pointer | |
mousepoint = hs.mouse.getAbsolutePosition() | |
-- Prepare a big red circle around the mouse pointer | |
mouseCircle = hs.drawing.circle(hs.geometry.rect(mousepoint.x-40, mousepoint.y-40, 80, 80)) | |
mouseCircle:setStrokeColor({["red"]=1,["blue"]=0,["green"]=0,["alpha"]=1}) | |
mouseCircle:setFill(false) | |
mouseCircle:setStrokeWidth(5) | |
mouseCircle:show() | |
-- Set a timer to delete the circle after 3 seconds | |
mouseCircleTimer = hs.timer.doAfter(3, function() mouseCircle:delete() end) | |
end | |
hs.hotkey.bind({"cmd","alt","shift"}, "D", mouseHighlight) | |
-- Watch insertion of particular USB device | |
-- local usbWatcher = nil | |
-- function usbDeviceCallback(data) | |
-- if (data["productName"] == "ScanSnap S1300i") then | |
-- if (data["eventType"] == "added") then | |
-- hs.application.launchOrFocus("ScanSnap Manager") | |
-- elseif (data["eventType"] == "removed") then | |
-- app = hs.appfinder.appFromName("ScanSnap Manager") | |
-- app:kill() | |
-- end | |
-- end | |
-- end | |
-- usbWatcher = hs.usb.watcher.new(usbDeviceCallback) | |
-- usbWatcher:start() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment