feat(screenshot): capture authentic about system and fastfetch window
This commit is contained in:
1 parent
feddc61aaa
commit
71053feaf8
2 files changed
+78
-13
No files matched your search
@@ -93,8 +93,19 @@ jobs:
|
|||||||
sleep 15
|
sleep 15
|
||||||
python3 scripts/capture_qemu.py /tmp/qemu/qmp.sock /tmp/captures/04_airlys_start_menu.ppm
|
python3 scripts/capture_qemu.py /tmp/qemu/qmp.sock /tmp/captures/04_airlys_start_menu.ppm
|
||||||
|
|
||||||
# Capture 5: Final Settled System State (at 155s)
|
# Close Start Menu
|
||||||
sleep 30
|
python3 scripts/capture_qemu.py /tmp/qemu/qmp.sock esc
|
||||||
|
sleep 2
|
||||||
|
|
||||||
|
# Launch Konsole & run fastfetch to show the authentic OS About specs
|
||||||
|
python3 scripts/capture_qemu.py /tmp/qemu/qmp.sock about
|
||||||
|
sleep 6
|
||||||
|
|
||||||
|
# Capture 5: Desktop with About System / Fastfetch Information
|
||||||
|
python3 scripts/capture_qemu.py /tmp/qemu/qmp.sock /tmp/captures/06_airlys_about_system.ppm
|
||||||
|
|
||||||
|
# Capture 6: Final Settled System State (at 180s)
|
||||||
|
sleep 5
|
||||||
python3 scripts/capture_qemu.py /tmp/qemu/qmp.sock /tmp/captures/05_airlys_desktop_final.ppm
|
python3 scripts/capture_qemu.py /tmp/qemu/qmp.sock /tmp/captures/05_airlys_desktop_final.ppm
|
||||||
|
|
||||||
kill -9 $QEMU_PID || true
|
kill -9 $QEMU_PID || true
|
||||||
|
|||||||
+65
-11
@@ -4,6 +4,18 @@ import time
|
|||||||
import socket
|
import socket
|
||||||
import json
|
import json
|
||||||
|
|
||||||
|
def qmp_execute(sock_path, cmd_dict):
|
||||||
|
s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
|
||||||
|
s.settimeout(10)
|
||||||
|
s.connect(sock_path)
|
||||||
|
s.recv(4096) # Greeting
|
||||||
|
s.sendall(json.dumps({"execute": "qmp_capabilities"}).encode() + b"\n")
|
||||||
|
s.recv(4096) # Ack
|
||||||
|
s.sendall(json.dumps(cmd_dict).encode() + b"\n")
|
||||||
|
resp = s.recv(4096)
|
||||||
|
s.close()
|
||||||
|
return resp
|
||||||
|
|
||||||
def qmp_send_keys(sock_path, key_names):
|
def qmp_send_keys(sock_path, key_names):
|
||||||
try:
|
try:
|
||||||
s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
|
s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
|
||||||
@@ -16,24 +28,61 @@ def qmp_send_keys(sock_path, key_names):
|
|||||||
cmd = json.dumps({"execute": "send-key", "arguments": {"keys": [{"type": "qcode", "data": k}]}})
|
cmd = json.dumps({"execute": "send-key", "arguments": {"keys": [{"type": "qcode", "data": k}]}})
|
||||||
s.sendall(cmd.encode() + b"\n")
|
s.sendall(cmd.encode() + b"\n")
|
||||||
s.recv(4096)
|
s.recv(4096)
|
||||||
time.sleep(0.1)
|
time.sleep(0.08)
|
||||||
s.close()
|
s.close()
|
||||||
print(f"Sent keys {key_names} successfully.")
|
print(f"Sent keys {key_names} successfully.")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Failed to send keys: {e}")
|
print(f"Failed to send keys: {e}")
|
||||||
|
|
||||||
|
def qmp_send_combo(sock_path, combo_keys):
|
||||||
|
try:
|
||||||
|
keys_payload = [{"type": "qcode", "data": k} for k in combo_keys]
|
||||||
|
cmd = {"execute": "send-key", "arguments": {"keys": keys_payload}}
|
||||||
|
qmp_execute(sock_path, cmd)
|
||||||
|
print(f"Sent combo {combo_keys} successfully.")
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Failed to send combo {combo_keys}: {e}")
|
||||||
|
|
||||||
|
def qmp_type_string(sock_path, text):
|
||||||
|
try:
|
||||||
|
for ch in text:
|
||||||
|
if ch == ' ':
|
||||||
|
qmp_send_keys(sock_path, ['spc'])
|
||||||
|
elif ch == '\n':
|
||||||
|
qmp_send_keys(sock_path, ['ret'])
|
||||||
|
elif ch == '-':
|
||||||
|
qmp_send_keys(sock_path, ['minus'])
|
||||||
|
else:
|
||||||
|
qmp_send_keys(sock_path, [ch.lower()])
|
||||||
|
time.sleep(0.05)
|
||||||
|
print(f"Typed string '{text}' successfully.")
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Failed to type string: {e}")
|
||||||
|
|
||||||
|
def qmp_open_about_terminal(sock_path):
|
||||||
|
try:
|
||||||
|
print("Opening Application / Terminal for About System...")
|
||||||
|
# 1. First try KRunner (Alt+F2)
|
||||||
|
qmp_send_combo(sock_path, ["alt", "f2"])
|
||||||
|
time.sleep(1.5)
|
||||||
|
qmp_type_string(sock_path, "konsole\n")
|
||||||
|
time.sleep(4)
|
||||||
|
|
||||||
|
# 2. Also try standard shortcut Ctrl+Alt+T
|
||||||
|
qmp_send_combo(sock_path, ["ctrl", "alt", "t"])
|
||||||
|
time.sleep(3)
|
||||||
|
|
||||||
|
# 3. Type fastfetch in Konsole terminal
|
||||||
|
qmp_type_string(sock_path, "fastfetch\n")
|
||||||
|
time.sleep(4)
|
||||||
|
print("Executed fastfetch command in live terminal.")
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Failed to open About system: {e}")
|
||||||
|
|
||||||
def qmp_screendump(sock_path, out_file):
|
def qmp_screendump(sock_path, out_file):
|
||||||
try:
|
try:
|
||||||
s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
|
cmd = {"execute": "screendump", "arguments": {"filename": out_file}}
|
||||||
s.settimeout(10)
|
qmp_execute(sock_path, cmd)
|
||||||
s.connect(sock_path)
|
|
||||||
s.recv(4096) # QMP greeting
|
|
||||||
s.sendall(json.dumps({"execute": "qmp_capabilities"}).encode() + b"\n")
|
|
||||||
s.recv(4096) # Capabilities accepted
|
|
||||||
cmd = json.dumps({"execute": "screendump", "arguments": {"filename": out_file}})
|
|
||||||
s.sendall(cmd.encode() + b"\n")
|
|
||||||
s.recv(4096) # Screendump completed
|
|
||||||
s.close()
|
|
||||||
print(f"Successfully captured screenshot to: {out_file}")
|
print(f"Successfully captured screenshot to: {out_file}")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Failed to capture {out_file}: {e}")
|
print(f"Failed to capture {out_file}: {e}")
|
||||||
@@ -50,5 +99,10 @@ if __name__ == "__main__":
|
|||||||
qmp_send_keys(sock, ["a", "i", "r", "l", "y", "s", "ret"])
|
qmp_send_keys(sock, ["a", "i", "r", "l", "y", "s", "ret"])
|
||||||
elif arg == "start" or arg == "super":
|
elif arg == "start" or arg == "super":
|
||||||
qmp_send_keys(sock, ["meta_l"])
|
qmp_send_keys(sock, ["meta_l"])
|
||||||
|
elif arg == "esc":
|
||||||
|
qmp_send_keys(sock, ["esc"])
|
||||||
|
elif arg == "about":
|
||||||
|
qmp_open_about_terminal(sock)
|
||||||
else:
|
else:
|
||||||
qmp_screendump(sock, arg)
|
qmp_screendump(sock, arg)
|
||||||
|
|
||||||
Reference in new issue
Block a user