Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

ci(linux): visible Stop click on GPU-rendered GNOME sessions (#3283)

Richie McIlroy4491ce30a264
diff --git a/scripts/linux-desktop-harness/stop-locate.py b/scripts/linux-desktop-harness/stop-locate.py
index 3ad06e80c..0e816ac2a 100755
--- a/scripts/linux-desktop-harness/stop-locate.py
+++ b/scripts/linux-desktop-harness/stop-locate.py
@@ -5,6 +5,10 @@ The controls draw their Stop button (icon and elapsed time) in Cap's red,
#ff4766. Given a screenshot and the controls window's frame, prints the centre
of the red pixels inside it as "x y", or nothing when there are none.
+GNOME Shell writes an empty screenshot when it renders on a GPU or without a
+DRM device, so with no picture to read this prints where the button sits in
+the 320x150 controls.
+
Usage: stop-locate.py <screenshot.png> <x> <y> <width> <height>
"""
import sys
@@ -12,16 +16,23 @@ import sys
import gi
gi.require_version("GdkPixbuf", "2.0")
-from gi.repository import GdkPixbuf # noqa: E402
+from gi.repository import GdkPixbuf, GLib # noqa: E402
RED = (0xFF, 0x47, 0x66)
TOLERANCE = 40
+# The red pixels' centre in a session on vkms.
+STOP_OFFSET = (48, 116)
def main() -> int:
path = sys.argv[1]
left, top, width, height = (int(value) for value in sys.argv[2:6])
- image = GdkPixbuf.Pixbuf.new_from_file(path)
+ try:
+ image = GdkPixbuf.Pixbuf.new_from_file(path)
+ except GLib.Error as error:
+ print(f"no screenshot ({error.message}); using the Stop button's place", file=sys.stderr)
+ print(f"{left + STOP_OFFSET[0]} {top + STOP_OFFSET[1]}")
+ return 0
pixels = image.get_pixels()
stride = image.get_rowstride()
channels = image.get_n_channels()