From 13babe75745101bf5ba462e694b2d578ced0e2cc Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Mon, 1 May 2017 14:29:51 -0300 Subject: Adds kvmx_xephyr_stop --- kvmx | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/kvmx b/kvmx index 4509a6d..9e5f288 100755 --- a/kvmx +++ b/kvmx @@ -161,6 +161,7 @@ function __kvmx_initialize { SSHFILE="$STATE_DIR/ssh" DISPLAYFILE="$STATE_DIR/display" SPICEFILE="$STATE_DIR/spice" + XEPHYRFILE="$STATE_DIR/xephyr" LOGFILE="$LOG_DIR/qemu" SPICELOG="$LOG_DIR/spice" XPRALOG="$LOG_DIR/xpra" @@ -526,6 +527,7 @@ function kvmx_poweroff { fi echo /usr/bin/sudo poweroff | kvmx_ssh &> /dev/null + kvmx_xephyr_stop sleep 3 kvmx_status } @@ -556,6 +558,7 @@ function kvmx_hibernate { echo "Unable to hibernate guest: please check guest configuration" exit 1 else + kvmx_xephyr_stop kvmx_status fi } @@ -747,6 +750,7 @@ function kvmx_stop { if kvmx_running; then PID="`cat $PIDFILE`" kill $PID + kvmx_xephyr_stop fi } @@ -755,6 +759,7 @@ function kvmx_kill { if kvmx_running; then PID="`cat $PIDFILE`" kill -9 $PID + kvmx_xephyr_stop fi } @@ -957,12 +962,15 @@ function kvmx_xephyr { Xephyr :$GUEST_DISPLAY -ac -port $XDMCP_PORT -query 127.0.0.1 $resolution &> $XDMCPLOG < /dev/null & + XEPHYRPID="$!" + echo "$XEPHYRPID" > $XEPHYRFILE + # Give time to connect sleep 1 # Set keyboard layout # Thanks https://unix.stackexchange.com/questions/304391/xephyr-keyboard-mapping-not-working-properly - setxkbmap -display :0 -print | xkbcomp - :$GUEST_DISPLAY >> $XDMCPLOG + setxkbmap -display :0 -print | xkbcomp - :$GUEST_DISPLAY &> /dev/null # Fix window titles if which /usr/bin/xdotool &> /dev/null; then @@ -970,6 +978,15 @@ function kvmx_xephyr { fi } +# Close Xephyr client +function kvmx_xephyr_stop { + XEPHYRPID="`cat $XEPHYRFILE`" + + if [ ! -z "$XEPHYRPID" ]; then + kill $XEPHYRPID &> /dev/null + fi +} + # Dispatch if type kvmx_$ACTION 2> /dev/null | grep -q 'function'; then __kvmx_initialize -- cgit v1.2.3