# Photon Uploader (Apple Silicon)

![Photon Logo](/logo.png)

A lightweight macOS menu bar app that watches a folder for new image files and automatically uploads them to your Photon SSH Container via SCP. After a successful upload, the URL is copied to your clipboard and a system notification is sent.

## Requirements
- [Homebrew](https://brew.sh)
- `fswatch` — `brew install fswatch`
- `openssl` — `brew install openssl`

## Configuration

Copy `photon.conf` to `~/Documents/Photon/photon.conf` and fill in your values:

```bash
# Directories
DIR_TO_MONITOR="/Users/Jordan/Documents/Photon/tmp"   # Folder to watch for new files
DIR_TO_MOVE="/Users/Jordan/Documents/Photon/upload"   # Staging area during upload
DIR_ARCHIVE="/Users/Jordan/Documents/Photon/archive"  # Where files go after upload (if archiving)

# Server
SERVER="photon.example.com"
USER="photon"
PORT="2222"
REMOTE_DIR="/path/on/server/"
PHOTON_DOMAIN="photon.example.com"
BASE_URL="https://photon.example.com/share"

# SSH key
SSH_KEY_PATH="$HOME/.ssh/id_rsa"

# File handling
SUPPORTED_EXTENSIONS="jpg,jpeg,png,gif,webp,bmp,tiff"
CLEANUP_AFTER_UPLOAD=true
ENABLE_NOTIFICATIONS=true

# Performance
MAX_CONCURRENT_UPLOADS=3
UPLOAD_TIMEOUT=30
```

## Building

```bash
./build.sh
```

This compiles both Swift binaries, assembles the app bundle, and installs the result to `~/Applications/Photon Uploader.app`.

### Regenerating the app icon

```bash
./create_icon.sh
```

Requires `magick` (`brew install imagemagick`). Generates `Resources/AppIcon.icns` from the source artwork and then runs `build.sh`.

## Usage

Launch **Photon Uploader** from `~/Applications`. It will start automatically monitoring `DIR_TO_MONITOR`. Drop any supported image file into that folder and it will be:

1. Renamed to a random filename
2. Uploaded to Photon via SCP
3. URL copied to your clipboard
4. Thumbnail generation triggered on the server
5. Archived or removed locally (depending on `CLEANUP_AFTER_UPLOAD`)

Use the menu bar icon to **Open Log** (`~/Documents/Photon/photon-upload.log`) or **Quit**.

## Project structure

```
photon-uploader/
├── build/
│   ├── Info.plist               App bundle metadata.
│   ├── PhotonUploader/
│   │   └── main.swift           Menu bar app source.
│   │
│   ├── PhotonNotify/
│   │   ├── main.swift           Notification helper source.
│   │   └── info.plist           Helper bundle metadata.
│   │
│   ├── Resources/
│   │   ├── AppIcon.icns         App icon.
│   │   ├── MenuBarIcon.png      Menu bar icon (1x).
│   │   └── MenuBarIcon@2x.png   Menu bar icon (2x).
│   └── upload.sh                Upload daemon script.
│   
├── build.sh                     Build and install script.
└── photon.conf                Example configuration

```
