summaryrefslogtreecommitdiff
path: root/bin/embroider-remote
blob: 2b943fe5332d7a5c5f3e4abd80cae36e40b294da (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/bin/bash

# This tool converts a .CSV file to a .PES file and uploads it to my embroidery
# machine, which is connected to my home server.  This way, I can embroider from my
# laptop over my wifi without having to connect the sewing machine to my laptop every
# time.

# /etc/fstab entry: /dev/disk/by-id/usb-B-EMB_USB_RAM_Disk_INST_0-0:0-part1 /mnt/embroidery vfat user,uid=1000,gid=1000,nobootwait,noauto 0 0

HOST=myhomeserver.local

set -e

if [[ "$1" == *.csv ]]; then
    pes=$(mktemp /tmp/XXXXXXXXXXX.pes)
    libembroidery-convert "$1" "$pes"
    file="$pes"
else
    file="$1"
fi

cat "$file" | ssh $HOST "
    mount /mnt/embroidery &&
    rm -f /mnt/embroidery/* &&
    cat > /mnt/embroidery/embroidery.pes &&
    umount /mnt/embroidery" \
        || echo 'failed to upload embroidery :('