MIC-02-5 Small progress during a busy end of week

I set the stage for command groups in bike.py with [my latest change to bike.py](added sel2pb command to bike.py · rdhyee/python-learning@a161fe9).

It seems that Keyboard Maestro doesn't allow for watching for changes in files that already exist. Maybe, more likely, I've just not been able to figure out how. I have some progress using hammerspoon though. Here's a relevant part of my init.lua:


function list_true_flags(flags)
  local true_flags = " "
  for key, value in pairs(flags) do
    if value then
      true_flags = true_flags .. key .. " | "
    end
  end
  return true_flags
end

function fileModifiedCallback(paths, flagTables)
  for i, file in ipairs(paths) do
    if file == "/Volumes/ryvault1/MacHD/Users/raymondyee/obsidian/MainRY/bike/overall.bike" then
      local flags = flagTables[i]
      print(i, file)
      print_true_flags(flags)

      local timestamp = os.date("%Y-%m-%d %H:%M:%S")
      -- local message = timestamp .. " overall.bike changed\n"

      local logFile = io.open("/tmp/hschange.log", "a")
      logFile:write(timestamp .. list_true_flags(flags) .. "\n")
      logFile:close()
    end
  end
end

watcher = hs.pathwatcher.new("/Volumes/ryvault1/MacHD/Users/raymondyee/obsidian/MainRY/bike", fileModifiedCallback)
watcher:start()

Leave a Reply

Only people in my network can comment.

This site uses Akismet to reduce spam. Learn how your comment data is processed.