# Desktop app and sync

The Dunjii app for Mac and Windows keeps a folder on your computer in sync with your workspace, so you can edit your files in Obsidian or any other editor.

## Installing the app

Download the app from the [download page](https://dunjii.com/download), which offers **Download for macOS** and **Download for Windows**. There is no Linux version.

- **Mac:** open the `.dmg` file and drag Dunjii into Applications. Dunjii runs in the menu bar, not the Dock.
- **Windows:** run the setup file and click **Install**. Dunjii installs for your account only and starts when you sign in to Windows. Its icon is in the notification area by the clock; click the ^ arrow if you don't see it. If Windows says it protected your PC, click **More info**, then **Run anyway**.

The app also installs the `dunjii` command for the terminal. On a Mac, choose **Install CLI Tool...** from the menu if it is there. **Start on Login** turns starting the app with your computer on or off.

## Signing in and setting up a folder

1. Click the Dunjii icon and choose **Log In...** to sign in with your browser.
2. The menu now lists your workspace. Choose **Set Up...** under its name.

Dunjii creates a folder for your workspace inside a folder named `Dunjii` in your home folder, downloads your files into it, and keeps it in sync from then on. The computer appears in **Settings › Desktop app** under **Signed in**; click **Sign out** there to stop it syncing.

To keep the workspace in a different folder, run `dunjii sync` in that folder instead of choosing **Set Up...**, then quit the app and open it again. The app syncs every folder you have run `dunjii sync` in. [Local agents](https://dunjii.com/docs/agents/local-agents.md) shows the commands.

To stop syncing a folder, choose **Remove** under its name in the menu. The files stay on your computer.

## How changes move

While the app runs, it watches the folder and uploads a file about a second after you save it. Changes made in Dunjii, on the web or on another computer, reach the folder within a few seconds, because Dunjii tells the app when something changes. If that connection drops, the app checks for changes every 60 seconds.

On a Mac, opening the menu syncs right away. On Windows, choose **Sync Now**. **Stop Sync** pauses every folder until you choose **Start Sync**. The line under each folder's name says when it last synced, such as **Synced 12s ago**.

| File                                        | Syncs |
| ------------------------------------------- | ----- |
| Markdown (`.md`, `.markdown`)               | Yes   |
| PNG, JPEG, GIF, WebP and SVG images         | Yes   |
| PDF                                         | On the Pro plan |
| Names starting with a dot, such as `.obsidian` | No |
| Any other file                              | No: it stays on your computer |

To keep more files out of sync, list them in `.dunjii/ignore` in the synced folder. It takes the same patterns as a `.gitignore` file.

```text
Scratch/
*.draft.md
```

- `Scratch/`: A folder that stays on this computer.
- `*.draft.md`: Any file ending in .draft.md, in any folder.

## Conflicts

Dunjii merges edits made in two places at once. When you change one section of a document on your computer and someone changes another section on the web, both changes are kept. Frontmatter merges key by key.

When both sides changed the same part, the edit that reaches Dunjii last wins. Dunjii saves the other copy in the document's [history](https://dunjii.com/docs/your-files/version-history.md), marked **displaced**, so nothing is lost. Pictures follow the same rule: the later picture wins and the earlier one stays in the history.

Documents with a displaced copy are listed on the History page's **Needs review** tab, and the sidebar row reads **History · 1 to review**. Open a document from the list to see the displaced copy and a line saying what replaced it, such as "Replaced by a sync from" and the computer's name. Then:

- **Restore** makes the displaced copy the current version.
- **Show what replaced it** steps to the version that won.
- **Okay, noted** takes the document off the list and changes nothing.

## Deleted files on your computer

When a file is deleted in Dunjii, the app moves your copy into `.dunjii/trash` in the synced folder instead of deleting it. Each sync removes anything there older than 14 days. When one sync moves 10 or more files at once, the menu shows a warning such as **⚠ Sync moved 12 files to trash**, with **Restore them** to put them back and **Dismiss** to leave them in the trash.

When you delete a file on your computer, Dunjii deletes it too, and you can restore it from **Recently deleted**. See [Deleted files](https://dunjii.com/docs/your-files/trash.md).

## Obsidian, other editors and the terminal

The synced folder holds ordinary markdown files and images, so any editor can open it. To use Obsidian, open the folder as a vault. Obsidian keeps its own settings in `.obsidian`, which doesn't sync, and wikilinks such as `[[Ferryman Odo]]` work in both.

| Command                         | What it does |
| ------------------------------- | ------------ |
| `dunjii sync`                   | Syncs the folder once. |
| `dunjii sync --watch`           | Keeps syncing until you press Ctrl+C, as the app does. |
| `dunjii sync status`            | Lists the folders the app syncs and how each one is doing. |
| `dunjii history <file>`         | Lists a file's versions. |
| `dunjii restore <file> --to 3`  | Writes version 3 back into the file. `--to` also takes a time, such as `1d` or `yesterday`. |
| `dunjii trash list`             | Lists the batches of files sync moved into `.dunjii/trash`, newest first. |
| `dunjii trash restore latest`   | Puts the newest batch back where it was. |

[Local agents](https://dunjii.com/docs/agents/local-agents.md) covers `dunjii login` and setting up a folder from the terminal.
