Apply shellcheck and shfmt
This commit is contained in:
parent
d1fa399c86
commit
154d15b890
7
.editorconfig
Normal file
7
.editorconfig
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
[*.sh]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 4
|
||||||
|
|
||||||
|
shell_variant = posix
|
||||||
|
binary_next_line = true
|
||||||
|
switch_case_indent = true
|
42
reStream.sh
42
reStream.sh
@ -7,11 +7,11 @@ landscape=true # rotate 90 degrees to the right
|
|||||||
# loop through arguments and process them
|
# loop through arguments and process them
|
||||||
while [ $# -gt 0 ]; do
|
while [ $# -gt 0 ]; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
-p|--portrait)
|
-p | --portrait)
|
||||||
landscape=false
|
landscape=false
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
-d|--destination)
|
-d | --destination)
|
||||||
ssh_host="$2"
|
ssh_host="$2"
|
||||||
shift
|
shift
|
||||||
shift
|
shift
|
||||||
@ -19,6 +19,7 @@ while [ $# -gt 0 ]; do
|
|||||||
*)
|
*)
|
||||||
echo "Usage: $0 [-p] [-d <destination>]"
|
echo "Usage: $0 [-p] [-d <destination>]"
|
||||||
exit 1
|
exit 1
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
@ -28,10 +29,13 @@ height=1872
|
|||||||
bytes_per_pixel=2
|
bytes_per_pixel=2
|
||||||
loop_wait="true"
|
loop_wait="true"
|
||||||
loglevel="info"
|
loglevel="info"
|
||||||
ssh_cmd="ssh -o ConnectTimeout=1 "$ssh_host""
|
|
||||||
|
ssh_cmd() {
|
||||||
|
ssh -o ConnectTimeout=1 "$ssh_host" "$@"
|
||||||
|
}
|
||||||
|
|
||||||
# check if we are able to reach the remarkable
|
# check if we are able to reach the remarkable
|
||||||
if ! $ssh_cmd true; then
|
if ! ssh_cmd true; then
|
||||||
echo "$ssh_host unreachable"
|
echo "$ssh_host unreachable"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
@ -44,12 +48,11 @@ fallback_to_gzip() {
|
|||||||
sleep 2
|
sleep 2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# check if lz4 is present on remarkable
|
# check if lz4 is present on remarkable
|
||||||
if $ssh_cmd "[ -f /opt/bin/lz4 ]"; then
|
if ssh_cmd "[ -f /opt/bin/lz4 ]"; then
|
||||||
compress="/opt/bin/lz4"
|
compress="/opt/bin/lz4"
|
||||||
elif $ssh_cmd "[ -f ~/lz4 ]"; then
|
elif ssh_cmd "[ -f ~/lz4 ]"; then
|
||||||
compress="~/lz4"
|
compress="\$HOME/lz4"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# gracefully degrade to gzip if is not present on remarkable or host
|
# gracefully degrade to gzip if is not present on remarkable or host
|
||||||
@ -63,11 +66,8 @@ else
|
|||||||
decompress="lz4 -d"
|
decompress="lz4 -d"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# calculte how much bytes the window is
|
# calculte how much bytes the window is
|
||||||
window_bytes="$(($width*$height*$bytes_per_pixel))"
|
window_bytes="$((width * height * bytes_per_pixel))"
|
||||||
|
|
||||||
# rotate 90 degrees if landscape=true
|
# rotate 90 degrees if landscape=true
|
||||||
landscape_param="$($landscape && echo '-vf transpose=1')"
|
landscape_param="$($landscape && echo '-vf transpose=1')"
|
||||||
@ -80,12 +80,14 @@ read_loop="while $head_fb0; do $loop_wait; done | $compress"
|
|||||||
|
|
||||||
set -e # stop if an error occurs
|
set -e # stop if an error occurs
|
||||||
|
|
||||||
$ssh_cmd "$read_loop" \
|
# shellcheck disable=SC2086
|
||||||
|
ssh_cmd "$read_loop" \
|
||||||
| $decompress \
|
| $decompress \
|
||||||
| ffplay -vcodec rawvideo \
|
| ffplay \
|
||||||
-loglevel "$loglevel" \
|
-vcodec rawvideo \
|
||||||
-f rawvideo \
|
-loglevel "$loglevel" \
|
||||||
-pixel_format gray16le \
|
-f rawvideo \
|
||||||
-video_size "$width,$height" \
|
-pixel_format gray16le \
|
||||||
$landscape_param \
|
-video_size "$width,$height" \
|
||||||
-i -
|
$landscape_param \
|
||||||
|
-i -
|
||||||
|
Loading…
x
Reference in New Issue
Block a user