agama/live/live-root/usr/bin/agama-screenshot
Ladislav Slezák b98bb609f8
live: Added agama-screenshot helper script (#3537)
## Problem

- Taking screenshots of the Agama installer running locally is
difficult.

## Solution

- Added `agama-screenshot` helper script which saves the whole current
screen.

## Notes

- Enabling the unsafe mode in Gnome Kiosk should be fine in our case,
there is nothing else running in the machine besides the Agama
installer. And you need root access to communicate with the DBus session
bus.
- Ideally we should set some keyboard shortcut for that but
unfortunately Gnome Kiosk does not support that. 😟

## Testing

- Tested manually

```console
agama:~ # agama-screenshot
Screenshot saved to agama-2026-05-22-Pa5h.png
agama:~ # ll agama-2026-05-22-Pa5h.png
-rw-r--r-- 1 root root 112769 May 22 16:53 agama-2026-05-22-Pa5h.png
agama:~ # agama-screenshot agama.png
Screenshot saved to agama.png
agama:~ # ll agama.png 
-rw-r--r-- 1 root root 236302 May 22 16:53 agama.png

```

## Screenshots

Here are the screenshots taken by the commands above.

The default Agama screen after boot:
<img width="1280" height="800" alt="agama-2026-05-22-Pa5h"
src="https://github.com/user-attachments/assets/02e2d33b-07cf-42bf-b5a6-5a3708cc9858"
/>

It captures the whole currently visible screen, if you open the Firefox
developer tools then the window is captured as well:
<img width="1280" height="800" alt="agama"
src="https://github.com/user-attachments/assets/0f5ad823-71a4-4643-9939-4689bfcd0fea"
/>

---------

Co-authored-by: Martin Vidner <mvidner@suse.com>
2026-06-01 16:50:59 +02:00

48 lines
1.5 KiB
Bash
Executable file

#! /bin/bash
# This is a helper script for taking screenshot of the Agama installer
# running locally in Gnome kiosk.
set -e
# handle help option
if [ "$1" == "-h" ] || [ "$1" == "--help" ]; then
echo "Usage: $0 [TARGET_FILE]"
echo
echo "Takes a screenshot of the Agama installer running locally."
echo "The screenshot is saved in PNG format."
echo
echo "If TARGET_FILE is not specified it generates a random name in"
echo "the current directory."
echo
echo "Options:"
echo " -h, --help Show this help message and exit."
exit 0
fi
# Gnome kiosk fails if the target file already exists,
# create the screenshot in a temporary directory and then move it
SCREENSHOT_DIR=$(mktemp -d -p /tmp "screenshot-XXXXXXX")
FILE="$SCREENSHOT_DIR/screenshot.png"
# see the DBus API description at
# https://gitlab.gnome.org/GNOME/gnome-kiosk/-/blob/main/dbus-interfaces/org.gnome.Shell.Screenshot.xml?ref_type=heads
# include cursor: false
# flash screen: false
gdbus call --session --dest org.gnome.Shell.Screenshot --object-path \
/org/gnome/Shell/Screenshot --method org.gnome.Shell.Screenshot.Screenshot \
false false "$FILE" >/dev/null
# move the file
if [ -n "$1" ]; then
# if the script is called with an argument, use it as the target file
TARGET_FILE="$1"
else
# otherwise use a random name in the current directory
TARGET_FILE=$(mktemp "agama-$(date +%Y-%m-%d)-XXXX.png")
fi
mv "$FILE" "$TARGET_FILE"
rm -rf "$SCREENSHOT_DIR"
echo "Screenshot saved to $TARGET_FILE"