From 382944058e12c148d1e9a588ce0489a380676a40 Mon Sep 17 00:00:00 2001 From: Rien Maertens Date: Thu, 2 Apr 2020 14:14:36 +0200 Subject: [PATCH] Add parameters to README, ssh timeout to 1s Changed the README to reflect the command line options added with bcf62e3. Also incorporates the SSH timeout of 1 second added by the initial PR (#10). Co-authored-by: Aaron David Schneider --- README.md | 7 ++++++- reStream.sh | 33 ++++++++++++++++++--------------- 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index ec1232f..d28ab54 100644 --- a/README.md +++ b/README.md @@ -14,9 +14,14 @@ reMarkable screen sharing over SSH. 1. Connect your reMarkable with the USB cable. 2. Make sure you can [open an SSH connection](https://remarkablewiki.com/tech/ssh). -3. Run `./reStream.sh` for landscape mode, or `./reStram.sh -p` for portrait mode. +3. Run `./reStream.sh` 4. A screen will pop-up on your local machine, with a live view of your reMarkable! +### Options + +- `-p --portrait`: shows the reMarkable screen in portrait mode (the default is landscape mode, 90 degrees rotated tot the right) +- `-d --destination`: the ssh destination of the reMarkable (default: `root@10.11.99.1`) + If you have problems, don't hesitate to [open an issue](https://github.com/rien/reStream/issues/new) or [send me an email](mailto:rien.maertens@posteo.be). ## Requirements diff --git a/reStream.sh b/reStream.sh index f1bcede..8031b6b 100755 --- a/reStream.sh +++ b/reStream.sh @@ -1,23 +1,25 @@ #!/bin/sh -# these are probably the only two parameters you need to change -ssh_host="root@10.11.99.1" # location of the remarkable -landscape=true # default vertical +# default values for arguments +ssh_host="root@10.11.99.1" # remarkable connected trough USB +landscape=true # rotate 90 degrees to the right -# Loop through arguments and process them +# loop through arguments and process them for arg in "$@" do case $arg in -p|--portrait) - landscape=false - shift - ;; + landscape=false + shift + ;; -d|--destination) - ssh_host="$2" - shift - shift - ;; + ssh_host="$2" + shift + shift + ;; *) + echo "Usage: $0 [-p] [-d ]" + exit 1 esac done @@ -27,9 +29,10 @@ height=1872 bytes_per_pixel=2 loop_wait="true" loglevel="info" +ssh_cmd="ssh -o ConnectTimeout=1 "$ssh_host"" # check if we are able to reach the remarkable -if ! ssh "$ssh_host" true; then +if ! $ssh_cmd true; then echo "$ssh_host unreachable" exit 1 fi @@ -44,9 +47,9 @@ fallback_to_gzip() { # check if lz4 is present on remarkable -if ssh "$ssh_host" "[ -f /opt/bin/lz4 ]"; then +if $ssh_cmd "[ -f /opt/bin/lz4 ]"; then compress="/opt/bin/lz4" -elif ssh "$ssh_host" "[ -f ~/lz4 ]"; then +elif $ssh_cmd "[ -f ~/lz4 ]"; then compress="~/lz4" fi @@ -78,7 +81,7 @@ read_loop="while $head_fb0; do $loop_wait; done | $compress" set -e # stop if an error occurs -ssh "$ssh_host" "$read_loop" \ +$ssh_cmd "$read_loop" \ | $decompress \ | ffplay -vcodec rawvideo \ -loglevel "$loglevel" \