Replies: 2 comments
-
|
I don't think there's any way to add that info to the Using the -- somewhere global:
myWindowWatchers = {}
-- wherever you're creating each watcher:
myWindow = hs.window.focusedWindow()
myWindowID = myWindow:id()
myWindowWatchers[myWindowID] = myWindow:newWatcher(
function(element, event, watcher)
print("myWatcher for myWindow called with event " .. event)
-- clean up watchers for windows that no longer exist:
if event == hs.uielement.watcher.elementDestroyed then
myWindowWatchers[myWindowID] = nil
end
end
)
myWindow.myWatcher:start({hs.uielement.watcher.windowMoved, hs.uielement.watcher.elementDestroyed})
-- make sure that elementDestroyed gets added to this call: ↑Footnotes
|
Beta Was this translation helpful? Give feedback.
-
|
Thanks for the response. I ended up using window IDs as keys for some locally managed tables here: https://github.com/mogenson/PaperWM.spoon/blob/e64e0d864d2db4cb6f65a92929bbcdf4a1b07fa4/init.lua#L121 |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello, I'd like to append some metadata to an instance of an
hs.windowso I can retrieve and inspect it later. For example, use thehs.window:newWatcher()method to create auielement.watcherand store it with the window.Are there any strategies in Lua to storing Lua variables/tables alongside a
userdatatype likehs.window? Wolddebug. setuservalue()be an option? I can't find any good examples of it's use.Beta Was this translation helpful? Give feedback.
All reactions