-
Notifications
You must be signed in to change notification settings - Fork 1
/
install.zsh
executable file
·61 lines (46 loc) · 1.58 KB
/
install.zsh
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
57
58
59
60
61
#!/bin/zsh
function realpath { echo $(cd $(dirname $1); pwd)/$(basename $1); }
BASEDIR=`realpath $(dirname $0)`
TEMPLATEDIR="$BASEDIR/templates"
if ! [ -x "$(command -v node)" ]; then
echo 'Error: node is not installed.' >&2
exit 1
fi
if ! [ -x "$(command -v brew)" ]; then
echo 'Error: brew is not installed.' >&2
exit 1
fi
PATH_TO_NODE="$(which node)";
PATH_TO_SCREENSHOTS="$(defaults read com.apple.screencapture location | sed 's#~#'${HOME}'#g')";
if ! [ -d "${PATH_TO_SCREENSHOTS}" ]; then
PATH_TO_SCREENSHOTS="${HOME}/Desktop"
fi
echo "📁 Watching ${PATH_TO_SCREENSHOTS} for recordings"
if ! [ -d /tmp/screenToGif ]; then
mkdir /tmp/screenToGif
fi
PLISTFILE="screenToGif.plist"
JSFILE="screenToGif.js"
rm -rf $BASEDIR/$PLISTFILE;
cp $TEMPLATEDIR/$PLISTFILE $BASEDIR/$PLISTFILE;
sed -i '' 's~{NODE}~'"${PATH_TO_NODE}"'~g' "$BASEDIR/$PLISTFILE";
sed -i '' 's~{PATH_TO_SCRIPT}~'"${BASEDIR}"'~g' "$BASEDIR/$PLISTFILE";
sed -i '' 's#{PATH_TO_SCREENSHOTS}#'"${PATH_TO_SCREENSHOTS}"'#g' "$BASEDIR/$PLISTFILE";
rm -rf $BASEDIR/$JSFILE;
cp $TEMPLATEDIR/$JSFILE $BASEDIR/$JSFILE;
sed -i '' 's#{PATH_TO_SCREENSHOTS}#'"${PATH_TO_SCREENSHOTS}"'#g' "$BASEDIR/$JSFILE";
if ! [ -x "$(command -v ffmpeg)" ]; then
brew install ffmpeg;
fi
if ! [ -x "$(command -v gifski)" ]; then
brew install gifski;
fi
LA_FILE="$HOME/Library/LaunchAgents/$PLISTFILE"
if [ -f "$LA_FILE" ]; then
launchctl unload "$LA_FILE";
fi
mv $BASEDIR/$PLISTFILE "$LA_FILE";
launchctl load "$LA_FILE"
echo "Installed 🥳"
echo "To see logs: tail -f /tmp/screenToGif.out"
echo "To see errors: tail -f /tmp/screenToGif.err"