exit 1
fi
+ local spicestring
+
if [ "$spice_client" == "spicy" ] && which spicy &> /dev/null; then
+ spicestring="spice display 0:0"
#spicy -h localhost -p $PORT &
spicy --uri=spice+unix://$SPICESOCKET &
elif [ "$spice_client" == "remote-viewer" ] && which remote-viewer &> /dev/null; then
+ spicestring="$VM \(1\)"
#remote-viewer spice://localhost:$PORT &
remote-viewer spice+unix://$SPICESOCKET &
# This is untested due to libvirt requirements
elif [ "$spice_client" == "virt-viewer" ] && which virt-viewer &> /dev/null; then
#virt-viewer spice://localhost:$PORT &
- virt-viewer spice+unix://$SPICESOCKET &
+ virt-viewer -c spice+unix://$SPICESOCKET &
# Unsupported as spicec was deprecated
#elif [ "$spice_client" != "spicec" ] && which spicec &> /dev/null; then
# # https://lists.freedesktop.org/archives/spice-devel/2013-September/014643.html
exit 1
else
if which spicy &> /dev/null; then
+ spicestring="spice display 0:0"
#spicy -h localhost -p $PORT &
spicy --uri=spice+unix://$SPICESOCKET &
fi
SPICEPID="$!"
echo "$SPICEPID" > $SPICEFILE
- # Give time to connect
- sleep 2
+ echo $spicestring
# Fix window title and position
- if which /usr/bin/xdotool &> /dev/null; then
+ if which /usr/bin/xdotool &> /dev/null && [ ! -z "$spicestring" ]; then
+ local spicewait="0"
+ local windowid
+ local windowpid
+
+ # Wait for the spice window to show up. This might take a while and we'll
+ # wait only a few times
+ while (( $spicewait <= 5 )); do
+ # Wait a bit
+ sleep 2
+ let spicewait++
+
+ windowid="`xdotool search --name "$spicestring" 2> /dev/null`"
+
+ if [ ! -z "$windowid" ]; then
+ # Get the SPICE PID
+ windowpid="`xprop -id $windowid | grep '_NET_WM_PID(CARDINAL)' | cut -d = -f 2 | sed -e 's/ //g'`"
+
+ if [ ! -z "$windowpid" ] && [ "$windowpid" == "$SPICEPID" ]; then
+ break
+ else
+ windowid=""
+ windowpid=""
+ fi
+ fi
+ done
+
# Set window position
#
# Configuration xclient_windowmove can be set either at kvmxconfig
# or as a user setting at ~/.config/kvmxconfig (which will affect all guests).
if [ ! -z "$xclient_windowmove" ]; then
#xdotool search --name "SPICEc:0" windowmove $xclient_windowmove
- xdotool search --name "spice display 0:0" windowmove $xclient_windowmove
+ #xdotool search --name "spice display 0:0" windowmove $xclient_windowmove
+ #xdotool search --name "$spicestring" windowmove $xclient_windowmove
+
+ if [ ! -z "$windowid" ]; then
+ xdotool windowmove $windowid $xclient_windowmove
+ fi
fi
+ # Rename window, search by title version
#xdotool search --name "SPICEc:0" set_window --name $VM
- xdotool search --name "spice display 0:0" set_window --name $VM
+ #xdotool search --name "spice display 0:0" set_window --name $VM
+ #xdotool search --name "$spicestring" set_window --name $VM
+
+ # Rename window, window ID version
+ if [ ! -z "$windowid" ]; then
+ xdotool set_window --name $VM $windowid
+ fi
fi
if [ "$ACTION" == "spice" ]; then