]> gitweb.fluxo.info Git - kvmx.git/commitdiff
Feat: spice: notification on Awesome VM when a Spice session is taking too long to...
authorSilvio Rhatto <rhatto@riseup.net>
Sun, 4 Aug 2024 13:58:00 +0000 (10:58 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Sun, 4 Aug 2024 13:58:00 +0000 (10:58 -0300)
ChangeLog.md
kvmx

index 668816cc505fee3b40dacbc68c0d7671c99f6143..68b066e2b69b7bd6ecbb112295bcb8b01afafed1 100644 (file)
@@ -10,7 +10,7 @@
   * Inotify action for watching a folder in the host and issuing commands in the
     guest upon change.
 
-  * Notification on Awesome VM when a Spice session is triggered.
+  * Notification on Awesome VM when a Spice session taking too long to open.
 
 ## 0.2.0 - 2024-07-02
 
diff --git a/kvmx b/kvmx
index 3a7e59d23ccf55b6905694495b8fdc0422ee62bb..ab599f5ce0c390a1a171525ad352215498227686 100755 (executable)
--- a/kvmx
+++ b/kvmx
@@ -265,11 +265,6 @@ function kvmx_spice {
     exit 1
   fi
 
-  # UX
-  if which awesome-client &> /dev/null; then
-    echo "naughty.notify({title = \"KVMX:\", text =\"Starting GUI session for $VM\", timeout = 2})" | awesome-client
-  fi
-
   local spicestring
 
   if [ "$spice_client" == "spicy" ] && which spicy &> /dev/null; then
@@ -307,14 +302,11 @@ function kvmx_spice {
     local spicewait="0"
     local windowid
     local windowpid
+    local notify="0"
 
     # 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++
-
+    while (( $spicewait <= 10 )); do
       windowid="`xdotool search --name "$spicestring" 2> /dev/null`"
 
       if [ ! -z "$windowid" ]; then
@@ -328,6 +320,17 @@ function kvmx_spice {
           windowpid=""
         fi
       fi
+
+      # It's waiting too long, notify the user
+      if which awesome-client &> /dev/null && [ "$notify" == "0" ]; then
+        notify="1"
+
+        echo "naughty.notify({title = \"KVMX:\", text =\"Starting GUI session for $VM\", timeout = 2})" | awesome-client
+      fi
+
+      # Wait a bit and try again
+      sleep 1
+      let spicewait++
     done
 
     # Set window position