Comments (3)
Yeah, it's looking for a running instance of the Dock, so it will fail if Hammerspoon somehow manages to start before the Dock. But all it's actually doing with it at that point is trying to find the Dock app on disk, so I think it could probably be changed to:
local path = application.pathForBundleID("com.apple.dock") .. "/Contents/Resources"
(It does try to actually talk to the running Dock later on, to interact with Mission Control/Spaces - but the Dock is likely to be running by the time you're using any of those functions.)
If you want to try out that change, you can copy spaces.lua
from Hammerspoon into ~/.hammerspoon/hs/spaces.lua
and edit the line above into that copy. Or if you want to dynamically patch it, so that you still get any other updates to spaces.lua
in new Hammerspoon versions, you can create ~/.hammerspoon/hs/spaces.lua
with this code in it:
~/.hammerspoon/hs/spaces.lua
(patching version)
local myName, myPath = ...
local pathToAbsolute = require 'hs.fs'.pathToAbsolute
local myAbsPath = pathToAbsolute(myPath)
for entry in package.path:gmatch '[^;]*' do
local realPath = package.searchpath(myName, entry)
if not realPath or pathToAbsolute(realPath) == myAbsPath then goto continue end
local fn = load(coroutine.wrap(function()
local yield = coroutine.yield
local findStr = [[application.applicationsForBundleID("com.apple.dock")[1]:path()]]
local replaceStr = [[application.pathForBundleID("com.apple.dock")]]
local findPattern = findStr:gsub('%W', '%%%0')
local replacePattern = replaceStr:gsub('%%', '%%%%')
local didPatch = false
for line in io.lines(realPath, 'L') do
local fixedLine, nMatches = line:gsub(findPattern, replacePattern)
yield(fixedLine)
if nMatches > 0 then
didPatch = true
end
end
if not didPatch then
print "Warning: couldn't patch spaces.lua!"
end
end), '@'..realPath, 't')
do return fn(myName, realPath) end
::continue::
end
from hammerspoon.
I've never run into a timing issue this tight, but pathForBundleID
should work. At load time, it's looking for the specific verbiage that pages will be using in the Mission Control accessibility objects, so it's the location on disk that matters, not the running Dock itself.
As noted, the running Dock is important when you trigger it, but not at load time.
from hammerspoon.
Would I run into issues if I just edited the app itself for testing?
from hammerspoon.
Related Issues (20)
- Moving Apps To Spaces HOT 2
- Memory is growing up to 2-4GB after some time - how to debug? HOT 1
- ** Warning: LuaSkin: hs.audiodevice.watcher callback fired, but theWatcher is nil. This is a bug
- ERROR: hotkey.lua:415: key must be a string or a number HOT 6
- Create Helper apps with Hammerspoon and sell it? HOT 2
- attempt to call a nil value (method 'setCallback')
- A way to prevent hs.alert.show() from stealing focus? HOT 1
- Unexpected behavior when moving a window with `moveToUnit` HOT 2
- hs.window:raise() focuses raised window when other window for same application is focused HOT 1
- hs.window.filter stops emitting windowFocused events for application if one window has tabs HOT 1
- Add functions to hs.mouse to get more information about cursor type HOT 1
- hs.notify.show doesn't work HOT 2
- Support for Elgato Stream Deck Neo HOT 1
- hs.serial:sendData(value) chokes after some indeterminate amount of time? HOT 2
- hs.socket and hs.socket.udp listens on all interfaces
- hs.spaces.moveWindowToSpace not working HOT 10
- `hs.alert.defaultStyle`: option to add top or bottom margin
- hs.urlevent: Fix multiple query params and pass in fullURL to hs.urlevent's bind callback
- cannot remap SHIFT + ยง
- backspace key code?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hammerspoon.