Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --init.lua
- --using hammerspoon to automatically run toggledock
- -- LOAD VARIABLES
- monitorWatcher = nil
- initWatcher = nil
- --MY FUNCTIONS
- --function to reload init.lua when it changes
- function reloadConfig(files)
- doReload = false
- for _,file in pairs(files) do
- if file:sub(-4) == ".lua" then
- doReload = true
- end
- end
- if doReload then
- hs.reload()
- end
- end
- --hs.osascript.applescript([[display dialog "this is a test"]])
- --hs.osascript.applescriptFromFile(os.getenv("HOME") .. "/Documents/toggledock2.app/Contents/Resources/Scripts/main.scpt")
- --hs.alert.show("trying to call toggle dock.app")
- --hs.screen.watcher:stop()
- --monitorWatcher:stop()
- --hs.alert.show("screen.watcher stopped")
- --hs.timer.usleep(100000)
- --monitorWatcher:start()
- --hs.alert.show("screen.watcher started")
- -- hs.application.launchOrFocus("toggle dock.app")
- --need a function that calls an applescript
- function monitorChangedCallback()
- --hs.screen.watcher:stop()
- --monitorWatcher:stop()
- --hs.timer.usleep(100000)
- --monitorWatcher:start()
- --hs.alert.show("screen.watcher started")
- newCount = #hs.screen.allScreens()
- hs.alert.show(screenCount)
- hs.alert.show(newCount)
- if screenCount ~= newCount then
- screenCount = #newCount
- hs.alert.show("trying to call toggle dock.app")
- hs.application.launchOrFocus("toggledock.app")
- end
- end
- --function to send a message
- function message(note)
- hs.alert.show(note)
- end
- --TOP
- -- clear console
- hs.console.clearConsole()
- --starts the pathwatcher to see if the init.lua changes in ~/.hammerspoon/
- initWatcher = hs.pathwatcher.new(os.getenv("HOME") .. "/.hammerspoon/", reloadConfig):start()
- --hs.timer.doAfter(1, message)
- hs.alert.show("Config loaded")
- --objects will be garbage collcted if they aren't in explicit vars
- --Starts the screen watcher, making it so fn is called each time the screen arrangement changes
- monitorWatcher = hs.screen.watcher.new(monitorChangedCallback):start()
- screenCount = #hs.screen.allScreens()
Advertisement
Add Comment
Please, Sign In to add comment