The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.
TypeScript 3d-modelingagent-frameworkagent-harnessai-agentscadclaude-codecodexcoding-agentsdeveloper-toolsesp32game-developmentmcp-servermulti-agentopen-hardwareopencodeopenharnesspcbroboticsterminaltmux
feat(os): disk-unlock lock screen, screenshots and a Super+e file manager window
bubu-dudud6179dc2ff1a
diff --git a/os/INSTALL.md b/os/INSTALL.mdindex 8ca033248..1ce271a6d 100644--- a/os/INSTALL.md+++ b/os/INSTALL.md@@ -144,8 +144,11 @@ the next key. A capital letter in a prefix binding means Shift + letter.| Super+m | Connect a computer || Super+w | Connect to Wi-Fi || Super+b | Open/focus Chromium, or return to Harness |+| Super+e | Open/focus the file manager, or return to Harness || Super+Enter | Focus Harness || Super+l | Lock; unlock with the account password |+| Print or Super+p | Screenshot the whole screen |+| Shift+Print or Super+r | Screenshot a region dragged with the pointer (Esc cancels) || Super+u | Update Harness || `hn-browser http://localhost:3000` | Open a local project in the browser || `sudo systemctl poweroff` | Shut down |diff --git a/os/README.md b/os/README.mdindex 2ed4a5e37..6f97ef29c 100644--- a/os/README.md+++ b/os/README.md@@ -185,7 +185,12 @@ is no connection. Connecting advances automatically to OpenCode on the left andtwo terminal panes on the right. Working Ethernet skips Wi-Fi setup. Later bootsreconnect to saved Wi-Fi and restore existing work. Super+n starts New Harness,Super+t opens a shell directly, Super+m connects a computer, Super+w opens Wi-Fi-and Super+l locks the session. These require no Shift or prefix. The shared TUI+and Super+l locks the session behind the same wordmark and "Enter your password"+as disk unlock. Super+e opens the file manager in its own window, a folder+tree on the left and the folder on the right; pressing it again returns to hn.+Print or Super+p captures the screen, Shift+Print or Super+r a+dragged region; each picture is saved under `~/Pictures/Screenshots` and copied+to the clipboard. The Super keys require no Shift or prefix. The shared TUIshortcuts still work; ordinary hn on macOS and other Linux distributions retainsits usual UI.Recovery remains available through another console or the USB; the owner retainsdiff --git a/os/packages.x86_64 b/os/packages.x86_64index b8775a424..48b32949f 100644--- a/os/packages.x86_64+++ b/os/packages.x86_64@@ -38,13 +38,15 @@ vulkan-radeonlibva-intel-driverintel-media-driverwl-clipboard+grim+slurpxdg-utilsxdg-desktop-portal-wlrpipewirepipewire-pulsewireplumberswayidle-swaylock+gtklockbrightnessctlttf-dejavuttf-nerd-fonts-symbols-monodiff --git a/os/packaging/fedora/guide.md b/os/packaging/fedora/guide.mdindex 9325f56b1..45649a4fa 100644--- a/os/packaging/fedora/guide.md+++ b/os/packaging/fedora/guide.md@@ -22,8 +22,10 @@ Ctrl+b is a prefix: release it before the next key. Verify customized keys with`hn list-keys`. Closing a pane and stopping an agent are different actions.The OS keys are in `labwc/rc.xml`: Super+n opens New Harness, Super+t a terminal,-Super+m the connection flow, Super+w Wi-Fi, Super+b the browser, Super+Enter hn,-and Super+l the lock screen. Super is Command on a Mac keyboard running Linux.+Super+m the connection flow, Super+w Wi-Fi, Super+b the browser, Super+e the file manager, Super+Enter hn,+and Super+l the lock screen. Print or Super+p saves a screenshot, Shift+Print or+Super+r a region, to `~/Pictures/Screenshots` and the clipboard. Super is Command+on a Mac keyboard running Linux.Brightness and audio keys operate supported hardware. These are Linux sessionbindings, not macOS shortcuts.diff --git a/os/packaging/fedora/harness-os-session.spec b/os/packaging/fedora/harness-os-session.specindex a784d4510..7783cac68 100644--- a/os/packaging/fedora/harness-os-session.spec+++ b/os/packaging/fedora/harness-os-session.spec@@ -15,8 +15,8 @@ Source1: files.listRequires: python3, nodejs22, nodejs22-bin, tmux, foot, labwcRequires: systemd, dbus-tools, NetworkManager, sudo, util-linux, procps-ng, kmod, iproute-Requires: pipewire, pipewire-pulseaudio, wireplumber, swayidle, swaylock, brightnessctl-Requires: wl-clipboard, xdg-utils, xdg-desktop-portal-wlr, dejavu-sans-mono-fonts+Requires: pipewire, pipewire-pulseaudio, wireplumber, swayidle, gtklock, brightnessctl+Requires: wl-clipboard, grim, slurp, xdg-utils, xdg-desktop-portal-wlr, dejavu-sans-mono-fontsRequires: google-noto-color-emoji-fonts, cascadia-mono-nf-fonts%descriptiondiff --git a/os/root/usr/lib/harness-os/files b/os/root/usr/lib/harness-os/filesnew file mode 100644index 000000000..cc3cbfe4b--- /dev/null+++ b/os/root/usr/lib/harness-os/files@@ -0,0 +1,9 @@+#!/bin/sh+# Super+e: the file manager in a window of its own, beside hn as the browser is (Super+b) — a folder+# tree on the left, the folder's contents on the right. It is hn's own file view run standalone+# (`hn files`), in the same foot look as the hn screen, so a file opens in the editor right there.+. /usr/lib/harness-os/runtime-path+cd "$HOME" || exit 1+export HARNESS_OS=1+exec /usr/bin/foot --app-id=harness-files --title=Files \+ --config=/usr/share/harness-os/foot.ini "$HARNESS_TUI_BIN" files "${1:-$HOME}"diff --git a/os/root/usr/lib/harness-os/lock b/os/root/usr/lib/harness-os/locknew file mode 100644index 000000000..048550d27--- /dev/null+++ b/os/root/usr/lib/harness-os/lock@@ -0,0 +1,16 @@+#!/bin/sh+# The session lock, laid out as the disk unlock screen: the HARNESS wordmark, "Enter your password"+# and a rectangular field showing one * per key (lock/layout.ui, lock/style.css). It replaced+# `swaylock -c 000000`: a black screen whose only sign of life was a ring that appeared after the+# first key, and people did not know where to type.+#+# -d returns only once the compositor has acknowledged the lock, so swayidle's before-sleep waits+# for it, as it did for swaylock -f. The marker says the same to the session checks+# (tests/session_vm.py): gtklock, unlike swaylock, leaves no session leader to look for.+marker=${XDG_RUNTIME_DIR:-/run/user/$(id -u)}/harness-os-locked+rm -f "$marker"+exec gtklock -d \+ -s /usr/share/harness-os/lock/style.css \+ -x /usr/share/harness-os/lock/layout.ui \+ -L "touch $marker" -U "rm -f $marker" \+ "$@"diff --git a/os/root/usr/lib/harness-os/screenshot b/os/root/usr/lib/harness-os/screenshotnew file mode 100644index 000000000..ed32b1946--- /dev/null+++ b/os/root/usr/lib/harness-os/screenshot@@ -0,0 +1,25 @@+#!/bin/sh+# Print / Super+p: the whole screen. Shift+Print / Super+r: a region dragged out with the pointer.+# The picture is saved under ~/Pictures/Screenshots and put on the clipboard, so it can be pasted+# into an agent or the browser at once. There is no notification daemon; hn says where it went.+set -u+mode=${1:-full}+dir=${XDG_PICTURES_DIR:-$HOME/Pictures}/Screenshots+file=$dir/Screenshot-$(date +%Y-%m-%d_%H-%M-%S).png+tell() { hn display-message "$1" >/dev/null 2>&1 || true; }++mkdir -p "$dir" || { tell "Screenshot failed: cannot create $dir"; exit 1; }+case $mode in+ full) grim "$file" ;;+ # Escape or a right click cancels the selection; that is not a failure worth a message.+ region) area=$(slurp) || exit 0; grim -g "$area" "$file" ;;+ *) echo "usage: screenshot [full|region]" >&2; exit 2 ;;+esac || { tell "Screenshot failed"; exit 1; }++shown=$(printf '%s' "$file" | sed "s|^$HOME/|~/|")+# wl-copy stays behind to serve the clipboard; it must not hold the caller's output open.+if wl-copy --type image/png <"$file" >/dev/null 2>&1; then+ tell "Screenshot saved to $shown and copied"+else+ tell "Screenshot saved to $shown"+fidiff --git a/os/root/usr/lib/systemd/user/harness-idle.service b/os/root/usr/lib/systemd/user/harness-idle.serviceindex 63f5a8f6a..ce6075b26 100644--- a/os/root/usr/lib/systemd/user/harness-idle.service+++ b/os/root/usr/lib/systemd/user/harness-idle.service@@ -4,5 +4,5 @@ ConditionPathExists=!/etc/harness-livePartOf=harness-os.target[Service]-ExecStart=/usr/bin/swayidle -w timeout 600 'swaylock -f -c 000000' before-sleep 'swaylock -f -c 000000'+ExecStart=/usr/bin/swayidle -w timeout 600 /usr/lib/harness-os/lock before-sleep /usr/lib/harness-os/lockRestart=on-failurediff --git a/os/root/usr/share/harness-os/AGENTS.md b/os/root/usr/share/harness-os/AGENTS.mdindex d9ae95338..a3117fb2f 100644--- a/os/root/usr/share/harness-os/AGENTS.md+++ b/os/root/usr/share/harness-os/AGENTS.md@@ -82,8 +82,12 @@ is required.- npm installs into `~/.local`. The initial npm configuration permits the vendorinstall scripts for Claude Code, Codex and OpenCode. When another package needsan install script, approve that package explicitly; keep npm's other defaults.-- `Super+b` opens/focuses Chromium or returns to hn; `Super+Enter` focuses hn;+- `Super+b` opens/focuses Chromium or returns to hn; `Super+e` does the same for+ the file manager window (`hn files DIR`); `Super+Enter` focuses hn;`Super+l` locks the screen. `sudo systemctl poweroff` shuts down cleanly.+- Print/`Super+p` saves a full screenshot and Shift+Print/`Super+r` a region to+ `~/Pictures/Screenshots`, also copied to the clipboard. When the user mentions+ "the screenshot", read the newest file there. `grim` and `slurp` are installed.- On supported NVIDIA Turing and newer GPUs, including RTX 4090/5090 and RTX 6000generations, the LTS-kernel packages are `nvidia-open-lts nvidia-utils`.New USB images carrying the NVIDIA bundle install them offline when the exactdiff --git a/os/root/usr/share/harness-os/labwc/rc.xml b/os/root/usr/share/harness-os/labwc/rc.xmlindex f9cecac4c..735ec5a20 100644--- a/os/root/usr/share/harness-os/labwc/rc.xml+++ b/os/root/usr/share/harness-os/labwc/rc.xml@@ -22,7 +22,7 @@</keybind><keybind key="W-Return"><action name="ForEach"><query identifier="hn" /><then><action name="Raise" /><action name="Focus" /></then></action></keybind><keybind key="A-Tab"><action name="NextWindowImmediate" /></keybind>- <keybind key="W-l"><action name="Execute" command="swaylock -f -c 000000" /></keybind>+ <keybind key="W-l"><action name="Execute" command="/usr/lib/harness-os/lock" /></keybind><keybind key="W-u"><action name="Execute" command="/usr/lib/harness-os/open-updates" /><action name="ForEach"><query identifier="hn" /><then><action name="Raise" /><action name="Focus" /></then></action>@@ -43,10 +43,26 @@<action name="Execute" command="hn os-action terminal" /><action name="ForEach"><query identifier="hn" /><then><action name="Raise" /><action name="Focus" /></then></action></keybind>+ <!-- Super+e is run-or-raise for the file manager window, then back to hn, as Super+b is. -->+ <keybind key="W-e">+ <action name="If">+ <query identifier="harness-files" />+ <then><action name="ForEach"><query identifier="hn" /><then><action name="Raise" /><action name="Focus" /></then></action></then>+ <else>+ <action name="ForEach"><query identifier="harness-files" /><then><action name="Raise" /><action name="Focus" /></then><none><action name="Execute" command="/usr/lib/harness-os/files" /></none></action>+ </else>+ </action>+ </keybind><keybind key="W-m"><action name="Execute" command="hn os-action connect" /><action name="ForEach"><query identifier="hn" /><then><action name="Raise" /><action name="Focus" /></then></action></keybind>+ <!-- Screenshots go to ~/Pictures/Screenshots and the clipboard. Super+p/r stand in for Print+ on keyboards without one. Focus stays where it is: raising hn would capture hn instead. -->+ <keybind key="Print"><action name="Execute" command="/usr/lib/harness-os/screenshot full" /></keybind>+ <keybind key="S-Print"><action name="Execute" command="/usr/lib/harness-os/screenshot region" /></keybind>+ <keybind key="W-p"><action name="Execute" command="/usr/lib/harness-os/screenshot full" /></keybind>+ <keybind key="W-r"><action name="Execute" command="/usr/lib/harness-os/screenshot region" /></keybind><keybind key="XF86MonBrightnessUp"><action name="Execute" command="brightnessctl --class=backlight --min-value=1 set +5%" /></keybind><keybind key="XF86MonBrightnessDown"><action name="Execute" command="brightnessctl --class=backlight --min-value=1 set 5%-" /></keybind><keybind key="XF86KbdBrightnessUp"><action name="Execute" command="brightnessctl --class=leds --device='*::kbd_backlight' set +10%" /></keybind>@@ -58,6 +74,7 @@<mouse><context name="Root"><mousebind button="Right" action="Press"><action name="None" /></mousebind></context></mouse><windowRules><windowRule identifier="hn" serverDecoration="no" />+ <windowRule identifier="harness-files" serverDecoration="no" /><windowRule identifier="chromium*" type="normal" serverDecoration="no"><action name="Maximize" /></windowRule></windowRules></labwc_config>diff --git a/os/root/usr/share/harness-os/lock/layout.ui b/os/root/usr/share/harness-os/lock/layout.uinew file mode 100644index 000000000..e910b6ffc--- /dev/null+++ b/os/root/usr/share/harness-os/lock/layout.ui@@ -0,0 +1,110 @@+<?xml version="1.0" encoding="UTF-8"?>+<!-- The session lock, laid out as the disk unlock screen (plymouth/themes/harness): the wordmark,+ "Enter your password" and a field that shows one * per key. gtklock looks its widgets up by+ these ids; the clock and Unlock button it expects are kept but never shown. The wordmark is+ the Plymouth theme's, character for character (tests/test_lock_and_screenshot.py). -->+<interface>+ <object class="GtkBox" id="window-box">+ <property name="name">window-box</property>+ <property name="halign">center</property>+ <property name="valign">center</property>+ <property name="orientation">vertical</property>+ <child>+ <object class="GtkBox" id="info-box">+ <property name="name">info-box</property>+ <property name="halign">center</property>+ <property name="orientation">vertical</property>+ <child>+ <object class="GtkLabel" id="wordmark">+ <property name="name">wordmark</property>+ <property name="label"> _ _ _ ____ _ _ _____ ____ ____+| | | | / \ | _ \| \ | | ____/ ___/ ___|+| |_| | / _ \ | |_) | \| | _| \___ \___ \+| _ |/ ___ \| _ <| |\ | |___ ___) |__) |+|_| |_/_/ \_\_| \_\_| \_|_____|____/____/</property>+ </object>+ </child>+ <child>+ <object class="GtkBox" id="time-box">+ <property name="name">time-box</property>+ <property name="no-show-all">1</property>+ <property name="visible">0</property>+ <property name="orientation">vertical</property>+ <child><object class="GtkLabel" id="clock-label"><property name="name">clock-label</property></object></child>+ <child><object class="GtkLabel" id="date-label"><property name="name">date-label</property></object></child>+ </object>+ </child>+ </object>+ </child>+ <child>+ <object class="GtkRevealer" id="body-revealer">+ <property name="transition-type">none</property>+ <property name="reveal-child">0</property>+ <child>+ <object class="GtkGrid" id="body-grid">+ <property name="halign">center</property>+ <property name="row-spacing">12</property>+ <child>+ <object class="GtkLabel" id="input-label">+ <property name="name">input-label</property>+ <property name="label">Enter your password</property>+ </object>+ <packing><property name="left-attach">0</property><property name="top-attach">0</property></packing>+ </child>+ <child>+ <object class="GtkEntry" id="input-field">+ <property name="name">input-field</property>+ <property name="width-request">420</property>+ <property name="visibility">0</property>+ <property name="invisible-char">*</property>+ <property name="xalign">0.5</property>+ <property name="caps-lock-warning">0</property>+ <property name="input-purpose">password</property>+ <signal name="activate" handler="window_pw_check"/>+ </object>+ <packing><property name="left-attach">0</property><property name="top-attach">1</property></packing>+ </child>+ <child>+ <object class="GtkRevealer" id="message-revealer">+ <property name="transition-type">none</property>+ <property name="no-show-all">1</property>+ <child>+ <object class="GtkScrolledWindow" id="message-scrolled-window">+ <property name="hscrollbar-policy">never</property>+ <property name="max-content-height">256</property>+ <property name="propagate-natural-height">1</property>+ <child><object class="GtkViewport"><child>+ <object class="GtkBox" id="message-box">+ <property name="orientation">vertical</property>+ <property name="homogeneous">1</property>+ </object>+ </child></object></child>+ </object>+ </child>+ </object>+ <packing><property name="left-attach">0</property><property name="top-attach">2</property></packing>+ </child>+ <child>+ <object class="GtkBox">+ <property name="halign">center</property>+ <property name="spacing">8</property>+ <child><object class="GtkLabel" id="warning-label"><property name="name">warning-label</property></object></child>+ <child><object class="GtkLabel" id="error-label"><property name="name">error-label</property></object></child>+ <child>+ <object class="GtkButton" id="unlock-button">+ <property name="name">unlock-button</property>+ <property name="no-show-all">1</property>+ <property name="visible">0</property>+ <property name="label">Unlock</property>+ <signal name="clicked" handler="window_pw_check"/>+ </object>+ </child>+ </object>+ <packing><property name="left-attach">0</property><property name="top-attach">3</property></packing>+ </child>+ </object>+ </child>+ </object>+ </child>+ </object>+</interface>diff --git a/os/root/usr/share/harness-os/lock/style.css b/os/root/usr/share/harness-os/lock/style.cssnew file mode 100644index 000000000..e9864cc55--- /dev/null+++ b/os/root/usr/share/harness-os/lock/style.css@@ -0,0 +1,39 @@+/* The disk unlock screen's colours (plymouth/themes/harness/harness.script): a yellow wordmark,+ light grey text, monospace. The background stays black: the session checks require a lock that+ shows nothing of the desk, down to its corner pixels. */+window {+ background-color: #000000;+ background-image: none;+}+#wordmark, #input-label, #input-field, #error-label, #warning-label {+ font-family: "DejaVu Sans Mono", monospace;+ font-size: 16pt;+}+#wordmark {+ color: #d9c71a;+ margin-bottom: 40px;+}+#input-label {+ color: #dbdbdb;+}+#input-field {+ color: #dbdbdb;+ caret-color: #d9c71a;+ background-color: #000000;+ background-image: none;+ border: 1px solid #5a5a5a;+ border-radius: 0;+ box-shadow: none;+ padding: 8px 12px;+}+#input-field:focus {+ border-color: #d9c71a;+}+#error-label {+ color: #e05555;+ font-size: 13pt;+}+#warning-label {+ color: #d9c71a;+ font-size: 13pt;+}diff --git a/os/tests/session_vm.py b/os/tests/session_vm.pyindex ada707b06..4e58109d8 100644--- a/os/tests/session_vm.py+++ b/os/tests/session_vm.py@@ -48,11 +48,11 @@ def screen_text(vm, name):def wait_lock(vm, locked, timeout=15):- # -f returns only after the compositor acknowledges the lock, then its child- # calls setsid(). A matching process alone includes the pre-lock parent/PAM- # helper and can race the screen and keyboard grab.- command = ("ps -u 1000 -o pid=,sid=,comm= | awk '$1 == $2 && $3 == \"swaylock\" {ready=1} END {exit !ready}'"- if locked else '! pgrep -u 1000 -x swaylock >/dev/null')+ # The lock's marker is written only once the compositor acknowledges the lock+ # (gtklock's lock command, usr/lib/harness-os/lock). A matching process alone+ # includes the pre-lock parent and can race the screen and keyboard grab.+ command = ('pgrep -u 1000 -x gtklock >/dev/null && test -e /run/user/1000/harness-os-locked'+ if locked else '! pgrep -u 1000 -x gtklock >/dev/null')vm.command('for n in $(seq 1 ' + str(timeout * 4) + '); do if ' + command + '; then exit 0; fi; sleep 0.25; done; exit 1', timeout=timeout + 5)@@ -64,7 +64,7 @@ def live_lock(vm, user):print('Checking live ' + name, flush=True)trigger()time.sleep(1)- _, status = vm.command('pgrep -u 1000 -x swaylock', check=False)+ _, status = vm.command('pgrep -u 1000 -x gtklock', check=False)if status == 0:vm.screenshot('live-' + name + '-locked')vm.keys('ret')@@ -333,7 +333,7 @@ def main():result['live_lock_error'] = str(error)vm.screenshot('live-lock-failure')# Recover this disposable fixture so installed locking can still be diagnosed.- vm.command('pkill -u 1000 -x swaylock || true')+ vm.command('pkill -u 1000 -x gtklock || true')put(vm, '/tmp/install-config.json', json.dumps(config))vm.command('nmcli networking off')print('Installing offline into the disposable test disk', flush=True)diff --git a/os/tests/test_lock_and_screenshot.py b/os/tests/test_lock_and_screenshot.pynew file mode 100644index 000000000..97cab541a--- /dev/null+++ b/os/tests/test_lock_and_screenshot.py@@ -0,0 +1,152 @@+from pathlib import Path+import re+import stat+import subprocess+import tempfile+import unittest+import xml.etree.ElementTree as ET++OS = Path(__file__).resolve().parents[1]+ROOT = OS / 'root'+RC = ROOT / 'usr/share/harness-os/labwc/rc.xml'+LOCK = ROOT / 'usr/lib/harness-os/lock'+SCREENSHOT = ROOT / 'usr/lib/harness-os/screenshot'+++def bindings():+ keyboard = ET.parse(RC).getroot().find('keyboard')+ return {bind.get('key'): [a.get('command') for a in bind.iter('action') if a.get('command')]+ for bind in keyboard.findall('keybind')}+++class SessionLock(unittest.TestCase):+ def test_every_lock_goes_through_one_dressed_locker(self):+ self.assertEqual(bindings()['W-l'], ['/usr/lib/harness-os/lock'])+ idle = (ROOT / 'usr/lib/systemd/user/harness-idle.service').read_text()+ self.assertIn('timeout 600 /usr/lib/harness-os/lock before-sleep /usr/lib/harness-os/lock', idle)+ self.assertNotIn('swaylock', RC.read_text() + idle)++ def test_locker_keeps_what_the_session_checks_rely_on(self):+ text = LOCK.read_text()+ # -d returns once the lock is acknowledged (swayidle's before-sleep waits on it); the marker+ # is what tests/session_vm.py waits for, written by the lock command and removed on unlock.+ self.assertRegex(text, r'(?m)^exec gtklock -d ')+ self.assertIn('-s /usr/share/harness-os/lock/style.css', text)+ self.assertIn('-x /usr/share/harness-os/lock/layout.ui', text)+ self.assertIn('-L "touch $marker" -U "rm -f $marker"', text)+ self.assertIn('harness-os-locked', (OS / 'tests/session_vm.py').read_text())+ subprocess.run(['sh', '-n', LOCK], check=True)+ packages = (OS / 'packages.x86_64').read_text().split()+ self.assertIn('gtklock', packages)+ self.assertNotIn('swaylock', packages)++ def test_lock_screen_reads_as_the_disk_unlock_screen(self):+ theme = (ROOT / 'usr/share/plymouth/themes/harness/harness.script').read_text()+ art = re.search(r'logo_text = "(.*)";', theme)[1].encode().decode('unicode_escape')+ objects = {o.get('id'): o for o in ET.parse(ROOT / 'usr/share/harness-os/lock/layout.ui').iter('object')}+ prop = lambda oid, name: next(p.text for p in objects[oid].findall('property') if p.get('name') == name)+ self.assertEqual(prop('wordmark', 'label'), art)+ self.assertEqual(prop('input-label', 'label'), 'Enter your password')+ # One * per key, as the Plymouth entry draws them; never a reveal-the-password button.+ self.assertEqual(prop('input-field', 'invisible-char'), '*')+ self.assertEqual(prop('input-field', 'visibility'), '0')+ self.assertFalse([p for p in objects['input-field'].findall('property') if 'icon' in p.get('name')])+ # Every widget gtklock looks up (src/window.c) must exist, or it cannot lock at all.+ for oid in ['window-box', 'body-revealer', 'body-grid', 'input-label', 'input-field', 'message-revealer',+ 'message-scrolled-window', 'message-box', 'unlock-button', 'error-label', 'warning-label',+ 'info-box', 'time-box', 'clock-label', 'date-label']:+ self.assertIn(oid, objects)+ style = (ROOT / 'usr/share/harness-os/lock/style.css').read_text()+ self.assertRegex(style, r'window \{\s*background-color: #000000;')+++class FileManager(unittest.TestCase):+ def test_super_e_runs_or_raises_its_own_window_like_the_browser(self):+ keyboard = ET.parse(RC).getroot().find('keyboard')+ bind = next(b for b in keyboard.findall('keybind') if b.get('key') == 'W-e')+ condition = bind.find('action')+ self.assertEqual(condition.get('name'), 'If')+ self.assertEqual(condition.find('query').get('identifier'), 'harness-files')+ # Focused: back to hn. Otherwise: raise the window, or start it when there is none.+ self.assertEqual(condition.find('then').find('action/query').get('identifier'), 'hn')+ self.assertEqual([a.get('command') for a in condition.find('else').iter('action') if a.get('command')],+ ['/usr/lib/harness-os/files'])+ rules = ET.parse(RC).getroot().find('windowRules')+ self.assertTrue([r for r in rules if r.get('identifier') == 'harness-files' and r.get('serverDecoration') == 'no'])++ def test_window_runs_hn_files_in_the_screen_look(self):+ script = (ROOT / 'usr/lib/harness-os/files').read_text()+ self.assertIn('--app-id=harness-files', script)+ self.assertIn('--config=/usr/share/harness-os/foot.ini "$HARNESS_TUI_BIN" files', script)+ subprocess.run(['sh', '-n', ROOT / 'usr/lib/harness-os/files'], check=True)+++class Screenshots(unittest.TestCase):+ def test_print_and_super_keys_capture_without_raising_hn(self):+ keys = bindings()+ for key, mode in [('Print', 'full'), ('S-Print', 'region'), ('W-p', 'full'), ('W-r', 'region')]:+ self.assertEqual(keys[key], [f'/usr/lib/harness-os/screenshot {mode}'], key)+ keyboard = ET.parse(RC).getroot().find('keyboard')+ for bind in keyboard.findall('keybind'):+ if bind.get('key') in {'Print', 'S-Print', 'W-p', 'W-r'}:+ self.assertFalse([q for q in bind.iter('query') if q.get('identifier') == 'hn'])++ def test_capture_tools_are_installed(self):+ packages = (OS / 'packages.x86_64').read_text().split()+ self.assertIn('grim', packages)+ self.assertIn('slurp', packages)+ self.assertRegex((OS / 'packaging/fedora/harness-os-session.spec').read_text(), r'Requires:.*\bgrim, slurp\b')++ def run_script(self, *args, slurp='0,0 10x10', slurp_status=0, grim_status=0):+ with tempfile.TemporaryDirectory() as tmp:+ home, bin_dir = Path(tmp) / 'home', Path(tmp) / 'bin'+ home.mkdir()+ bin_dir.mkdir()+ log = Path(tmp) / 'calls'+ stubs = {+ 'grim': f'echo "grim $*" >>{log}; for a; do last=$a; done; [ {grim_status} = 0 ] && printf PNG >"$last"; exit {grim_status}',+ 'slurp': f'echo slurp >>{log}; echo "{slurp}"; exit {slurp_status}',+ 'wl-copy': f'echo "wl-copy $*" >>{log}; cat >/dev/null',+ 'hn': f'echo "hn $*" >>{log}',+ }+ for name, body in stubs.items():+ path = bin_dir / name+ path.write_text('#!/bin/sh\n' + body + '\n')+ path.chmod(path.stat().st_mode | stat.S_IEXEC)+ env = {'PATH': f'{bin_dir}:/usr/bin:/bin', 'HOME': str(home)}+ result = subprocess.run(['sh', SCREENSHOT, *args], env=env, capture_output=True, text=True)+ calls = log.read_text() if log.exists() else ''+ shots = sorted((home / 'Pictures/Screenshots').glob('*.png')) if (home / 'Pictures').exists() else []+ return result.returncode, calls, [p.name for p in shots]++ def test_full_screen_is_saved_copied_and_announced(self):+ code, calls, shots = self.run_script('full')+ self.assertEqual(code, 0)+ self.assertEqual(len(shots), 1)+ self.assertRegex(shots[0], r'^Screenshot-\d{4}-\d\d-\d\d_\d\d-\d\d-\d\d\.png$')+ self.assertIn('wl-copy --type image/png', calls)+ self.assertRegex(calls, r'hn display-message Screenshot saved to ~/Pictures/Screenshots/\S+ and copied')+ self.assertNotIn('slurp', calls)++ def test_region_passes_the_selection_to_grim(self):+ code, calls, shots = self.run_script('region', slurp='5,6 70x80')+ self.assertEqual(code, 0)+ self.assertIn('grim -g 5,6 70x80 ', calls)+ self.assertEqual(len(shots), 1)++ def test_cancelled_selection_saves_and_says_nothing(self):+ code, calls, shots = self.run_script('region', slurp='', slurp_status=1)+ self.assertEqual(code, 0)+ self.assertEqual(shots, [])+ self.assertNotIn('grim', calls)+ self.assertNotIn('display-message', calls)++ def test_failed_capture_is_reported(self):+ code, calls, _ = self.run_script('full', grim_status=1)+ self.assertEqual(code, 1)+ self.assertIn('hn display-message Screenshot failed', calls)+ self.assertNotIn('wl-copy', calls)+++if __name__ == '__main__':+ unittest.main()diff --git a/os/tools/fedora_payload.py b/os/tools/fedora_payload.pyindex 20d07f4df..d0ddeba92 100644--- a/os/tools/fedora_payload.py+++ b/os/tools/fedora_payload.py@@ -48,9 +48,10 @@ def stage(source, runtime, destination, commit, runtime_commit):paths = ['usr/bin/hn', 'usr/bin/harness', 'usr/bin/hn-browser','usr/share/harness-os/foot.ini', 'usr/share/harness-os/tmux.conf',+ 'usr/share/harness-os/lock/layout.ui', 'usr/share/harness-os/lock/style.css',*['usr/share/harness-os/labwc/' + name for name in ['autostart', 'shutdown', 'rc.xml']],*['usr/lib/harness-os/' + name for name in- ['session', 'session-settings.py', 'runtime-path', 'wait-runtime', 'virtio-2d', 'open-wifi', 'open-updates']],+ ['session', 'session-settings.py', 'runtime-path', 'wait-runtime', 'virtio-2d', 'open-wifi', 'open-updates', 'screenshot', 'lock', 'files']],*['usr/lib/systemd/user/' + name for name in['hn-screen.service', 'harness-daemon.service', 'harness-idle.service','harness-update.service', 'harness-update.timer']],