# ksnip setup: upload with its script

How to set up ksnip with hematite on Linux, Windows or macOS: download the script, choose it as ksnip's upload script, and copy each capture's link.

[ksnip](https://github.com/ksnip/ksnip) is a free screenshot tool for Linux, Windows and macOS. Its **Script** uploader runs a script with each capture, which is where [hematite's upload script](https://hematite.gg/docs/uploaders/upload-script) comes in: it uploads the capture and prints the link for ksnip to copy.

## Set it up

1. **Download the script.** In hematite, open [Settings → Uploaders](https://hematite.gg/settings/uploaders), press **Download script** beside ksnip, and choose your system: `hematite-upload.sh` for Linux and macOS, `hematite-upload.cmd` for Windows.
2. **Put it in place,** where only you can read it. On Linux and macOS, ksnip runs it directly, so it has to be executable too:

   ```sh
   mkdir -p ~/.local/bin
   mv ~/Downloads/hematite-upload.sh ~/.local/bin/
   chmod 700 ~/.local/bin/hematite-upload.sh
   ```

   On Windows, move `hematite-upload.cmd` to a folder of your own, such as `C:\Users\nova\AppData\Local\hematite`.

3. **Choose it in ksnip.** Open **Settings → Uploader** and set **Uploader Type** to **Script**. Then, under **Script Uploader**, press **Browse** beside **Script** and choose the file.
4. **Copy what it prints.** Still under **Script Uploader**, tick **Copy script output to clipboard** and set **Filter** to `https://\S+`, so only the link is copied. Leave **Stop when upload script writes to StdErr** on: that's how ksnip knows an upload failed.
5. **Upload a capture.** After a capture, press **Upload**, or tick **Upload image** in an action of yours to upload every capture it takes.

> **Warning: The script holds a token: keep it to yourself**
>
> Each download carries a new upload token, which is shown nowhere else. If the
> script gets out, remove the token and download a new one.

## When it fails

ksnip says **Upload Failed: Script wrote to StdErr.** and keeps the reason to itself. To read it, run the script by hand on a capture:

```sh
~/.local/bin/hematite-upload.sh ~/Pictures/capture.png
```

[The upload script's guide](https://hematite.gg/docs/uploaders/upload-script#when-it-fails) lists what it says and what to do. On Windows, run `hematite-upload.cmd capture.png` in a terminal the same way.

## Your upload tokens

The script's token lasts 90 days and counts toward your ten. It's listed as **ksnip** on [Settings → Uploaders](https://hematite.gg/settings/uploaders) and in [Settings → Security](https://hematite.gg/settings/security). Remove it in either place and the script stops uploading; your other uploaders carry on.
