Skip to content

Commit

Permalink
[various] fix PID grab and allow for custom payload dirs
Browse files Browse the repository at this point in the history
On NixOS, process names cant be reliably grabbed using pgrep or by
grepping ps. Instead we use the built-in BASH functionality for that,
despite what my previous comment may suggest about it's reliability.
Hopefully it doesn't break it.

The custom payload dirs thing was done to allow for potential packaging
of this application, in case it needs to be done.
  • Loading branch information
nikp123 committed Jul 13, 2023
1 parent 895baa7 commit 368fefd
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions startscreen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ function get_display_params {
TARGET_DISPLAY_MODE=$(echo $RESOLUTION/$DENSITY)
}

PAYLOAD_STORE_DIR=payload

TARGET_CONNECTION_TIMEOUT=1
TARGET_TMP_DIR=/data/local/tmp
TARGET_SCRIPT1=$TARGET_TMP_DIR/scrcpy-payload1.sh
Expand Down Expand Up @@ -156,16 +158,17 @@ fi
# use -S if you're edgy
scrcpy --display $display -w -S -K &

# Bash let me down so this is the alternative I have to work with
SCRCPY_PID=$(pgrep scrcpy)
# ???. Use the this one in case $! doesn't work??
#SCRCPY_PID=$(pgrep scrcpy)
SCRCPY_PID=$!

#
# Payload section starts here
#

# Execute the payload stream generator remotely (with precisely the parameters that it wants)
adb push payload/stage1.sh $TARGET_SCRIPT1
adb push payload/stage2.sh $TARGET_SCRIPT2
adb push $PAYLOAD_STORE_DIR/stage1.sh $TARGET_SCRIPT1
adb push $PAYLOAD_STORE_DIR/stage2.sh $TARGET_SCRIPT2
adb shell chmod +x $TARGET_SCRIPT1
adb shell chmod +x $TARGET_SCRIPT2

Expand Down

0 comments on commit 368fefd

Please sign in to comment.