From 6cb18816e2aa2e565b53cbcf7ec03d5eceba0a98 Mon Sep 17 00:00:00 2001 From: mattlalumiere <66732655+mattlalumiere@users.noreply.github.com> Date: Fri, 18 Nov 2022 11:31:41 -0500 Subject: [PATCH] Fixed Xclient scripts and added some examples (#717) --- __main__.py | 1 + scripts/launch_klipperscreen.sh.EXAMPLE | 53 +++++++++++++++++++++++++ scripts/xsdl_wrapper.sh | 7 +++- 3 files changed, 60 insertions(+), 1 deletion(-) create mode 120000 __main__.py create mode 100755 scripts/launch_klipperscreen.sh.EXAMPLE diff --git a/__main__.py b/__main__.py new file mode 120000 index 00000000..0d00b8dd --- /dev/null +++ b/__main__.py @@ -0,0 +1 @@ +screen.py \ No newline at end of file diff --git a/scripts/launch_klipperscreen.sh.EXAMPLE b/scripts/launch_klipperscreen.sh.EXAMPLE new file mode 100755 index 00000000..bde85587 --- /dev/null +++ b/scripts/launch_klipperscreen.sh.EXAMPLE @@ -0,0 +1,53 @@ +#!/bin/bash +# Change XCLIENT and/or display to your destination xserver (XSDL platform). +# Example: export DISPLAY=192.168.1.101:0 + +# Note: You will likely want to reserve a DHCP address or set a static IP of the +# Xserver clientso that your IP does not change and require reconfiguration. + +export XCLIENT=change_me +export DISPLAY=change_me + +if [ $XCLIENT == "change_me" ]; then + echo "launch_klipperscreen.sh for XSDL/XServer Clients has not been cofigured properly. Please edit this file to point to your XServer Client" + exit +fi + + +# Send script to daemon process so that it does not fail when tty closes. +# + +export PYKLIPPERSCREEN=~/.KlipperScreen-env/bin/python +export PYKLIPPERSCREENPARAM=~/KlipperScreen/screen.py + + +if [ -f $PYKLIPPERSCREEN ]; then + echo "Testing $PYKLIPPERSCREEN" + test -x $PYKLIPPERSCREEN || echo "$PYKLIPPERSCREEN is Not Executable" +fi + +if [ -f $PYKLIPPERSCREENPARAM ]; then + echo "Testing $PYKLIPPERSCREENPARAM" + test -f $PYKLIPPERSCREENPARAM || echo "$PYKLIPPERSCREENPARAM is not a file" +fi + + +case "$1" in + start) + echo -n "Starting Klipper Screen Xclient Deamon .... " + setsid "$PYKLIPPERSCREEN" "$PYKLIPPERPARAM" #>/dev/null 2>&1 < /dev/null & + echo "running" + ;; + stop) + echo -n "Stopping Klipper Screen Xclient Deamon .... " + PID=`ps -ef|grep KlipperScreen-env/bin/python|awk '{print $2}'` + kill -9 $PID + echo "stopping" + ;; + *) + echo "Usage: $0 start" + exit 1 + ;; +esac + + diff --git a/scripts/xsdl_wrapper.sh b/scripts/xsdl_wrapper.sh index 5736a282..4ac4db85 100755 --- a/scripts/xsdl_wrapper.sh +++ b/scripts/xsdl_wrapper.sh @@ -4,7 +4,12 @@ # Keeps the process alive while the server is active # to mimic default X's behaviour and keep the service happy -./lauch_klipperscreen.sh +if [ -f $PWD/launch_klipperscreen.sh ]; then + exec $PWD/launch_klipperscreen.sh +elif [ ! -f $PWD/launch_klipperscreen.sh ]; then + echo "launch_klipperscreen.sh does not exist" + exit +fi ret=1 timeout=0