Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function writeStringToFileWithMode(aString, aPath, aMode)
- local this_file
- this_file = io.open(aPath, aMode)
- this_file:write(aString)
- this_file:close()
- end
- function myFolderWatch(files)
- local str = "Launch Agents folder was modified on " .. os.date() .. " :\n\t"
- local this_path = os.getenv("HOME") .. "/Desktop/LaunchFolderModified.txt"
- local ignore = "DS_Store"
- local count = 0
- for _,file in pairs (files) do
- count = count + 1
- i = string.find(file, ignore)
- if not i then
- str = str .. file .. "\n\t"
- else
- if count == 1 then
- str = "\n"
- end
- end
- end
- str = str .. "\n"
- writeStringToFileWithMode(str, this_path, "a")
- if string.len(str) > 2 then
- hs.alert.show("Launch Agents folder was modified.")
- end
- end
- local aWatcher = hs.pathwatcher.new(os.getenv("HOME") .. "/Library/LaunchAgents/", myFolderWatch):start()
Add Comment
Please, Sign In to add comment