]> gitweb.fluxo.info Git - kvmx.git/commitdiff
Adds kvmx_xephyr_stop
authorSilvio Rhatto <rhatto@riseup.net>
Mon, 1 May 2017 17:29:51 +0000 (14:29 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Mon, 1 May 2017 17:29:51 +0000 (14:29 -0300)
kvmx

diff --git a/kvmx b/kvmx
index 4509a6dab072d6cec849b51ab49656fe266ca449..9e5f288933b3968379f9037464012654862ff536 100755 (executable)
--- 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