Note: This site is currently "Under construction". I'm migrating to a new version of my site building software. Lots of things are in a state of disrepair as a result (for example, footnote links aren't working). It's all part of the process of building in public. Most things should still be readable though.

Move bears.json Into Place

This doesn't work well. It doesn't picks up all the changes and sometimes takes several seconds to make the move. So, I'm not using it.

Looking at setting up a script with `watchexec``

This launchd script watches my Downloads folder. When a file named "ascii-shop.json" shows up it gets copied to my "asciibear" projected and with the name "bears.json"

Code

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC 
"-//Apple//DTD PLIST 1.0//EN" 
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>Label</key>
  <string>com.alanwsmith.move_ascii_bears.plist</string>
  <key>EnvironmentVariables</key>
  <dict>
    <key>INPUT_FILE</key>
    <string>/Users/alan/Downloads/ascii-shop.json</string>
    <key>OUTPUT_FILE</key>
    <string>/Users/alan/workshop/asciibear/bears.json</string>
  </dict>
  <key>ProgramArguments</key>
  <array>
    <string>/bin/bash</string>
    <string>-c</string>
    <string>
if [ -f "$INPUT_FILE" ]; then
  if [ -f "$OUTPUT_FILE" ]; then
    rm "$OUTPUT_FILE"
  fi
  mv "$INPUT_FILE" "$OUTPUT_FILE"
  # osascript -e 'display notification "bears.json moved" with title "ASCIISHOP" subtitle "Notice" sound name "Pop"'
fi
date 
    </string>
  </array>
  <key>WatchPaths</key>
  <array>
    <string>/Users/alan/Downloads</string>
  </array>
  <key>StandardErrorPath</key>
    <string>/tmp/launchd_move_bears_json.log</string>
  <key>StandardOutPath</key>
    <string>/tmp/launchd_move_bears_json.log</string>
</dict>
</plist>