-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtwiddler-dotkey-org-inbox-and-clear
executable file
·56 lines (45 loc) · 1.68 KB
/
twiddler-dotkey-org-inbox-and-clear
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/bash
set -eu # Quit on any error
#
# 1. Use the accompanying reader script to read the Twiddler's TWIDDLER.KEY
# file which contains the keys typed when in Untethered Re-Chording Mode.
# 2. Send the ASCII contents to an Org Mode file as a header
# 3. Delete the TWIDDLER.KEY file off the Twiddler
#
# Author: Reed Spool
#
# Configuration
#
# Change to where you've installed the node script
READER_PATH="/home/human/projects/twiddler-headless.git/twiddler-read-dotkey";
# Change to your org-mode inbox
ORG_TARGET_PATH="./test.org";
ORG_TARGET_PATH="/home/human/org/inbox.org";
# Change to /media/user/twiddler
REMOTE_PATH=".";
REMOTE_PATH="/media/human/C494-6732";
# This is probably what you want, but to read from a backup, put path here
DOTKEY="TWIDDLER.KEY";
# Where to back up just-read TWIDDLER.KEY file before deleting off device
BACKUP_PATH="/home/human/projects/twiddler-headless.git/TWIDDLER-$(date "+%Y-%m-%d-%H-%M").KEY";
# BACKUP_PATH=/dev/null; # Don't backup
# Line to insert before contents of TWIDDLER.KEY in your org mode file
CAPTURE_HEADER="* Twiddler headless input [$(date "+%Y-%m-%d %a %R")]";
#
# Code
#
if [[ ! -e "$REMOTE_PATH/" ]]
then
echo "Twiddler file system not found. Is the Twiddler plugged in and on?";
exit 1; # Do not proceed
fi
if [[ ! -f "$REMOTE_PATH/$DOTKEY" ]]
then
echo "Twiddler has no $DOTKEY file. Disregarding.";
exit 0; # This is fine, we just didn't use it since last dump.
fi
echo "$CAPTURE_HEADER" >> "$ORG_TARGET_PATH";
$READER_PATH "$REMOTE_PATH/$DOTKEY" >> "$ORG_TARGET_PATH";
cp "$REMOTE_PATH/$DOTKEY" "$BACKUP_PATH";
rm "$REMOTE_PATH/$DOTKEY";
echo "Appended entry to $ORG_TARGET_PATH and deleted $DOTKEY. Happy organizing!";