From a0fea094f53b69f3e9c9fc49280e846f70f85993 Mon Sep 17 00:00:00 2001 From: Kuba Orlik Date: Wed, 25 May 2022 21:35:55 +0200 Subject: [PATCH] A little bit of smarter checks instead of blind sleeps --- Docker/utils.sh | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/Docker/utils.sh b/Docker/utils.sh index b002776..b430d15 100644 --- a/Docker/utils.sh +++ b/Docker/utils.sh @@ -92,20 +92,22 @@ start_firefox(){ FIREFOX_PID=$! while [ $(get_pixel_color 100 100) = "NONE" ] do - echo "waiting for firefox to open the window" sleep 0.1 done; - echo "firefox opened the window" } prepare_firefox(){ - xdotool key Return # in case there's a "firefox closed unexpectedly" button - sleep 1 - grab "after sleep 1" +# xdotool key Return # in case there's a "firefox closed unexpectedly" button +# sleep 1 +# grab "after sleep 1" click 1886 13 #maximize button grab "after maximize" - sleep 1 - grab "after sleep 1" + FIREFOX_WIDTH=$(wmctrl -lpG | grep Firefox | awk '{print $6}') + while [ "$FIREFOX_WIDTH" != "2880" ] + do + sleep 0.1 + done + #grab "after sleep 1" # no need to reopen the network tab, as it's almost certainly already open # keycombo Control_L Shift_L e # grab "after ctrl+shift+e" @@ -121,9 +123,15 @@ wait_for_pixel_color(){ y=$2; color=$3; timeout=$4; - while [ $(get_pixel_color 143 122) = "#2e3436" ] + start=$(timestamp) + while [ $(get_pixel_color 143 122) != "$color" ] do sleep 0.1 + ts=$(timestamp) + if [ $(( ts - start )) -gt $(( timeout * 1000 )) ] + then + return + fi done } @@ -155,7 +163,7 @@ load_website(){ open_network_inspector(){ keycombo Shift_L F5 #profiler - sleep 1 + wait_for_pixel_color 1777 152 0a84ff 3 keycombo Control_L Shift_L e }