-
Notifications
You must be signed in to change notification settings - Fork 46
/
Copy pathshow.sh
executable file
·56 lines (43 loc) · 937 Bytes
/
show.sh
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
# Using openssl and curl send the image file to the display server.
# This is a bit roundabout but this way we don't need to put the file in a place
# from where the server could serve it as static.
set -e
shopt -s nocasematch
TITLE=''
WIN='null'
function usage() {
cat >&2 <<EOF
Usage: [-t title] [-w id] imagefile
EOF
}
if [ "$#" -eq 0 ]; then
usage
exit 2
fi
while getopts "t:w:h" opt; do
case $opt in
t) TITLE=$OPTARG;;
w) WIN="\"win\": \"$OPTARG\",";;
h) usage; exit 2;;
esac
done
IMGFILE=${@:$OPTIND:1}
EXT=${IMGFILE##*.}
case $EXT in
jpg) EXT="jpeg"
;;
png|gif|bmp|webp|pdf)
;;
*)
echo >&2 "Warning: unrecognized image format: $EXT"
;;
esac
function compose() {
cat <<EOF
{ "command": "image", "title":"$TITLE", "src":"data:image/${EXT};base64,
EOF
openssl enc -base64 -in $IMGFILE
echo '"}'
}
compose | curl -X POST -d @- http://localhost:8000/events