mirror of
https://github.com/saphid/frame-control.git
synced 2026-10-24 05:01:40 +02:00
Compare commits
6
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
26206e85b4 | ||
|
|
f4efefa958 | ||
|
|
8f245cede7 | ||
|
|
359407bd06 | ||
|
|
810ef1822d | ||
|
|
3dd8e982a3 |
No files matched your search
@@ -63,17 +63,17 @@ About 4,500 F-Droid apps rated for the Frame. One click installs each as its own
|
||||
<tr>
|
||||
<td valign="top">
|
||||
|
||||
**📁 Files, games and clipboard**<br>
|
||||
Drag files onto the window to send them. Drop a game's .zip, folder or .exe to add it to the Steam library, with Proton or the Linux runtime picked for you. Send text or your clipboard straight to the headset's desktop.
|
||||
**📁 Files and games**<br>
|
||||
Drag files onto the window to send them. Drop a game's .zip, folder or .exe to add it to the Steam library, with Proton or the Linux runtime picked for you.
|
||||
|
||||
</td>
|
||||
<td valign="top">
|
||||
|
||||
**📸 Screenshots and recordings**<br>
|
||||
Browse the shots you take in the headset and save them to your Pictures folder. Record what the headset shows, with its sound, or export Steam's clips at any length, as .mp4 files in your Videos folder ([not tested on a headset yet](docs/recording.md)).
|
||||
Browse the shots you take in the headset and save them to your Pictures folder, or have new ones and your Steam clips copied over automatically. Record what the headset shows, with its sound, or export Steam's clips at any length, as .mp4 files in your Videos folder ([not tested on a headset yet](docs/recording.md)).
|
||||
|
||||
**⌨️ Keyboard and trackpad**<br>
|
||||
Type and point in the Frame's apps from your computer or phone, through KDE Connect, which Frame Control brings along and sets up on the Frame. Nothing else to install, anywhere.
|
||||
**⌨️ Type on the headset**<br>
|
||||
Type and point in the Frame's apps from your computer or phone, through KDE Connect, which Frame Control brings along and sets up on the Frame. Copy text to the headset's clipboard and back again. Nothing else to install, anywhere. Press T to open it.
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -282,6 +282,12 @@ ipcMain.handle("server:restart", (e) => {
|
||||
if (win && e.sender === win.webContents && e.senderFrame && e.senderFrame.url.startsWith("data:")) restartServer();
|
||||
});
|
||||
ipcMain.handle("clipboard:read", (e) => fromUi(e) ? clipboard.readText() : "");
|
||||
// Text from the headset's clipboard onto this computer's.
|
||||
ipcMain.handle("clipboard:write", (e, text) => {
|
||||
if (!fromUi(e) || typeof text !== "string") return false;
|
||||
clipboard.writeText(text);
|
||||
return true;
|
||||
});
|
||||
ipcMain.handle("preferences:read", (e) => fromUi(e) ? preferences.read() : {});
|
||||
ipcMain.handle("preferences:write", (e, key, value) => fromUi(e) ? preferences.write(key, value) : false);
|
||||
// A PNG or JPEG (a screenshot) onto the clipboard as an image.
|
||||
|
||||
+3
-2
@@ -1,5 +1,5 @@
|
||||
// Lets the page read this computer's clipboard through Electron, so sending it
|
||||
// to the Frame needs no pbpaste, PowerShell, xclip or wl-clipboard. Also tells
|
||||
// Lets the page read and write this computer's clipboard through Electron, so sending
|
||||
// it to the Frame, and copying the Frame's back, needs no pbpaste, PowerShell, xclip or wl-clipboard. Also tells
|
||||
// the page where a dropped file or folder lives, so a folder can be sideloaded
|
||||
// as a title without zipping it (the local server reads it from there).
|
||||
// It can put a screenshot on the clipboard as an image, open Set Up Connection when
|
||||
@@ -17,6 +17,7 @@ contextBridge.exposeInMainWorld("frameApp", {
|
||||
},
|
||||
notify: (message, request) => ipcRenderer.invoke("comfort:notify", message, request),
|
||||
readClipboard: () => ipcRenderer.invoke("clipboard:read"),
|
||||
writeClipboard: (text) => ipcRenderer.invoke("clipboard:write", text),
|
||||
writeImage: (bytes) => ipcRenderer.invoke("clipboard:writeImage", bytes),
|
||||
setUpConnection: () => ipcRenderer.invoke("connection:setup"),
|
||||
restartServer: () => ipcRenderer.invoke("server:restart"), // the "couldn't start" page's Try Again
|
||||
|
||||
@@ -0,0 +1,156 @@
|
||||
# Battery charge limit (80%): research
|
||||
|
||||
**Question:** can Frame Control set an 80% battery charge limit on the Frame
|
||||
over SSH or adb, safely?
|
||||
|
||||
**Verdict: don't build it yet; it needs a headset check.** Valve's supported
|
||||
mechanism (the one Steam's own charge-limit setting uses on the Deck) is not
|
||||
configured for the Frame. The only control the Frame seems to have is a
|
||||
vendor charger attribute that Valve's own charging daemon also manages.
|
||||
Research as of 2026-10-23. **Not tested on a headset.**
|
||||
|
||||
## How Steam does it on other devices
|
||||
|
||||
- Steam's **Settings → Power → Battery Charge Limit** shipped to the Deck in
|
||||
SteamOS 3.7.8 (beta client 2025-05-08)
|
||||
([GamingOnLinux](https://www.gamingonlinux.com/2025/05/steamos-3-7-7-beta-brings-a-battery-charge-limit-option-and-improved-lenovo-legion-go-s-support/)).
|
||||
- Steam calls SteamOS Manager on the session bus:
|
||||
`com.steampowered.SteamOSManager1.BatteryChargeLimit1`, with properties
|
||||
`MaxChargeLevel` (`i`, read/write; `-1` resets to the default) and
|
||||
`SuggestedMinimumLimit` (`i`, read-only). The CLI is
|
||||
`steamosctl get-max-charge-level` / `set-max-charge-level` /
|
||||
`suggested-minimum-charge-limit`. Source: `data/interfaces/com.steampowered.SteamOSManager1.xml`
|
||||
and `steamos-manager/src/bin/steamosctl.rs` in
|
||||
[holo/steamos-manager](https://gitlab.steamos.cloud/holo/steamos-manager),
|
||||
read at commit `83981ab` (2026-10-21).
|
||||
- The root daemon writes the value to sysfs only if the device's TOML in
|
||||
`data/devices/` has a `[battery_charge_limit]` section. Two methods exist
|
||||
(`steamos-manager/src/power.rs`, `BatteryChargeLimitMethod`):
|
||||
- `hwmon_attribute`: the Deck writes `max_battery_charge_level` on
|
||||
`steamdeck_hwmon` (`data/devices/steam-deck.toml`).
|
||||
- `acpi_sb`: ROG Ally, MSI Claw and others write the standard
|
||||
`charge_control_end_threshold` on the ACPI battery
|
||||
(`/sys/bus/{platform,acpi}/drivers/…battery…/PNP0C0A:00/…/power_supply/*/`).
|
||||
On ARM there's no ACPI, so this path can't match there either.
|
||||
- With no `[battery_charge_limit]` section, the interface fails with
|
||||
`UnknownInterface` (Steam can still show its toggle on unsupported hardware:
|
||||
[steam-for-linux#12044](https://github.com/ValveSoftware/steam-for-linux/issues/12044)).
|
||||
|
||||
## What the Frame has
|
||||
|
||||
- **Upstream `data/devices/steam-frame.toml`** (matched by
|
||||
`dt.compatible = "qcom,sm8650"`, variant `Deckard`) configures GPU clocks
|
||||
and performance profiles only. It has **no `[battery_charge_limit]`**, so
|
||||
SteamOS Manager on the Frame has no charge-limit backend. Its git history
|
||||
(2026-09-10 to 2026-10-12) never added one.
|
||||
- **Battery driver:** the Frame's battery is
|
||||
`/sys/class/power_supply/max1720x_bat_7-36`, and the charger is a
|
||||
`tcpm-source-psy-…` USB-PD supply ([how-the-frame-works.md](how-the-frame-works.md)).
|
||||
Both were verified 2026-09-25, and `ui/frame_status.py` `battery()` and
|
||||
`power_source()` read them. The Maxim MAX1720x is a **fuel gauge** and
|
||||
can't control charging. Mainline `drivers/power/supply/max1720x_battery.c`
|
||||
exposes only read-only properties (capacity, voltage, current, temp,
|
||||
charge_full…), with no `charge_control_end_threshold`. Valve's build is
|
||||
patched: it reports `time_to_full_now`, which mainline doesn't have. Even
|
||||
so, a charge stop would have to come from the separate charger IC, not this
|
||||
node.
|
||||
- **Not the qcom_battmgr path.** Some other SM8650/SM8750 handhelds get
|
||||
`charge_control_end_threshold` from Qualcomm's `qcom_battmgr`
|
||||
(pmic_glink) driver, clamped at 55% or above. A third-party distro enabled
|
||||
Steam's limit on those by patching steamos-manager
|
||||
([armada-os/armada#758](https://github.com/armada-os/armada/pull/758)). The
|
||||
Frame's battery isn't exposed by `qcom_battmgr`, so that doesn't carry over.
|
||||
(Unverified: whether a `qcom_battmgr` node also exists on the Frame. The
|
||||
read-only checks below answer this.)
|
||||
- **What third parties found:**
|
||||
[y0usaf/frame-charge](https://github.com/y0usaf/frame-charge) reports that
|
||||
the Frame has no `charge_control_end_threshold` and falls back to a vendor
|
||||
`charging_pause` attribute. It also reports that `constant_charge_current`
|
||||
changes on its own, which it attributes to Valve's `deckard_charge_daemon`
|
||||
(`deckard-charger.service`). By its own README, that tool has only run its
|
||||
read-only `status` on a Frame and has **not** been tested against real
|
||||
charging. Two questions are still open: whether pausing stops the current,
|
||||
and whether Valve's daemon undoes it.
|
||||
|
||||
## Why not build it now
|
||||
|
||||
- **No supported endpoint.** The only Valve-supported interface,
|
||||
`BatteryChargeLimit1`, isn't backed on the Frame. Writing sysfs ourselves
|
||||
would bypass Steam and SteamOS Manager, and it needs root (`sudo -S` with
|
||||
the user's password).
|
||||
- **A rival owner.** Valve's charge daemon already adjusts charging
|
||||
parameters. Toggling `charging_pause` underneath it could be undone without
|
||||
warning, fight it in a loop, or leave charging paused.
|
||||
- **Stuck at a low charge.** If the app or the Frame dies while charging is
|
||||
paused, the Frame could sit at a low charge on the charger. Whether a
|
||||
reboot clears `charging_pause` is unknown.
|
||||
- **The UI would mislead.** Steam's setting (if it shows at all) wouldn't
|
||||
reflect our limit.
|
||||
- **adb doesn't help.** Wi-Fi adb (`frame:5555`) reaches the Lepton Android
|
||||
container only. USB-C adb reaches the Linux side as `steamos` (non-root, the
|
||||
same as SSH, [ssh.md](ssh.md)). Neither adds a charging-control route.
|
||||
Android's `dumpsys battery` in Lepton is a container view, not the hardware.
|
||||
|
||||
**Revisit when** a SteamOS update adds `[battery_charge_limit]` to
|
||||
`steam-frame.toml` (or `steamosctl get-max-charge-level` stops returning
|
||||
`UnknownInterface` on the Frame). Then the feature is just a SteamOS Manager
|
||||
call:
|
||||
|
||||
- Read: `steamosctl get-max-charge-level`
|
||||
- Set: `steamosctl set-max-charge-level 80`
|
||||
- Undo: `steamosctl set-max-charge-level -- -1`
|
||||
|
||||
That runs as `steamos` with no sudo. It's the same value Steam's own
|
||||
Settings → Power shows, so both stay in sync.
|
||||
|
||||
## Headset checks (read-only first)
|
||||
|
||||
Run these over SSH as `steamos`. Steps 1–4 only read.
|
||||
|
||||
```sh
|
||||
# 1. Does SteamOS Manager offer the interface on this build?
|
||||
steamosctl get-max-charge-level; steamosctl suggested-minimum-charge-limit
|
||||
busctl --user introspect com.steampowered.SteamOSManager1 \
|
||||
/com/steampowered/SteamOSManager1 | grep -i -A3 ChargeLimit
|
||||
grep -n battery_charge_limit /usr/share/steamos-manager/devices/*frame* 2>/dev/null
|
||||
|
||||
# 2. Which power supplies exist, and which drivers back them?
|
||||
for d in /sys/class/power_supply/*; do
|
||||
echo "== $d ($(cat $d/type)) driver=$(basename "$(readlink -f $d/device/driver)" 2>/dev/null)"
|
||||
ls $d
|
||||
done
|
||||
|
||||
# 3. Any charge-control attributes, with their values and permissions?
|
||||
ls -l /sys/class/power_supply/*/{charge_control_*,charging_pause,charging_enable,constant_charge_current*,charge_behaviour} 2>/dev/null
|
||||
grep -H . /sys/class/power_supply/*/{charge_control_*,charging_pause,charging_enable,constant_charge_current*,charge_behaviour} 2>/dev/null
|
||||
|
||||
# 4. What is Valve's charger daemon, and what does it touch?
|
||||
systemctl status deckard-charger.service --no-pager
|
||||
systemctl cat deckard-charger.service
|
||||
journalctl -b -u deckard-charger.service --no-pager | tail -50
|
||||
```
|
||||
|
||||
If step 1 succeeds on some build, test `steamosctl set-max-charge-level 80`
|
||||
on a charger at a charge above 80%. Watch `current_now` on the
|
||||
`max1720x_bat_*` node fall to about 0, then `steamosctl set-max-charge-level -- -1` and
|
||||
confirm charging resumes. Do this on a supervised Frame only. If only step 3
|
||||
finds a vendor attribute, **stop**: don't write it, and leave the question
|
||||
with Valve.
|
||||
|
||||
## Sources
|
||||
|
||||
- steamos-manager source, commit `83981ab` (2026-10-21):
|
||||
`data/devices/steam-frame.toml`, `data/devices/steam-deck.toml`,
|
||||
`data/interfaces/com.steampowered.SteamOSManager1.xml`,
|
||||
`steamos-manager/src/power.rs`, `steamos-manager/src/manager/user.rs`.
|
||||
[gitlab.steamos.cloud/holo/steamos-manager](https://gitlab.steamos.cloud/holo/steamos-manager)
|
||||
- Mainline [`max1720x_battery.c`](https://github.com/torvalds/linux/blob/master/drivers/power/supply/max1720x_battery.c)
|
||||
- [ValveSoftware/steam-for-linux#12044](https://github.com/ValveSoftware/steam-for-linux/issues/12044):
|
||||
the Steam toggle shows on unsupported hardware
|
||||
- [armada-os/armada#758](https://github.com/armada-os/armada/pull/758):
|
||||
`qcom_battmgr` threshold on other SM8650/SM8750 devices
|
||||
- [y0usaf/frame-charge](https://github.com/y0usaf/frame-charge): third-party,
|
||||
untested on real charging
|
||||
- [GamingOnLinux: SteamOS 3.7.7 beta charge limit](https://www.gamingonlinux.com/2025/05/steamos-3-7-7-beta-brings-a-battery-charge-limit-option-and-improved-lenovo-legion-go-s-support/)
|
||||
- Repo: [how-the-frame-works.md](how-the-frame-works.md) (battery and
|
||||
charger nodes), [ssh.md](ssh.md) (adb scope), `ui/frame_status.py`
|
||||
@@ -15,6 +15,10 @@ depends on SSH working through the `frame` alias from `scripts/connect.sh`.
|
||||
| KDE Connect | KDE Connect on both | Guess | There's a macOS build of KDE Connect, but whether it's present or installable on the Frame wasn't confirmed. It would give you clipboard sync, file send, and remote input. Worth checking on-device. |
|
||||
| microSD | Physical card | Confirmed that the slot exists ([Wikipedia](https://en.wikipedia.org/wiki/Steam_Frame)) | Offline fallback. |
|
||||
|
||||
Screenshots and Steam clips have their own buttons on **Tools → Capture &
|
||||
Live**, and **Settings → Copy to this computer** copies new ones here
|
||||
automatically: see [recording.md](recording.md#copying-new-ones-automatically).
|
||||
|
||||
## Clipboard
|
||||
|
||||
`scripts/paste-to-frame.sh` sends the Mac clipboard (or stdin) to the
|
||||
@@ -36,3 +40,28 @@ desktop has to be running in the headset. It's text only, and pastes over about
|
||||
|
||||
A simpler fallback: `ssh frame 'cat > ~/clip.txt'` < file, then open it in the
|
||||
headset.
|
||||
|
||||
### In Frame Control
|
||||
|
||||
**Tools → Type on the headset** (also on Home, and press `T` anywhere) has the
|
||||
clipboard next to the keyboard and trackpad, both ways:
|
||||
|
||||
- **Send text** or **Send this computer's clipboard** puts text on the headset's
|
||||
clipboard, as above.
|
||||
- **Copy the headset's clipboard** brings it back: copy something in a desktop
|
||||
app on the Frame, then press it, and paste on your computer. It calls
|
||||
Klipper's `getClipboardContents` on the same D-Bus bus, and sends the text
|
||||
back as base64, so accents, emoji and line breaks arrive unchanged. The
|
||||
desktop app and the iPhone app put it on their own clipboard. With the server
|
||||
in a browser, the server sets the clipboard of the computer it runs on:
|
||||
`pbcopy` on macOS, PowerShell's `Set-Clipboard` (or `clip.exe`) on Windows,
|
||||
`wl-copy`, `xclip` or `xsel` on Linux.
|
||||
|
||||
It's text only, and copying back takes up to 1 MB; a bigger clipboard is
|
||||
refused with a message, so send big things as a file. An empty clipboard, or
|
||||
one holding an image, says so. Neither the server nor its log ever records what
|
||||
was on the clipboard.
|
||||
|
||||
**Not tested on a headset yet.** Reading uses the same Klipper interface as
|
||||
sending, which was verified on 2026-09-25, but `getClipboardContents` itself
|
||||
hasn't been tried on a Frame. The fake Frame (`tests/fakeframe`) answers it.
|
||||
+11
-5
@@ -25,7 +25,7 @@ settings, reports), **Tools** (in the headset: your computer's windows, the medi
|
||||
player and the panel switcher; then sending files and text, Flatpaks, remote and
|
||||
power), **Devices** (your headsets and their addresses), and **Control** (the
|
||||
searchable Control Center, metrics, supported settings and headset guidance).
|
||||
Keys 1–6 switch between them. The gear in the header (key 7) opens **Settings**:
|
||||
Keys 1–6 switch between them, and `T` opens Type on the headset. The gear in the header (key 7) opens **Settings**:
|
||||
privacy and updates, library artwork and the assistant. The battery chip opens
|
||||
the headset's details: storage, memory, temperature, Wi-Fi, uptime and SteamOS
|
||||
build. Files can be dropped anywhere in the window. A
|
||||
@@ -84,8 +84,14 @@ counts them while they run.
|
||||
their own Android app. A game's `.zip`, folder or `.exe` becomes a title in
|
||||
the Steam library (Valve's Devkit Game path, with Proton or the Steam Linux
|
||||
Runtime picked from the program's header), listed under **Sideloaded titles**
|
||||
with Launch and Remove; see [sideloading.md](sideloading.md). Send typed text, or your computer's clipboard, to the
|
||||
Frame clipboard.
|
||||
with Launch and Remove; see [sideloading.md](sideloading.md).
|
||||
- **Type on the headset** (on Home, in Tools, in the Control Center, or press
|
||||
`T`): use your computer's keyboard and mouse, or a phone's touchscreen, in the
|
||||
Frame's apps through KDE Connect, and move clipboard text both ways. Send
|
||||
typed text or your computer's clipboard to the headset, or copy the headset's
|
||||
clipboard back: copy in a desktop app on the Frame, then **Copy the headset's
|
||||
clipboard**. The clipboard needs the desktop panel open in the headset; it's
|
||||
text only, up to 1 MB. See [file-transfer.md](file-transfer.md#clipboard).
|
||||
- **Mac in the headset** (macOS): show any Mac window, or a whole screen, as
|
||||
its own panel in the headset. Place it with the SteamVR dashboard, click and
|
||||
scroll with the laser, and type on the Mac. Streams hardware H.264 through
|
||||
@@ -224,8 +230,8 @@ Google publishes no arm64 Linux platform-tools. Set Up Connection runs
|
||||
`ui/frame_connect.py` in your terminal emulator (GNOME Terminal, Konsole, xterm
|
||||
and others). The log is at
|
||||
`~/.config/Frame Control/logs/server.log`. Running `ui/server.py` in a browser
|
||||
instead of the app, sending the clipboard needs `wl-clipboard` (Wayland) or
|
||||
`xclip` (X11).
|
||||
instead of the app, sending the clipboard, or copying the headset's to this
|
||||
computer, needs `wl-clipboard` (Wayland), `xclip` or `xsel` (X11).
|
||||
|
||||
## Building
|
||||
|
||||
|
||||
+3
-2
@@ -102,8 +102,9 @@ app installed opens its App Store page.
|
||||
Things iOS asks the first time: **Local Network** (tap Allow, or the app can't
|
||||
see the Frame), and **Paste** when you send the iPhone's clipboard (tap Allow
|
||||
Paste, or set Settings → Apps → Frame Control → Paste from Other Apps → Allow).
|
||||
Sending text to the Frame's clipboard needs the desktop panel open in the
|
||||
headset, as on the desktop app.
|
||||
Sending text to the Frame's clipboard, or copying the Frame's to the phone
|
||||
(**Type on the headset → Copy the headset's clipboard**), needs the desktop
|
||||
panel open in the headset, as on the desktop app.
|
||||
|
||||
Not yet exercised: Android display changes through podman (no Android app was
|
||||
running), a real sleep/restart/shut down on the Frame, and a physical iPhone.
|
||||
|
||||
@@ -143,6 +143,15 @@ check in the headset:
|
||||
- Keys from SteamVR's on-screen keyboard.
|
||||
- Whether Flathub Chromium decodes H.264 (otherwise use Compatible).
|
||||
|
||||
## Battery charge limit (2026-10-23)
|
||||
|
||||
Can an 80% charge limit be set over SSH or adb? **Not safely yet.** SteamOS
|
||||
Manager's `BatteryChargeLimit1` (the interface Steam's own setting uses) has
|
||||
no backend in the Frame's device config, and the battery node is a
|
||||
`max1720x` fuel gauge with no `charge_control_end_threshold`. Research and
|
||||
read-only headset checks are in [charge-limit.md](charge-limit.md). Not tested
|
||||
on a headset.
|
||||
|
||||
## Unconfirmed claims made in these docs
|
||||
|
||||
- `/home` and `/etc` persist across Frame OS updates. This is inferred from
|
||||
|
||||
@@ -287,3 +287,12 @@ then every 6 hours: the latest release's `update.json` on GitHub, or
|
||||
`api.github.com/repos/saphid/frame-control/releases/latest` if that fails.
|
||||
Those requests carry no id. To stop it, set
|
||||
`FRAME_CONTROL_NO_UPDATE_CHECK=1`. See [releasing.md](releasing.md).
|
||||
|
||||
## Screenshots and clips
|
||||
|
||||
Copying screenshots and Steam clips to your computer, by hand or with
|
||||
**Settings → Copy to this computer**, goes straight from the headset to your
|
||||
computer over the same SSH connection as everything else. Nothing is uploaded
|
||||
anywhere. What automatic copying has copied is listed, by file id, in
|
||||
`auto-sync.json` in Frame Control's data folder; see
|
||||
[recording.md](recording.md#copying-new-ones-automatically).
|
||||
+41
-3
@@ -74,10 +74,42 @@ The listing doesn't rely on the folder names: any folder under `clips/` or
|
||||
missing its init segment or its chunks is left out. Missing chunk numbers are
|
||||
shown as "pieces missing"; the rest still exports.
|
||||
|
||||
## Copying new ones automatically
|
||||
|
||||
**Settings → Copy to this computer** copies new screenshots and Steam clips
|
||||
here on their own. It's off until you turn it on, with a switch each for
|
||||
screenshots and Steam clips. While a headset is connected, Frame Control looks
|
||||
about once a minute and copies what's new with the same code as **Save** and
|
||||
**Export**: screenshots to `~/Pictures/SteamFrame`, clips to
|
||||
`~/Videos/SteamFrame`.
|
||||
|
||||
- **Only what's new.** It copies what you take after turning it on, so the
|
||||
shots and clips already on the headset don't all arrive at once. **Copy
|
||||
everything now** copies everything that isn't on this computer yet, once.
|
||||
- **Deleted stays deleted.** What it has copied is remembered, per headset, in
|
||||
`auto-sync.json` in Frame Control's data folder, so a file you delete here
|
||||
isn't copied again (**Copy everything now** would bring it back).
|
||||
- **Saved clips only.** Steam's background recording is a rolling buffer, not
|
||||
something you chose to keep, so it isn't copied; export it by hand. A clip
|
||||
Steam wrote to in the last 30 seconds is still being saved and waits for the
|
||||
next look.
|
||||
- **It gives way.** It waits while an install, an export, a recording or
|
||||
anything else is running on the headset, and stops between files if one
|
||||
starts. While a copy is running, switching headsets waits for it, as it does
|
||||
for an export. When the headset can't be reached it waits longer each time,
|
||||
up to 15 minutes, and starts over once it answers.
|
||||
- **When this computer is full** (under 512 MB free, or a copy runs out of
|
||||
space) it pauses and says so in Settings and above the lists. Free some space
|
||||
and press **Resume**.
|
||||
- **With several headsets** it copies from the one you're connected to.
|
||||
|
||||
Settings shows when it last checked, how many files it last copied and when,
|
||||
and the last problem it had. The screenshot and clip lists say when it's on.
|
||||
|
||||
## For developers
|
||||
|
||||
`ui/frame_clips.py` holds the logic, so other features (such as syncing clips
|
||||
automatically) can reuse it:
|
||||
`ui/frame_clips.py` holds the logic, so other features can reuse it (automatic
|
||||
copying, in `ui/frame_autosync.py`, does):
|
||||
|
||||
- `list_clips(run_frame)` and `export_clip(id, run_frame, run, fetch)` are the
|
||||
computer's side; the server passes how to reach the Frame.
|
||||
@@ -96,11 +128,15 @@ The API, with the same guards as every other request:
|
||||
| `GET /api/clips` | Steam's recordings on the Frame, each with `saved` |
|
||||
| `POST /api/clips/export {"id"}` | Starts an export; poll `/api/job` |
|
||||
| `POST /api/open {"what": "videos"}` | Opens `~/Videos/SteamFrame` |
|
||||
| `GET /api/autosync` | Automatic copying: `screenshots`, `clips`, `since` (the watermark), `checked`, `copied`, `copied_time`, `error`, `paused`, `waiting` (clips still being written) |
|
||||
| `POST /api/autosync {"action": "settings", "screenshots", "clips"}` | Turn either on or off; turning it on sets `since` to now |
|
||||
| `POST /api/autosync {"action": "now"\|"resume"}` | Copy everything not here yet, once; or resume after running out of space |
|
||||
|
||||
They aren't available when the server runs on the Frame itself (the iPhone
|
||||
app), since they save to a computer.
|
||||
|
||||
Tests: `tests/test_clips.py`. They run the recording's shell under bash with a
|
||||
Tests: `tests/test_clips.py`, and `tests/test_autosync.py` for automatic
|
||||
copying (with a fake headset). They run the recording's shell under bash with a
|
||||
stand-in `ffmpeg`, so Stop, the time limit and the clean-up are tested as they
|
||||
run on the Frame. Where `ffmpeg` is installed, they also make a 65-second DASH
|
||||
recording with Steam's file names and export it with the real `ffmpeg`.
|
||||
@@ -118,3 +154,5 @@ None of this has run on a Steam Frame yet. In particular:
|
||||
whether a clip's segments start mid-recording. The parser is deliberately
|
||||
loose about the layout.
|
||||
- How much x264 at 1080p30 costs the Frame while a game is running.
|
||||
- Automatic copying: that 30 seconds without a write is a safe sign Steam has
|
||||
finished saving a clip, and how a once-a-minute listing feels on the Frame.
|
||||
+1
-1
@@ -144,7 +144,7 @@ capture it.
|
||||
|
||||
## Input: type and point in the Frame from the Mac or iPhone
|
||||
|
||||
**Built: Home → Keyboard and trackpad**, in every version of Frame Control
|
||||
**Built: Home → Type on the headset** (or press `T`), in every version of Frame Control
|
||||
(Mac, Windows, Linux, iPhone and iPad), with nothing to install on the device
|
||||
you're holding. On a phone the panel is a trackpad (drag to move, tap to click,
|
||||
two fingers to scroll, two-finger tap to right-click) plus a text field that
|
||||
|
||||
@@ -55,6 +55,7 @@ struct WebShell: UIViewRepresentable {
|
||||
},
|
||||
notify: (message, request) => call("notify", { message, request }),
|
||||
readClipboard: () => call("readClipboard"),
|
||||
writeClipboard: (text) => call("writeClipboard", text),
|
||||
setUpConnection: () => call("setUpConnection"),
|
||||
open: (what) => call("open", what),
|
||||
saveImages: (images) => call("saveImages", images),
|
||||
@@ -143,6 +144,10 @@ struct WebShell: UIViewRepresentable {
|
||||
replyHandler(true, nil)
|
||||
case "readClipboard":
|
||||
replyHandler(UIPasteboard.general.string ?? "", nil)
|
||||
case "writeClipboard":
|
||||
guard let text = arg as? String else { return replyHandler(nil, "Expected text") }
|
||||
UIPasteboard.general.string = text
|
||||
replyHandler(true, nil)
|
||||
case "setUpConnection":
|
||||
model.showSetup()
|
||||
replyHandler(nil, nil)
|
||||
|
||||
@@ -45,6 +45,13 @@ class Device(harness.FrameTestCase):
|
||||
self.assertRegex(out['message'], r'^copied via Klipper \(\d+ chars\)$')
|
||||
self.assertEqual(state()['clipboard'], [text])
|
||||
|
||||
def test_clipboard_comes_back_from_klipper(self):
|
||||
text = 'from the headset: 世界 🎧\n\nwith trailing newlines\n\n'
|
||||
ok('POST', '/api/clipboard', {'text': text})
|
||||
out = ok('POST', '/api/clipboard', {'read': True})
|
||||
self.assertEqual(out['text'], text)
|
||||
self.assertRegex(out['message'], r"^Copied \d+ characters from the headset's clipboard$")
|
||||
|
||||
def test_flatpak_install_and_remove(self):
|
||||
# Installs run as background jobs (server.start_job); uninstall answers at once.
|
||||
job = finished(ok('POST', '/api/flatpak', {'id': 'org.videolan.VLC', 'action': 'install'}))
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Stub for qdbus6: records Klipper setClipboardContents calls, the way
|
||||
Frame Control sends text to the headset desktop's clipboard (server.PASTE,
|
||||
verified 2026-09-25)."""
|
||||
verified 2026-09-25), and answers getClipboardContents with the last one
|
||||
(server.COPY). Printing the string and a newline is how qdbus prints a
|
||||
returned QString; getClipboardContents itself is a guess, not seen on a headset."""
|
||||
import os
|
||||
import sys
|
||||
|
||||
@@ -15,5 +17,10 @@ if args[:3] == ['org.kde.klipper', '/klipper', 'org.kde.klipper.klipper.setClipb
|
||||
sys.exit('Could not connect to D-Bus server')
|
||||
with fs.update() as s:
|
||||
s['clipboard'].append(args[3])
|
||||
elif args == ['org.kde.klipper', '/klipper', 'org.kde.klipper.klipper.getClipboardContents']:
|
||||
if not os.environ.get('DBUS_SESSION_BUS_ADDRESS'):
|
||||
sys.exit('Could not connect to D-Bus server')
|
||||
clips = fs.read()['clipboard']
|
||||
sys.stdout.buffer.write((clips[-1] if clips else '').encode() + b'\n')
|
||||
else:
|
||||
sys.exit(f'qdbus6 stub: unsupported {args}')
|
||||
@@ -0,0 +1,291 @@
|
||||
"""Copying new screenshots and clips to the computer on their own (ui/frame_autosync.py).
|
||||
|
||||
The headset is a fake: lists of shots and clips, and save/export functions that
|
||||
record what they were asked to copy. No SSH, no headset.
|
||||
"""
|
||||
import sandbox # noqa: F401 (first: keeps tests off real data and services)
|
||||
import errno
|
||||
import json
|
||||
import shutil
|
||||
import sys
|
||||
import tempfile
|
||||
import threading
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "ui"))
|
||||
import frame_autosync as fa # noqa: E402
|
||||
|
||||
NOW = 1_800_000_000.0
|
||||
GB = 1024**3
|
||||
|
||||
|
||||
def shot(n, t, saved=False):
|
||||
return {"id": f"1/620/20261020{n:06d}_1.jpg", "time": t, "saved": saved}
|
||||
|
||||
|
||||
def clip(n, t, idle=600, kind="clip", saved=False):
|
||||
return {"id": f"1/clips/clip_620_{n}/video/bg", "kind": kind, "time": t, "idle": idle, "saved": saved}
|
||||
|
||||
|
||||
class FakeFrame:
|
||||
def __init__(self):
|
||||
self.shots, self.clips = [], []
|
||||
self.saved, self.exported, self.calls = [], [], []
|
||||
self.device, self.busy, self.down = "frame-a", False, False
|
||||
self.save_error = self.export_error = None
|
||||
|
||||
def list_shots(self):
|
||||
self.calls.append("list_shots")
|
||||
if self.down:
|
||||
raise RuntimeError("ssh: connect to host frame port 22: Connection timed out")
|
||||
return {"shots": list(self.shots)}
|
||||
|
||||
def list_clips(self):
|
||||
self.calls.append("list_clips")
|
||||
if self.down:
|
||||
raise RuntimeError("ssh: connect to host frame port 22: Connection timed out")
|
||||
return {"clips": list(self.clips)}
|
||||
|
||||
def save_shots(self, device, ids):
|
||||
self.calls.append("save_shots")
|
||||
if self.save_error:
|
||||
raise self.save_error
|
||||
self.saved.append((device, list(ids)))
|
||||
for s in self.shots:
|
||||
if s["id"] in ids:
|
||||
s["saved"] = True
|
||||
|
||||
def export_clip(self, device, clip_id):
|
||||
self.calls.append("export_clip")
|
||||
if self.export_error:
|
||||
raise self.export_error
|
||||
self.exported.append((device, clip_id))
|
||||
for c in self.clips:
|
||||
if c["id"] == clip_id:
|
||||
c["saved"] = True
|
||||
|
||||
|
||||
class AutoSyncTest(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.dir = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, self.dir, ignore_errors=True)
|
||||
self.frame = FakeFrame()
|
||||
self.now = [NOW]
|
||||
self.free = [100 * GB]
|
||||
self.sync = self.make()
|
||||
|
||||
def make(self):
|
||||
f = self.frame
|
||||
return fa.AutoSync(f.list_shots, f.save_shots, f.list_clips, f.export_clip,
|
||||
lambda: f.device, lambda: f.busy,
|
||||
offline=lambda e: "The Frame isn't answering." if "timed out" in str(e) else None,
|
||||
shots_folder=self.dir / "Pictures", clips_folder=self.dir / "Videos",
|
||||
path=self.dir / "auto-sync.json", clock=lambda: self.now[0],
|
||||
space=lambda folder: self.free[0])
|
||||
|
||||
def test_off_by_default_and_does_nothing(self):
|
||||
self.frame.shots = [shot(1, NOW + 10)]
|
||||
self.frame.clips = [clip(1, NOW + 10)]
|
||||
s = self.sync.state()
|
||||
self.assertFalse(s["screenshots"] or s["clips"])
|
||||
self.assertEqual(self.sync.tick(), fa.INTERVAL)
|
||||
self.assertEqual(self.frame.calls, []) # not even a listing
|
||||
self.assertFalse((self.dir / "auto-sync.json").exists())
|
||||
|
||||
def test_settings_persist(self):
|
||||
self.sync.update({"screenshots": True})
|
||||
again = self.make().state()
|
||||
self.assertTrue(again["screenshots"])
|
||||
self.assertFalse(again["clips"])
|
||||
self.assertEqual(again["since"], NOW)
|
||||
saved = json.loads((self.dir / "auto-sync.json").read_text())
|
||||
self.assertEqual((saved["screenshots"], saved["clips"]), (True, False))
|
||||
|
||||
def test_only_what_is_newer_than_turning_it_on(self):
|
||||
self.frame.shots = [shot(1, NOW - 3600), shot(2, NOW + 5), shot(3, NOW + 50, saved=True)]
|
||||
self.frame.clips = [clip(1, NOW - 3600), clip(2, NOW + 5)]
|
||||
self.sync.update({"screenshots": True, "clips": True})
|
||||
self.assertEqual(self.sync.tick(), fa.INTERVAL)
|
||||
self.assertEqual(self.frame.saved, [("frame-a", [shot(2, 0)["id"]])])
|
||||
self.assertEqual(self.frame.exported, [("frame-a", clip(2, 0)["id"])])
|
||||
s = self.sync.state()
|
||||
self.assertEqual((s["copied"], s["copied_time"], s["checked"], s["error"]), (2, NOW, NOW, None))
|
||||
|
||||
def test_watermark_moves_when_turned_off_and_on_again(self):
|
||||
self.sync.update({"screenshots": True})
|
||||
self.now[0] += 1000
|
||||
self.sync.update({"clips": True}) # already on: the watermark stays
|
||||
self.assertEqual(self.sync.state()["since"], NOW)
|
||||
self.sync.update({"screenshots": False, "clips": False})
|
||||
self.sync.update({"screenshots": True})
|
||||
self.assertEqual(self.sync.state()["since"], NOW + 1000)
|
||||
|
||||
def test_copy_everything_now_once(self):
|
||||
self.frame.shots = [shot(1, NOW - 3600), shot(2, NOW - 60)]
|
||||
self.frame.clips = [clip(1, NOW - 3600), clip(2, NOW - 60, kind="background")]
|
||||
self.sync.copy_all() # works with the toggles off too
|
||||
self.assertTrue(self.sync.state()["pending"])
|
||||
self.sync.tick()
|
||||
self.assertEqual(self.frame.saved, [("frame-a", [shot(1, 0)["id"], shot(2, 0)["id"]])])
|
||||
self.assertEqual(self.frame.exported, [("frame-a", clip(1, 0)["id"])]) # never the background recording
|
||||
self.assertFalse(self.sync.state()["pending"])
|
||||
self.frame.calls.clear()
|
||||
self.sync.tick()
|
||||
self.assertEqual(self.frame.calls, []) # off again afterwards
|
||||
|
||||
def test_not_copied_again_after_deleting_it_here(self):
|
||||
self.sync.update({"screenshots": True, "clips": True})
|
||||
self.frame.shots = [shot(1, NOW + 5)]
|
||||
self.frame.clips = [clip(1, NOW + 5)]
|
||||
self.sync.tick()
|
||||
for s in self.frame.shots + self.frame.clips:
|
||||
s["saved"] = False # the person deleted the files
|
||||
self.frame.saved.clear()
|
||||
self.frame.exported.clear()
|
||||
self.make().tick() # remembered across restarts too
|
||||
self.assertEqual((self.frame.saved, self.frame.exported), ([], []))
|
||||
|
||||
def test_saved_by_hand_counts_as_copied(self):
|
||||
self.sync.update({"screenshots": True})
|
||||
self.frame.shots = [shot(1, NOW + 5, saved=True)]
|
||||
self.sync.tick()
|
||||
self.frame.shots[0]["saved"] = False
|
||||
self.sync.tick()
|
||||
self.assertEqual(self.frame.saved, [])
|
||||
|
||||
def test_remembered_per_headset(self):
|
||||
self.sync.update({"screenshots": True})
|
||||
self.frame.shots = [shot(1, NOW + 5)]
|
||||
self.sync.tick()
|
||||
self.frame.device = "frame-b"
|
||||
self.frame.shots = [shot(1, NOW + 5)] # the same name on another headset
|
||||
self.sync.tick()
|
||||
self.assertEqual([d for d, _ in self.frame.saved], ["frame-a", "frame-b"])
|
||||
|
||||
def test_clip_still_being_recorded_waits(self):
|
||||
self.sync.update({"clips": True})
|
||||
self.frame.clips = [clip(1, NOW + 5, idle=4), clip(2, NOW + 6, idle=None)]
|
||||
self.sync.tick()
|
||||
self.assertEqual(self.frame.exported, [])
|
||||
self.assertEqual(self.sync.state()["waiting"], 2)
|
||||
self.frame.clips[0]["idle"] = fa.SETTLE + 1
|
||||
self.sync.tick()
|
||||
self.assertEqual(self.frame.exported, [("frame-a", clip(1, 0)["id"])])
|
||||
self.assertEqual(self.sync.state()["waiting"], 1)
|
||||
|
||||
def test_no_headset_no_work(self):
|
||||
self.sync.update({"screenshots": True, "clips": True})
|
||||
self.frame.device = None
|
||||
self.assertEqual(self.sync.tick(), fa.INTERVAL)
|
||||
self.assertEqual(self.frame.calls, [])
|
||||
|
||||
def test_waits_for_other_work(self):
|
||||
self.sync.update({"screenshots": True, "clips": True})
|
||||
self.frame.shots = [shot(1, NOW + 5)]
|
||||
self.frame.busy = True
|
||||
self.assertEqual(self.sync.tick(), fa.BUSY_WAIT)
|
||||
self.assertEqual(self.frame.calls, [])
|
||||
self.frame.busy = False
|
||||
self.sync.tick()
|
||||
self.assertEqual(len(self.frame.saved), 1)
|
||||
|
||||
def test_stops_between_items_when_other_work_starts(self):
|
||||
self.sync.update({"clips": True})
|
||||
self.frame.clips = [clip(1, NOW + 5), clip(2, NOW + 6)]
|
||||
export = self.frame.export_clip
|
||||
|
||||
def then_busy(device, clip_id):
|
||||
export(device, clip_id)
|
||||
self.frame.busy = True # an install started meanwhile
|
||||
self.frame.export_clip = then_busy
|
||||
sync = self.make()
|
||||
self.assertEqual(sync.tick(), fa.BUSY_WAIT)
|
||||
self.assertEqual(len(self.frame.exported), 1)
|
||||
|
||||
def test_backs_off_while_unreachable(self):
|
||||
self.sync.update({"screenshots": True})
|
||||
self.frame.down = True
|
||||
waits = [self.sync.tick() for _ in range(6)]
|
||||
self.assertEqual(waits[:4], [120, 240, 480, 900])
|
||||
self.assertEqual(waits[-1], fa.MAX_BACKOFF)
|
||||
self.assertEqual(self.sync.state()["error"], "The Frame isn't answering.")
|
||||
self.frame.down = False
|
||||
self.assertEqual(self.sync.tick(), fa.INTERVAL)
|
||||
self.assertIsNone(self.sync.state()["error"])
|
||||
self.frame.down = True
|
||||
self.assertEqual(self.sync.tick(), 120) # starts over after a good look
|
||||
|
||||
def test_pauses_when_this_computer_is_nearly_full(self):
|
||||
self.sync.update({"screenshots": True})
|
||||
self.frame.shots = [shot(1, NOW + 5)]
|
||||
self.free[0] = 10 * 1024**2
|
||||
self.sync.tick()
|
||||
s = self.sync.state()
|
||||
self.assertIn("out of space", s["paused"])
|
||||
self.assertEqual(self.frame.saved, [])
|
||||
self.free[0] = 100 * GB
|
||||
self.frame.calls.clear()
|
||||
self.sync.tick()
|
||||
self.assertEqual(self.frame.calls, []) # stays paused, also after a restart
|
||||
self.assertTrue(self.make().state()["paused"])
|
||||
self.sync.resume()
|
||||
self.sync.tick()
|
||||
self.assertEqual(len(self.frame.saved), 1)
|
||||
self.assertIsNone(self.sync.state()["paused"])
|
||||
|
||||
def test_pauses_when_a_copy_runs_out_of_space(self):
|
||||
self.sync.update({"screenshots": True, "clips": True})
|
||||
self.frame.clips = [clip(1, NOW + 5)]
|
||||
self.frame.export_error = RuntimeError("Not enough free space on this computer: it needs 900 MB")
|
||||
self.sync.tick()
|
||||
self.assertIn("ran out of space", self.sync.state()["paused"])
|
||||
self.sync.resume()
|
||||
self.frame.export_error = None
|
||||
self.frame.shots = [shot(1, NOW + 5)]
|
||||
self.frame.save_error = OSError(errno.ENOSPC, "No space left on device")
|
||||
self.sync.tick()
|
||||
self.assertTrue(self.sync.state()["paused"])
|
||||
|
||||
def test_space_on_the_frame_is_not_a_pause(self):
|
||||
self.sync.update({"clips": True})
|
||||
self.frame.clips = [clip(1, NOW + 5)]
|
||||
self.frame.export_error = RuntimeError("Not enough free space on the Frame to export it: it needs 900 MB")
|
||||
self.sync.tick()
|
||||
s = self.sync.state()
|
||||
self.assertIsNone(s["paused"])
|
||||
self.assertIn("Not enough free space on the Frame", s["error"])
|
||||
|
||||
def test_an_item_that_keeps_failing_is_left_alone(self):
|
||||
self.sync.update({"clips": True})
|
||||
self.frame.clips = [clip(1, NOW + 5)]
|
||||
self.frame.export_error = RuntimeError("ffmpeg couldn't join the recording")
|
||||
for _ in range(fa.TRIES + 2):
|
||||
self.sync.tick()
|
||||
self.assertEqual(self.frame.calls.count("export_clip"), fa.TRIES)
|
||||
|
||||
def test_worker_stops(self):
|
||||
stop = threading.Event()
|
||||
t = threading.Thread(target=self.sync.run, args=(stop,), daemon=True)
|
||||
t.start()
|
||||
stop.set()
|
||||
self.sync.update({}) # wakes it
|
||||
t.join(5)
|
||||
self.assertFalse(t.is_alive())
|
||||
|
||||
|
||||
class Server(unittest.TestCase):
|
||||
def test_route_and_settings(self):
|
||||
import server
|
||||
self.assertIn("/api/autosync", server.POST)
|
||||
with self.assertRaises(server.Failure):
|
||||
server.auto_sync({"action": "explode"})
|
||||
state = server.auto_sync({"action": "settings", "screenshots": "yes"}) # not a bool: ignored
|
||||
self.assertFalse(state["screenshots"])
|
||||
if server.LINK is None:
|
||||
with self.assertRaises(server.Failure):
|
||||
server.auto_sync({"action": "now"}) # nothing connected
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -0,0 +1,241 @@
|
||||
"""The clipboard both ways: the headset's read script, the server's answers, and the
|
||||
writer for this computer's clipboard on each platform. No headset: SSH and every
|
||||
clipboard program are mocked, and the read script runs against stub pgrep and qdbus6."""
|
||||
import sandbox # noqa: F401 (first: keeps tests off real data and services)
|
||||
import base64
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
from unittest import mock
|
||||
|
||||
ROOT = Path(__file__).resolve().parent.parent
|
||||
sys.path.insert(0, str(ROOT / "ui"))
|
||||
import frame_host # noqa: E402
|
||||
import server # noqa: E402
|
||||
|
||||
TEXT = "héllo, 世界 🎧\nsecond line\n\n" # accents, CJK, an emoji outside the BMP, trailing newlines
|
||||
|
||||
|
||||
def b64(text):
|
||||
return base64.b64encode(text.encode()).decode()
|
||||
|
||||
|
||||
class ReadCommand(unittest.TestCase):
|
||||
def test_reads_klipper_on_the_desktop_bus(self):
|
||||
self.assertIn("org.kde.klipper.klipper.getClipboardContents", server.COPY)
|
||||
self.assertIn("DBUS_SESSION_BUS_ADDRESS=$bus qdbus6 org.kde.klipper /klipper", server.COPY)
|
||||
self.assertIn(server.DESKTOP_CLOSED, server.COPY)
|
||||
self.assertIn(server.CLIPBOARD_TOO_BIG, server.COPY)
|
||||
self.assertIn(f"-gt {server.CLIPBOARD_LIMIT + 1} ]", server.COPY) # the limit, plus qdbus6's newline
|
||||
self.assertIn("base64 -w 0", server.COPY)
|
||||
|
||||
def test_command_carries_the_script_intact(self):
|
||||
encoded = server.COPY_CMD.split("echo ", 1)[1].split(" |", 1)[0]
|
||||
self.assertEqual(base64.b64decode(encoded).decode(), server.COPY)
|
||||
self.assertNotIn("'", server.COPY_CMD)
|
||||
|
||||
def test_send_still_uses_the_same_bus(self):
|
||||
self.assertIn(server.DESKTOP_BUS, server.PASTE)
|
||||
self.assertIn(server.DESKTOP_BUS, server.COPY)
|
||||
self.assertIn("setClipboardContents", server.PASTE)
|
||||
|
||||
|
||||
@unittest.skipUnless(sys.platform.startswith("linux") and shutil.which("bash") and shutil.which("base64"),
|
||||
"the script reads /proc, as on the Frame")
|
||||
class ReadScript(unittest.TestCase):
|
||||
"""server.COPY for real, with plasmashell's pid and Klipper stubbed."""
|
||||
|
||||
def setUp(self):
|
||||
self.dir = Path(tempfile.mkdtemp(prefix="frame-clip-"))
|
||||
self.addCleanup(shutil.rmtree, self.dir, True)
|
||||
self.clip = self.dir / "clip"
|
||||
# A process whose environment holds the desktop's bus address, standing in for plasmashell.
|
||||
self.plasma = subprocess.Popen(["sleep", "60"], env={**os.environ, "DBUS_SESSION_BUS_ADDRESS": "unix:path=/fake"})
|
||||
self.addCleanup(self.plasma.wait)
|
||||
self.addCleanup(self.plasma.kill)
|
||||
(self.dir / "pgrep").write_text(f'#!/bin/sh\n[ -e "{self.dir}/closed" ] || echo {self.plasma.pid}\n')
|
||||
(self.dir / "qdbus6").write_text(
|
||||
'#!/bin/sh\n[ "$DBUS_SESSION_BUS_ADDRESS" = unix:path=/fake ] || exit 1\n'
|
||||
f'[ "$3" = org.kde.klipper.klipper.getClipboardContents ] || exit 1\ncat "{self.clip}"; echo\n')
|
||||
for name in ("pgrep", "qdbus6"):
|
||||
(self.dir / name).chmod(0o755)
|
||||
|
||||
def run_script(self):
|
||||
def local_ssh(remote, **kw):
|
||||
r = subprocess.run(["bash", "-c", server.COPY], capture_output=True, text=True,
|
||||
env={**os.environ, "PATH": f"{self.dir}:{os.environ['PATH']}"})
|
||||
if r.returncode:
|
||||
raise server.Failure(r.stderr.strip())
|
||||
return r.stdout
|
||||
with mock.patch.object(server, "ssh", local_ssh):
|
||||
return server.headset_clipboard()
|
||||
|
||||
def test_unicode_and_newlines_come_back_exactly(self):
|
||||
self.clip.write_bytes(TEXT.encode())
|
||||
self.assertEqual(self.run_script(), TEXT)
|
||||
|
||||
def test_empty(self):
|
||||
self.clip.write_bytes(b"")
|
||||
with self.assertRaises(server.Failure) as cm:
|
||||
self.run_script()
|
||||
self.assertEqual(cm.exception.status, 400)
|
||||
self.assertIn("empty", str(cm.exception))
|
||||
|
||||
def test_too_big_is_refused_on_the_headset(self):
|
||||
self.clip.write_bytes(b"x" * (server.CLIPBOARD_LIMIT + 1))
|
||||
with self.assertRaises(server.Failure) as cm:
|
||||
self.run_script()
|
||||
self.assertEqual(cm.exception.status, 413)
|
||||
self.assertIn("1 MB", str(cm.exception))
|
||||
self.clip.write_bytes(b"x" * server.CLIPBOARD_LIMIT)
|
||||
self.assertEqual(len(self.run_script()), server.CLIPBOARD_LIMIT)
|
||||
|
||||
def test_desktop_closed(self):
|
||||
(self.dir / "closed").touch()
|
||||
with self.assertRaises(server.Failure) as cm:
|
||||
self.run_script()
|
||||
self.assertEqual(cm.exception.status, 409)
|
||||
|
||||
|
||||
class HeadsetClipboard(unittest.TestCase):
|
||||
def read(self, out=None, error=None):
|
||||
def fake_ssh(remote, **kw):
|
||||
self.assertEqual(remote, server.COPY_CMD)
|
||||
self.assertNotIn("stdin", kw)
|
||||
if error:
|
||||
raise server.Failure(error)
|
||||
return out
|
||||
with mock.patch.object(server, "ssh", fake_ssh):
|
||||
return server.headset_clipboard()
|
||||
|
||||
def test_drops_only_qdbus6s_newline(self):
|
||||
self.assertEqual(self.read(b64(TEXT + "\n") + "\n"), TEXT)
|
||||
self.assertEqual(self.read(b64("one line\n")), "one line")
|
||||
|
||||
def test_empty_and_images_say_so(self):
|
||||
for out, words in ((b64("\n"), "empty"), ("", "empty"), (b64("▨ 640x480 32bpp\n"), "image")):
|
||||
with self.assertRaises(server.Failure) as cm:
|
||||
self.read(out)
|
||||
self.assertEqual(cm.exception.status, 400)
|
||||
self.assertIn(words, str(cm.exception))
|
||||
|
||||
def test_unreadable_output_is_a_fault(self):
|
||||
for out in ("not base64!", base64.b64encode(b"\xff\xfe\n").decode()):
|
||||
with self.assertRaises(server.Failure) as cm:
|
||||
self.read(out)
|
||||
self.assertEqual(cm.exception.status, 502)
|
||||
|
||||
def test_failures(self):
|
||||
for error, status in (("The headset's desktop isn't open (plasmashell is not running).", 409),
|
||||
("The headset's clipboard holds too much to copy (over 1 MB).", 413),
|
||||
("Klipper call failed (bus: none)", 502)):
|
||||
with self.assertRaises(server.Failure) as cm:
|
||||
self.read(error=error)
|
||||
self.assertEqual(cm.exception.status, status, error)
|
||||
|
||||
|
||||
class ClipboardRequests(unittest.TestCase):
|
||||
def test_read_returns_the_text_for_the_page(self):
|
||||
with mock.patch.object(server, "headset_clipboard", return_value=TEXT):
|
||||
out = server.clipboard({"read": True})
|
||||
self.assertEqual(out["text"], TEXT)
|
||||
self.assertNotIn(TEXT, out["message"])
|
||||
|
||||
def test_to_computer_sets_this_computers_clipboard(self):
|
||||
with mock.patch.object(server, "headset_clipboard", return_value=TEXT), \
|
||||
mock.patch.object(frame_host, "set_clipboard_text") as put:
|
||||
out = server.clipboard({"toComputer": True})
|
||||
put.assert_called_once_with(TEXT)
|
||||
self.assertNotIn("text", out)
|
||||
self.assertEqual(out["message"], f"Copied {len(TEXT)} characters from the headset to this computer's clipboard")
|
||||
|
||||
def test_to_computer_without_a_clipboard_program(self):
|
||||
with mock.patch.object(server, "headset_clipboard", return_value=TEXT), \
|
||||
mock.patch.object(frame_host, "set_clipboard_text", side_effect=frame_host.HostError("Can't set the clipboard")):
|
||||
with self.assertRaises(server.Failure) as cm:
|
||||
server.clipboard({"toComputer": True})
|
||||
self.assertEqual(cm.exception.status, 500)
|
||||
|
||||
def test_to_computer_refused_when_the_server_runs_on_the_headset(self):
|
||||
with mock.patch.object(server, "LOCAL", True), mock.patch.object(server, "headset_clipboard") as read:
|
||||
with self.assertRaises(server.Failure) as cm:
|
||||
server.clipboard({"toComputer": True})
|
||||
self.assertEqual(cm.exception.status, 400)
|
||||
read.assert_not_called()
|
||||
|
||||
def test_flags_must_be_true(self):
|
||||
# Anything else is a send, and an empty one is refused before SSH.
|
||||
with mock.patch.object(server, "ssh") as ssh:
|
||||
for body in ({"read": "yes"}, {"toComputer": 1}):
|
||||
with self.assertRaises(server.Failure):
|
||||
server.clipboard(body)
|
||||
ssh.assert_not_called()
|
||||
|
||||
|
||||
class SetClipboardText(unittest.TestCase):
|
||||
def put(self, platform, have, text=TEXT, fail=()):
|
||||
runs = []
|
||||
|
||||
def run(cmd, **kw):
|
||||
runs.append((cmd, kw))
|
||||
if cmd[0] in fail:
|
||||
if fail[cmd[0]] == "timeout":
|
||||
raise subprocess.TimeoutExpired(cmd, 10)
|
||||
return subprocess.CompletedProcess(cmd, 1)
|
||||
return subprocess.CompletedProcess(cmd, 0)
|
||||
flags = {"MAC": platform == "mac", "WINDOWS": platform == "windows", "LINUX": platform == "linux"}
|
||||
with mock.patch.multiple(frame_host, **flags), \
|
||||
mock.patch.object(frame_host.shutil, "which", lambda name: f"/bin/{name}" if name in have else None), \
|
||||
mock.patch.object(frame_host.subprocess, "run", run):
|
||||
frame_host.set_clipboard_text(text)
|
||||
for _, kw in runs:
|
||||
# Nothing captured or logged, and no pipes left for a clipboard daemon to hold open.
|
||||
self.assertEqual((kw["stdout"], kw["stderr"]), (subprocess.DEVNULL, subprocess.DEVNULL))
|
||||
return runs
|
||||
|
||||
def test_mac_pbcopy_in_utf8(self):
|
||||
[(cmd, kw)] = self.put("mac", {"pbcopy"})
|
||||
self.assertEqual(cmd, ["pbcopy"])
|
||||
self.assertEqual(kw["input"], TEXT.encode("utf-8"))
|
||||
self.assertEqual(kw["env"]["LC_CTYPE"], "UTF-8")
|
||||
|
||||
def test_windows_powershell_gets_base64_utf8(self):
|
||||
[(cmd, kw)] = self.put("windows", {"powershell.exe", "clip.exe"})
|
||||
self.assertEqual(cmd[0], "powershell.exe")
|
||||
self.assertIn("Set-Clipboard", cmd[-1])
|
||||
self.assertIn("FromBase64String", cmd[-1])
|
||||
self.assertEqual(base64.b64decode(kw["input"]).decode("utf-8"), TEXT)
|
||||
|
||||
def test_windows_clip_fallback_gets_utf16_with_a_bom(self):
|
||||
runs = self.put("windows", {"powershell.exe", "clip.exe"}, fail={"powershell.exe": 1})
|
||||
self.assertEqual([c[0] for c, _ in runs], ["powershell.exe", "clip.exe"])
|
||||
data = runs[1][1]["input"]
|
||||
self.assertEqual(data[:2], b"\xff\xfe")
|
||||
self.assertEqual(data[2:].decode("utf-16-le"), TEXT)
|
||||
|
||||
def test_linux_tries_wayland_then_x11(self):
|
||||
[(cmd, kw)] = self.put("linux", {"wl-copy", "xclip", "xsel"})
|
||||
self.assertEqual(cmd, ["wl-copy"])
|
||||
self.assertEqual(kw["input"], TEXT.encode())
|
||||
runs = self.put("linux", {"wl-copy", "xclip", "xsel"}, fail={"wl-copy": 1, "xclip": "timeout"})
|
||||
self.assertEqual([c for c, _ in runs], [["wl-copy"], ["xclip", "-selection", "clipboard", "-in"],
|
||||
["xsel", "--clipboard", "--input"]])
|
||||
[(cmd, _)] = self.put("linux", {"xsel"})
|
||||
self.assertEqual(cmd[0], "xsel")
|
||||
|
||||
def test_nothing_to_set_it_with(self):
|
||||
with self.assertRaises(frame_host.HostError) as cm:
|
||||
self.put("linux", set())
|
||||
self.assertIn("wl-clipboard", str(cm.exception))
|
||||
with self.assertRaises(frame_host.HostError):
|
||||
self.put("linux", {"wl-copy"}, fail={"wl-copy": 1})
|
||||
with self.assertRaises(frame_host.HostError):
|
||||
self.put("mac", set())
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -149,6 +149,9 @@ class Sessions(unittest.TestCase):
|
||||
bg = by["123/video/bg_1172470_20261021_090000"]
|
||||
self.assertEqual((bg["kind"], bg["appid"], bg["streams"], bg["duration"]), ("background", "1172470", 1, None))
|
||||
self.assertIsNone(by["123/video/odd-name"]["appid"])
|
||||
# How long since Steam last wrote to it: auto-sync waits for a clip still being recorded.
|
||||
self.assertLess(clip["idle"], 60)
|
||||
self.assertGreater(by["123/video/odd-name"]["idle"], 10**8)
|
||||
self.assertEqual(clips.list_recordings(self.dir / "missing"), [])
|
||||
|
||||
def test_listing_marks_what_is_already_here(self):
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
"""Type on the headset: entry points, the T key and the clipboard copy, without a browser or headset."""
|
||||
import shutil
|
||||
import subprocess
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
@unittest.skipUnless(shutil.which('node'), 'Node exercises the page code')
|
||||
class TypingUi(unittest.TestCase):
|
||||
def test_behavior(self):
|
||||
root = Path(__file__).resolve().parents[1]
|
||||
result = subprocess.run(['node', '--test', str(root / 'tests/typing_ui.cjs')],
|
||||
capture_output=True, text=True)
|
||||
self.assertEqual(result.returncode, 0, result.stdout + result.stderr)
|
||||
@@ -0,0 +1,114 @@
|
||||
// Type on the headset: where people find it, the T key, and copying the headset's clipboard.
|
||||
// Production page code with only browser and transport boundaries replaced; no headset.
|
||||
const test=require('node:test');
|
||||
const assert=require('node:assert/strict');
|
||||
const cc=require('../ui/control-center.js');
|
||||
const {workspaceFixture,html}=require('./workspace_fixture.cjs');
|
||||
|
||||
const between=(from,to)=>{const start=html.indexOf(from),end=html.indexOf(to,start);assert.ok(start>=0&&end>start,from);return html.slice(start,end);};
|
||||
const section=id=>between(`id="${id}"`,'</section>');
|
||||
|
||||
test('Home, the Right now card and the Tools directory all name it Type on the headset',()=>{
|
||||
const home=between('data-page="home"','data-page="capture"');
|
||||
assert.match(home,/<a href="#pad" title="Type on the headset \(T\)"><span>Type on the headset<\/span><small>Keyboard, trackpad and clipboard<\/small>/);
|
||||
assert.match(home,/<button data-go="pad" title="Type on the headset \(T\)">Type on the headset<\/button>/);
|
||||
assert.match(between('id="toolDirectory"','<h2>Your Frame</h2>'),/href="#pad"[^>]*><span>Type on the headset<\/span>/);
|
||||
assert.doesNotMatch(html,/Keyboard &(amp;)? trackpad<\/span>|Type on the Frame</);
|
||||
});
|
||||
test('the clipboard, both ways, lives beside the keyboard, not in Send to Frame',()=>{
|
||||
const pad=section('pad');
|
||||
for(const id of ['clipText','clipSend','clipMac','clipFrom'])assert.match(pad,new RegExp(`id="${id}"`),id);
|
||||
assert.match(pad,/Text only, up to 1 MB/);
|
||||
const transfer=section('transfer');
|
||||
assert.doesNotMatch(transfer,/id="clip/);
|
||||
assert.match(transfer,/<a href="#pad">Type on the headset<\/a>/);
|
||||
});
|
||||
test('the tool page is titled Type on the headset',()=>{
|
||||
const f=workspaceFixture();
|
||||
f.navigate('#pad');
|
||||
assert.equal(f.activePage,'tools');assert.equal(f.el('pad').hidden,false);
|
||||
assert.equal(f.el('toolTitle').textContent,'Type on the headset');
|
||||
assert.equal(f.el('transfer').hidden,true);
|
||||
});
|
||||
|
||||
function keyFixture() {
|
||||
const f=workspaceFixture(),keys=[];let focused=0,started=0;
|
||||
Object.assign(f.context,{pad:{state:'off'},padStart(){started++;},ctrl:{on:false},PAGES:['apps','games','tools','settings'],
|
||||
history:{pushState(_,__,url){f.context.location.hash=url;}}});
|
||||
f.context.document.addEventListener=(type,fn)=>{if(type==='keydown')keys.push(fn);};
|
||||
f.context.document.querySelector=()=>null;
|
||||
f.context.document.activeElement={tagName:'BODY'};
|
||||
f.el('padType').focus=()=>{focused++;};
|
||||
f.run(between('function showNow(','$("nowSend").onclick'));
|
||||
f.run(between('document.addEventListener("keydown", e => {\n if (e.metaKey || e.ctrlKey || e.altKey','// ---- after an APK install'));
|
||||
const press=(key,extra={})=>{let prevented=false;keys.forEach(fn=>fn({key,preventDefault(){prevented=true;},...extra}));return prevented;};
|
||||
return {f,press,get focused(){return focused;},get started(){return started;}};
|
||||
}
|
||||
test('T opens Type on the headset, turns the keyboard on and puts the cursor in its field',()=>{
|
||||
const k=keyFixture();
|
||||
k.f.navigate('#games');
|
||||
assert.equal(k.press('t'),true,'the T must not also be typed into the field it focuses');
|
||||
assert.equal(k.f.context.location.hash,'#pad');assert.equal(k.f.activePage,'tools');
|
||||
assert.equal(k.started,1);assert.equal(k.focused,1);
|
||||
k.f.context.pad.state='ready';k.press('T');assert.equal(k.started,1,'already on: not started again');
|
||||
});
|
||||
test('T stays out of the way of typing, shortcuts and keys going to the Frame',()=>{
|
||||
const k=keyFixture();
|
||||
k.f.navigate('#games');
|
||||
k.press('t',{metaKey:true});k.press('t',{ctrlKey:true});k.press('t',{altKey:true});
|
||||
k.f.context.document.activeElement={tagName:'INPUT'};k.press('t');
|
||||
k.f.context.document.activeElement={tagName:'BODY'};k.f.context.document.querySelector=s=>s==='dialog[open]'?{}:null;k.press('t');
|
||||
k.f.context.document.querySelector=()=>null;
|
||||
k.f.context.ctrl.on=true;k.f.context.document.activeElement=k.f.el('viewer');k.press('t');
|
||||
assert.equal(k.f.context.location.hash,'#games');assert.equal(k.started,0);
|
||||
k.f.context.document.activeElement={tagName:'BODY'};k.press('3');assert.equal(k.f.context.location.hash,'#tools','number keys still switch pages');
|
||||
});
|
||||
test('Home’s button goes through the same path, showing the tool once before focusing it',()=>{
|
||||
const f=workspaceFixture(),buttons=[{dataset:{go:'pad'}},{dataset:{go:'media'}}];let focusedVisible=null;
|
||||
f.context.document.querySelectorAll=(q=>s=>s==='[data-go]'?buttons:q(s))(f.context.document.querySelectorAll);
|
||||
Object.assign(f.context,{pad:{state:'error'},padStart(){f.calls.push(['padStart']);},history:{pushState(_,__,url){f.context.location.hash=url;}}});
|
||||
f.el('padType').focus=()=>{focusedVisible=f.activePage==='tools'&&!f.el('pad').hidden;};
|
||||
f.navigate('#home');f.run(between('function showNow(','$("nowSend").onclick'));
|
||||
buttons[0].onclick();
|
||||
assert.equal(focusedVisible,true);assert.equal(f.calls.filter(c=>c[0]==='padStart').length,1);
|
||||
buttons[1].onclick();assert.equal(f.context.location.hash,'#media');
|
||||
});
|
||||
|
||||
function copyFixture(frameApp) {
|
||||
const calls=[],f=workspaceFixture();
|
||||
Object.assign(f.context,{window:{frameApp},api:async(path,body)=>{calls.push(JSON.parse(JSON.stringify([path,body])));return body.read?{text:'héllo 🎧\n',message:'Copied 8 characters from the headset\'s clipboard'}:{message:'Copied to this computer'};}});
|
||||
f.run(between('async function copyHeadsetClipboard()','$("clipFrom").onclick'));
|
||||
return {f,calls};
|
||||
}
|
||||
test('in the app, the headset’s clipboard is read and the app writes it, text untouched',async()=>{
|
||||
const written=[],{f,calls}=copyFixture({writeClipboard:async text=>{written.push(text);return true;}});
|
||||
const result=await f.run('copyHeadsetClipboard()');
|
||||
assert.deepEqual(calls,[['/api/clipboard',{read:true}]]);
|
||||
assert.deepEqual(written,['héllo 🎧\n']);
|
||||
assert.equal(result.message,'Copied 8 characters from the headset\'s clipboard');
|
||||
assert.equal(result.text,undefined,'the text is not handed on to be logged or toasted');
|
||||
});
|
||||
test('in a browser, the server sets the clipboard of the computer it runs on',async()=>{
|
||||
for(const frameApp of [undefined,{readClipboard(){}}]){
|
||||
const {f,calls}=copyFixture(frameApp);
|
||||
assert.equal((await f.run('copyHeadsetClipboard()')).message,'Copied to this computer');
|
||||
assert.deepEqual(calls,[['/api/clipboard',{toComputer:true}]]);
|
||||
}
|
||||
});
|
||||
test('a failed read writes nothing',async()=>{
|
||||
const written=[],f=workspaceFixture();
|
||||
Object.assign(f.context,{window:{frameApp:{writeClipboard:async t=>written.push(t)}},api:async()=>{throw new Error("The headset's clipboard is empty");}});
|
||||
f.run(between('async function copyHeadsetClipboard()','$("clipFrom").onclick'));
|
||||
await assert.rejects(f.run('copyHeadsetClipboard()'),/empty/);
|
||||
assert.deepEqual(written,[]);
|
||||
});
|
||||
|
||||
test('the Control Center finds Type on the headset by typing, keyboard and clipboard words',()=>{
|
||||
const input=cc.catalog.find(item=>item.id==='input');
|
||||
assert.equal(input.title,'Type on the headset');
|
||||
assert.deepEqual(input.links[0],['#pad','Type on the headset']);
|
||||
for(const query of ['type','typing','keyboard','clipboard','copy paste','kde connect'])
|
||||
assert.ok(cc.matches(input,query,'all'),query);
|
||||
const files=cc.catalog.find(item=>item.id==='files');
|
||||
assert.ok(files.links.some(([href])=>href==='#pad'),'Send files points clipboard seekers to the right place');
|
||||
});
|
||||
@@ -68,9 +68,9 @@
|
||||
{id:'sideload', category:'apps', icon:'game', title:'Sideloaded games', kind:'flow', label:'Existing controls',
|
||||
description:'Send a game folder, ZIP or executable. Frame Control selects Proton or the Linux runtime and adds a Steam library entry.',
|
||||
keywords:'windows exe zip linux devkit runtime shortcuts launch remove', links:[['#sideloaded','Manage titles'],['#transfer','Send a game']]},
|
||||
{id:'files', category:'apps', icon:'files', title:'Files & clipboard', kind:'flow', label:'Existing controls',
|
||||
description:'Send files to ~/Downloads, or send text to the Frame’s clipboard. Clipboard transfer needs the desktop panel open.',
|
||||
keywords:'upload transfer downloads paste copy text sftp storage', links:[['#transfer','Send files & text']]},
|
||||
{id:'files', category:'apps', icon:'files', title:'Send files', kind:'flow', label:'Existing controls',
|
||||
description:'Send files to ~/Downloads, or a game to the Steam library. Clipboard text, both ways, is in Type on the headset.',
|
||||
keywords:'upload transfer downloads sftp storage', links:[['#transfer','Send files'],['#pad','Clipboard']]},
|
||||
{id:'media', category:'apps', icon:'play', title:'Video & stereo photos', kind:'flow', label:'Preview feature',
|
||||
description:'Send and play H.264/H.265 video, SBS/OU photos or small splats with the built-in player. Choose a layout and theatre surround.',
|
||||
keywords:'movie photo sbs ou 3d splat gaussian theatre media player', links:[['#media','Open media player']],
|
||||
@@ -85,9 +85,11 @@
|
||||
{id:'remote', category:'network', icon:'display', title:'Remote access', kind:'flow', label:'Existing controls',
|
||||
description:'Open SSH, SFTP, Steam Link or remote desktop using the host’s existing tools. Developer Mode enables headset SSH and xrdp.',
|
||||
keywords:'terminal shell remote desktop rdp xrdp streaming steam link sftp', links:[['#power','Open remote tools']]},
|
||||
{id:'input', category:'network', icon:'keyboard', title:'Keyboard & trackpad', kind:'flow', label:'Existing controls',
|
||||
description:'Type and point in the Frame’s apps with KDE Connect, or use Control on the live panel view. First use sets up the input helper.',
|
||||
keywords:'mouse pointer keyboard trackpad touch click kde input', links:[['#pad','Open keyboard & trackpad'],['#view','Panel control']]},
|
||||
{id:'input', category:'network', icon:'keyboard', title:'Type on the headset', kind:'flow', label:'Existing controls',
|
||||
description:'Type and point in the Frame’s apps with this computer’s keyboard and mouse, and copy text both ways between the clipboards. Press T anywhere to open it.',
|
||||
keywords:'mouse pointer keyboard trackpad touch click kde connect input type typing text clipboard copy paste send',
|
||||
links:[['#pad','Type on the headset'],['#view','Panel control']],
|
||||
guidance:'The keyboard sets up KDE Connect on the Frame the first time. The clipboard needs the desktop panel open in the headset.'},
|
||||
{id:'mac', category:'network', icon:'display', title:'Mac in the headset', kind:'flow', label:'macOS only', platform:'mac',
|
||||
description:'Stream Mac screens or individual windows into headset panels. Choose quality and give each window its own display.',
|
||||
keywords:'macos mac window screen sharing stream quality sharp balanced light permissions', links:[['#macview','Configure Mac streaming']],
|
||||
|
||||
@@ -0,0 +1,285 @@
|
||||
"""Copy new screenshots and Steam clips from the headset to this computer on their own.
|
||||
|
||||
Off until it's turned on in Settings. Then a worker in the server looks about once a
|
||||
minute, while a headset is connected and nothing else is running on it, and copies
|
||||
what's new with the same code as Save and Export: screenshots to ~/Pictures/SteamFrame,
|
||||
saved Steam clips to ~/Videos/SteamFrame.
|
||||
|
||||
- Only what's newer than the moment it was turned on, so turning it on doesn't copy
|
||||
the whole back-catalogue; Copy everything now does that, once.
|
||||
- What it has copied is remembered per headset (auto-sync.json in the app's data
|
||||
folder), so a file deleted from this computer isn't copied again.
|
||||
- A clip Steam is still writing (a chunk changed in the last SETTLE seconds) waits
|
||||
for the next look. Steam's background recording is never copied: it's a rolling
|
||||
buffer, not something anyone chose to keep.
|
||||
- When this computer runs out of space it pauses and says so, until Resume.
|
||||
- When the headset can't be reached it waits longer each time, up to MAX_BACKOFF.
|
||||
|
||||
The server supplies how to reach the headset, so this can be tested without one:
|
||||
list_shots() -> {"shots": [{"id", "time", "saved"}...]}
|
||||
save_shots(device, ids) copies those screenshots here
|
||||
list_clips() -> {"clips": [{"id", "kind", "time", "idle", "saved"}...]}
|
||||
export_clip(device, id) exports one clip here
|
||||
device() -> the connected headset's id, or None
|
||||
busy() -> True while other work runs on the headset (installs, jobs, a recording)
|
||||
offline(error) -> a plain message if the error means the headset couldn't be reached
|
||||
"""
|
||||
import errno
|
||||
import json
|
||||
import os
|
||||
import shutil
|
||||
import threading
|
||||
import time
|
||||
from pathlib import Path
|
||||
|
||||
import frame_host
|
||||
|
||||
INTERVAL = 60 # seconds between looks
|
||||
BUSY_WAIT = 15 # something else is running: look again soon
|
||||
MAX_BACKOFF = 15 * 60 # the longest wait while the headset can't be reached
|
||||
SETTLE = 30 # a clip written to within this many seconds is still being recorded
|
||||
MIN_FREE = 512 * 1024**2 # pause below this much free space on this computer
|
||||
KEEP = 5000 # copied ids remembered per headset and kind
|
||||
BATCH = 100 # screenshots per copy
|
||||
TRIES = 3 # an item that fails this often is left until the app restarts
|
||||
KINDS = ("shots", "clips")
|
||||
|
||||
|
||||
class DiskFull(Exception):
|
||||
pass
|
||||
|
||||
|
||||
def free_space(folder):
|
||||
"""Free bytes on the disk `folder` is (or will be) on."""
|
||||
p = Path(folder)
|
||||
while not p.exists() and p != p.parent:
|
||||
p = p.parent
|
||||
return shutil.disk_usage(p).free
|
||||
|
||||
|
||||
def disk_full(error):
|
||||
"""Whether an error means this computer ran out of space (not the headset)."""
|
||||
if isinstance(error, OSError) and error.errno == errno.ENOSPC:
|
||||
return True
|
||||
text = str(error)
|
||||
return "No space left on device" in text or "free space on this computer" in text
|
||||
|
||||
|
||||
def _defaults():
|
||||
return {"screenshots": False, "clips": False, "since": None, "synced": {}, "paused": None,
|
||||
"checked": None, "copied": 0, "copied_time": None, "error": None, "waiting": 0}
|
||||
|
||||
|
||||
class AutoSync:
|
||||
def __init__(self, list_shots, save_shots, list_clips, export_clip, device, busy, offline=lambda e: None,
|
||||
shots_folder=None, clips_folder=None, path=None, clock=time.time, space=free_space):
|
||||
self.list_shots, self.save_shots = list_shots, save_shots
|
||||
self.list_clips, self.export_clip = list_clips, export_clip
|
||||
self.device, self.busy, self.offline = device, busy, offline
|
||||
self.shots_folder = Path(shots_folder or Path.home() / "Pictures" / "SteamFrame")
|
||||
self.clips_folder = Path(clips_folder or Path.home() / "Videos" / "SteamFrame")
|
||||
self.path = Path(path or frame_host.data_dir("auto-sync.json"))
|
||||
self.clock, self.space = clock, space
|
||||
self._lock = threading.RLock()
|
||||
self._wake = threading.Event()
|
||||
self._all = False # Copy everything now, waiting for the next pass
|
||||
self._running = False
|
||||
self._backoff = 0
|
||||
self._tries = {} # (device, id) -> failed attempts this run
|
||||
self._errors = [] # this pass's, for the page
|
||||
self._s = self._load()
|
||||
|
||||
# ---- settings and what the page shows ----
|
||||
def _load(self):
|
||||
s = _defaults()
|
||||
try:
|
||||
saved = json.loads(self.path.read_text())
|
||||
if isinstance(saved, dict):
|
||||
s.update({k: v for k, v in saved.items() if k in s})
|
||||
except (OSError, ValueError):
|
||||
pass
|
||||
s["screenshots"], s["clips"] = bool(s["screenshots"]), bool(s["clips"])
|
||||
if not isinstance(s["synced"], dict):
|
||||
s["synced"] = {}
|
||||
return s
|
||||
|
||||
def _save(self):
|
||||
try:
|
||||
self.path.parent.mkdir(parents=True, exist_ok=True)
|
||||
tmp = self.path.with_suffix(".tmp")
|
||||
tmp.write_text(json.dumps(self._s, indent=1))
|
||||
os.replace(tmp, self.path)
|
||||
except OSError:
|
||||
pass # the settings still apply until the app restarts
|
||||
|
||||
def enabled(self):
|
||||
with self._lock:
|
||||
return self._s["screenshots"] or self._s["clips"]
|
||||
|
||||
def state(self):
|
||||
with self._lock:
|
||||
s = self._s
|
||||
return {k: s[k] for k in ("screenshots", "clips", "since", "paused", "checked", "copied",
|
||||
"copied_time", "error", "waiting")} | {
|
||||
"pending": self._all, "running": self._running,
|
||||
"folders": {"shots": str(self.shots_folder), "clips": str(self.clips_folder)}}
|
||||
|
||||
def update(self, changes):
|
||||
"""{"screenshots": bool, "clips": bool}: turning it on starts the watermark now."""
|
||||
with self._lock:
|
||||
was = self.enabled()
|
||||
for key in ("screenshots", "clips"):
|
||||
if key in changes:
|
||||
self._s[key] = bool(changes[key])
|
||||
if self.enabled() and (not was or self._s["since"] is None):
|
||||
self._s["since"] = self.clock()
|
||||
if not self.enabled():
|
||||
self._s["error"], self._s["waiting"] = None, 0
|
||||
self._save()
|
||||
self._wake.set()
|
||||
return self.state()
|
||||
|
||||
def copy_all(self):
|
||||
"""Copy everything on the headset that isn't on this computer, once (also resumes)."""
|
||||
with self._lock:
|
||||
self._all, self._s["paused"] = True, None
|
||||
self._save()
|
||||
self._wake.set()
|
||||
return self.state()
|
||||
|
||||
def resume(self):
|
||||
with self._lock:
|
||||
self._s["paused"], self._s["error"] = None, None
|
||||
self._save()
|
||||
self._backoff = 0
|
||||
self._wake.set()
|
||||
return self.state()
|
||||
|
||||
# ---- the worker ----
|
||||
def run(self, stop):
|
||||
"""Until `stop` (a threading.Event) is set."""
|
||||
while not stop.is_set():
|
||||
delay = self.tick()
|
||||
self._wake.wait(delay)
|
||||
self._wake.clear()
|
||||
|
||||
def tick(self):
|
||||
"""One look. -> seconds until the next."""
|
||||
with self._lock:
|
||||
want_all = self._all
|
||||
shots = self._s["screenshots"] or want_all
|
||||
clips = self._s["clips"] or want_all
|
||||
if not (shots or clips) or self._s["paused"]:
|
||||
return INTERVAL
|
||||
since = None if want_all else self._s["since"] or 0
|
||||
device = self.device()
|
||||
if not device:
|
||||
return INTERVAL # nothing connected: nothing to ask
|
||||
if self.busy():
|
||||
return BUSY_WAIT
|
||||
with self._lock:
|
||||
self._running = True
|
||||
self._errors = []
|
||||
try:
|
||||
copied, waiting, done = self._pass(device, shots, clips, since)
|
||||
except DiskFull as e:
|
||||
with self._lock:
|
||||
self._s.update(paused=str(e), error=str(e))
|
||||
self._save()
|
||||
return INTERVAL
|
||||
except Exception as e:
|
||||
friendly = self.offline(e)
|
||||
self._backoff = min(max(self._backoff * 2, INTERVAL * 2), MAX_BACKOFF)
|
||||
with self._lock:
|
||||
self._s["error"] = friendly or str(e)
|
||||
self._save()
|
||||
return self._backoff
|
||||
finally:
|
||||
with self._lock:
|
||||
self._running = False
|
||||
self._backoff = 0
|
||||
with self._lock:
|
||||
if copied:
|
||||
self._s.update(copied=copied, copied_time=self.clock())
|
||||
self._s.update(checked=self.clock(), waiting=waiting)
|
||||
if done:
|
||||
self._s["error"] = self._errors[0] if self._errors else None
|
||||
if want_all:
|
||||
self._all = False
|
||||
self._save()
|
||||
return INTERVAL if done else BUSY_WAIT
|
||||
|
||||
def _synced(self, device, kind):
|
||||
with self._lock:
|
||||
return set(self._s["synced"].get(device, {}).get(kind, []))
|
||||
|
||||
def _mark(self, device, kind, ids):
|
||||
with self._lock:
|
||||
per = self._s["synced"].setdefault(device, {})
|
||||
have = per.get(kind, [])
|
||||
new = [i for i in ids if i not in set(have)]
|
||||
if new:
|
||||
per[kind] = (have + new)[-KEEP:]
|
||||
self._save()
|
||||
|
||||
def _room(self, folder):
|
||||
if self.space(folder) < MIN_FREE:
|
||||
raise DiskFull(f"Paused: this computer is nearly out of space ({folder} has under "
|
||||
f"{MIN_FREE // 1024**2} MB free). Free some space, then press Resume.")
|
||||
|
||||
def _failed(self, device, item, error):
|
||||
if disk_full(error):
|
||||
raise DiskFull("Paused: this computer ran out of space while copying. Free some space, "
|
||||
"then press Resume.")
|
||||
if self.offline(error):
|
||||
raise error
|
||||
key = (device, item)
|
||||
self._tries[key] = self._tries.get(key, 0) + 1
|
||||
self._errors.append(f"Couldn't copy {item.rsplit('/', 1)[-1]}: {error}")
|
||||
|
||||
def _pass(self, device, shots, clips, since):
|
||||
"""-> (copied, clips still being written, finished without stopping for other work)."""
|
||||
copied = waiting = 0
|
||||
if shots:
|
||||
listing = self.list_shots()["shots"]
|
||||
done = self._synced(device, "shots")
|
||||
self._mark(device, "shots", [s["id"] for s in listing if s.get("saved")])
|
||||
todo = [s["id"] for s in sorted(listing, key=lambda s: s["time"])
|
||||
if not s.get("saved") and (since is None or (s["time"] >= since and s["id"] not in done))
|
||||
and self._tries.get((device, s["id"]), 0) < TRIES]
|
||||
for i in range(0, len(todo), BATCH):
|
||||
if self.busy():
|
||||
return copied, waiting, False
|
||||
self._room(self.shots_folder)
|
||||
batch = todo[i:i + BATCH]
|
||||
try:
|
||||
self.save_shots(device, batch)
|
||||
except Exception as e:
|
||||
for item in batch:
|
||||
self._failed(device, item, e)
|
||||
continue
|
||||
self._mark(device, "shots", batch)
|
||||
copied += len(batch)
|
||||
if clips:
|
||||
listing = [c for c in self.list_clips()["clips"] if c.get("kind") == "clip"]
|
||||
done = self._synced(device, "clips")
|
||||
self._mark(device, "clips", [c["id"] for c in listing if c.get("saved")])
|
||||
for c in sorted(listing, key=lambda c: c["time"]):
|
||||
if c.get("saved") or self._tries.get((device, c["id"]), 0) >= TRIES:
|
||||
continue
|
||||
if since is not None and (c["time"] < since or c["id"] in done):
|
||||
continue
|
||||
if c.get("idle") is None or c["idle"] < SETTLE:
|
||||
waiting += 1 # still being written: copied on a later look
|
||||
continue
|
||||
if self.busy():
|
||||
return copied, waiting, False
|
||||
self._room(self.clips_folder)
|
||||
try:
|
||||
self.export_clip(device, c["id"])
|
||||
except Exception as e:
|
||||
self._failed(device, c["id"], e)
|
||||
continue
|
||||
self._mark(device, "clips", [c["id"]])
|
||||
copied += 1
|
||||
return copied, waiting, True
|
||||
+5
-2
@@ -412,7 +412,8 @@ def describe(userdata, clip_id):
|
||||
pass
|
||||
if duration is not None:
|
||||
break
|
||||
appid, when = None, max(s.st_mtime for s in stats)
|
||||
newest = max(s.st_mtime for s in stats)
|
||||
appid, when = None, newest
|
||||
for p in parts[2:]:
|
||||
m = STAMP.search(p)
|
||||
if m:
|
||||
@@ -426,7 +427,9 @@ def describe(userdata, clip_id):
|
||||
"size": sum(s.st_size for s in stats), "streams": len(streams),
|
||||
"chunks": sum(len(s) - 1 for s in streams.values()),
|
||||
"gaps": sum(chunk_gaps(s) for s in streams.values()), "duration": duration,
|
||||
"file": export_name(clip_id)}
|
||||
"file": export_name(clip_id),
|
||||
# Seconds since Steam last wrote to it, by the Frame's clock: still recording if small.
|
||||
"idle": round(max(0.0, time.time() - newest), 1)}
|
||||
|
||||
|
||||
def list_recordings(userdata):
|
||||
|
||||
@@ -5,6 +5,7 @@ Everything here runs on your computer, not the Frame. Python stdlib only.
|
||||
CLI (used by the Electron app, so terminal handling lives in one place):
|
||||
python3 ui/frame_host.py terminal -- CMD [ARG...] # open CMD in a terminal window
|
||||
"""
|
||||
import base64
|
||||
import hashlib
|
||||
import io
|
||||
import os
|
||||
@@ -308,6 +309,38 @@ def clipboard_text():
|
||||
raise HostError("Can't read the clipboard")
|
||||
|
||||
|
||||
def set_clipboard_text(text):
|
||||
"""Put TEXT on this computer's clipboard."""
|
||||
data = text.encode("utf-8")
|
||||
env = None
|
||||
if MAC:
|
||||
# pbcopy reads stdin in the locale's encoding, and the app may start with none (MacRoman).
|
||||
cmds, env = [["pbcopy"]], {**os.environ, "LC_CTYPE": "UTF-8"}
|
||||
elif WINDOWS:
|
||||
# Base64 on stdin, so no console code page touches the text. clip.exe takes UTF-16 with a BOM.
|
||||
script = ("Set-Clipboard -Value ([Text.Encoding]::UTF8.GetString("
|
||||
"[Convert]::FromBase64String([Console]::In.ReadToEnd())))")
|
||||
cmds = [["powershell.exe", "-NoProfile", "-NonInteractive", "-Command", script], ["clip.exe"]]
|
||||
else:
|
||||
cmds = [["wl-copy"], ["xclip", "-selection", "clipboard", "-in"], ["xsel", "--clipboard", "--input"]]
|
||||
for cmd in cmds:
|
||||
if not shutil.which(cmd[0]):
|
||||
continue
|
||||
feed = (base64.b64encode(data) if cmd[0] == "powershell.exe"
|
||||
else b"\xff\xfe" + text.encode("utf-16-le") if cmd[0] == "clip.exe" else data)
|
||||
# wl-copy and xclip stay behind to serve the clipboard: give them no pipes to hold open.
|
||||
try:
|
||||
r = subprocess.run(cmd, input=feed, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL,
|
||||
env=env, timeout=10)
|
||||
except subprocess.TimeoutExpired:
|
||||
continue
|
||||
if r.returncode == 0:
|
||||
return
|
||||
if LINUX:
|
||||
raise HostError("Can't set the clipboard: install wl-clipboard (Wayland) or xclip (X11)")
|
||||
raise HostError("Can't set the clipboard")
|
||||
|
||||
|
||||
# What Windows' OpenSSH says when it refuses ~/.ssh/config (or a key) for its ACL.
|
||||
BAD_PERMISSIONS = "Bad owner or permissions on "
|
||||
|
||||
|
||||
+96
-15
@@ -388,6 +388,7 @@
|
||||
.popt { display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; align-items: start; margin: 0 0 14px; cursor: pointer; }
|
||||
.popt input { margin: 3px 0 0; width: 16px; height: 16px; accent-color: var(--blue); }
|
||||
.popt b { font-weight: 600; color: var(--text); }
|
||||
.sync-note { margin: 10px 0 0; }
|
||||
.popt .sub { grid-column: 2; line-height: 1.45; }
|
||||
.sentlog { max-height: 260px; overflow: auto; background: rgba(0,0,0,.3); border-radius: 3px; padding: 10px;
|
||||
font: 11.5px ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; word-break: break-all; margin: 8px 0 0; }
|
||||
@@ -1143,7 +1144,7 @@
|
||||
<div class="workspace-heading"><div><span class="eyebrow">Your Steam Frame</span><h1 id="homeTitle">Let's connect</h1><p id="homeReadiness" role="status">Checking your headset…</p></div><a class="workspace-link" href="#devices">Devices & connection</a></div>
|
||||
<div class="home-grid"><section class="panel home-activity"><span class="eyebrow">Current activity</span><h2 id="homeActivity">Connect to see what's running</h2><p id="homeActivityNote">Your installed apps and current downloads appear here.</p><div id="homeRunning" class="home-running"></div><div class="home-actions"><a href="#library" class="workspace-link primary-link">Open Games →</a><a href="#discover" class="workspace-link">Find something new</a></div></section>
|
||||
<section class="panel home-session"><span class="eyebrow">Background tasks</span><h2 id="homeJobs">No active tasks</h2><p id="homeDownload">Install progress stays here while you explore.</p><button class="small" id="homeLog">View activity log</button></section></div>
|
||||
<div class="quick-routes"><a href="#capture"><span>Capture & Live</span><small>See and share the headset view</small></a><a href="#pad"><span>Keyboard & trackpad</span><small>Control apps on your Frame</small></a><a href="#comfort"><span>Family & comfort</span><small>Sessions, breaks and alerts</small></a><a href="#control"><span>Control Center</span><small>Search settings and live metrics</small></a></div>
|
||||
<div class="quick-routes"><a href="#capture"><span>Capture & Live</span><small>See and share the headset view</small></a><a href="#pad" title="Type on the headset (T)"><span>Type on the headset</span><small>Keyboard, trackpad and clipboard</small></a><a href="#comfort"><span>Family & comfort</span><small>Sessions, breaks and alerts</small></a><a href="#control"><span>Control Center</span><small>Search settings and live metrics</small></a></div>
|
||||
<section class="panel now" id="device">
|
||||
<div class="shelf-head"><h2>Right now</h2></div>
|
||||
<p class="now-state" id="nowState">Waiting for the Frame…</p>
|
||||
@@ -1159,7 +1160,7 @@
|
||||
<button data-go="media">Play a video or photo</button>
|
||||
<button data-go="macview" id="nowMac" hidden>Show a Mac window</button>
|
||||
<button id="nowSend">Send files…</button>
|
||||
<button data-go="pad">Type on the Frame</button>
|
||||
<button data-go="pad" title="Type on the headset (T)">Type on the headset</button>
|
||||
</div>
|
||||
<p class="hint">Casting shows everything the wearer sees, including anything private.</p>
|
||||
</section>
|
||||
@@ -1247,6 +1248,7 @@
|
||||
<button class="action small" id="shotsSaveNew" disabled>Save new to this computer</button>
|
||||
</div>
|
||||
<div class="shot-grid" id="shotGrid"><div class="sub">Loading…</div></div>
|
||||
<div class="sub sync-note" id="shotsSyncNote" hidden></div>
|
||||
<div class="hint">Screenshots you take in the headset with Steam's screenshot shortcut. New ones appear on their own. Click one to open it in the viewer, Copy puts it on the clipboard, and Save copies it to <code>~/Pictures/SteamFrame</code>. Right-click for more.</div>
|
||||
</section>
|
||||
<section id="clips">
|
||||
@@ -1255,6 +1257,7 @@
|
||||
<button class="small" id="videosFolder" title="Open the SteamFrame folder in your Videos">Show folder</button>
|
||||
</div>
|
||||
<div class="list" id="clipList"><div class="sub">Loading…</div></div>
|
||||
<div class="sub sync-note" id="clipsSyncNote" hidden></div>
|
||||
<div class="hint">Clips and background recordings from Steam's game recording in the headset. Export joins one into a single <code>.mp4</code> in <code>~/Videos/SteamFrame</code>, however long it is, without re-encoding it. Recordings you make with <b>Record</b> go there too.</div>
|
||||
</section>
|
||||
</div>
|
||||
@@ -1412,7 +1415,7 @@
|
||||
|
||||
<div class="page" data-page="tools">
|
||||
<div class="workspace-heading"><div><a href="#tools" id="toolBack" class="workspace-link" hidden>← All tools</a><h1 id="toolTitle">Tools</h1><p id="toolSubtitle">Choose a task for your Frame.</p></div></div>
|
||||
<div id="toolDirectory"><section class="tool-group"><h2>Content & files</h2><div class="quick-routes"><a href="#transfer"><span>Send to Frame</span><small>Add files, APKs or your own games</small></a><a href="#media"><span>Media player</span><small>Play your own videos and media</small></a><a href="#linuxApps"><span>Linux apps</span><small>Install and manage desktop apps</small></a></div></section><section class="tool-group"><h2>Play & control</h2><div class="quick-routes"><a href="#capture"><span>Capture & Live</span><small>See and control the headset view</small></a><a href="#pad"><span>Keyboard & trackpad</span><small>Type and point in desktop apps</small></a><a href="#panels"><span>Panel switcher</span><small>Bring an open panel into view</small></a><a href="#vrTools"><span>VR tools</span><small>Performance HUD and VR utilities</small></a><a href="#comfort"><span>Family & comfort</span><small>Session reminders and breaks</small></a><a href="#macview" id="macToolLink" hidden><span>Mac in the headset</span><small>Share Mac windows and displays</small></a></div></section><section class="tool-group"><h2>Your Frame</h2><a class="workspace-link" href="#settings">Connection, display & preferences →</a></section><section class="tool-group"><h2>Assistant</h2><a class="workspace-link" href="/assistant">Open assistant & AI agents →</a><p class="sub">Use your own model endpoint or review a proposed MCP action.</p></section></div>
|
||||
<div id="toolDirectory"><section class="tool-group"><h2>Content & files</h2><div class="quick-routes"><a href="#transfer"><span>Send to Frame</span><small>Add files, APKs or your own games</small></a><a href="#media"><span>Media player</span><small>Play your own videos and media</small></a><a href="#linuxApps"><span>Linux apps</span><small>Install and manage desktop apps</small></a></div></section><section class="tool-group"><h2>Play & control</h2><div class="quick-routes"><a href="#capture"><span>Capture & Live</span><small>See and control the headset view</small></a><a href="#pad" title="Type on the headset (T)"><span>Type on the headset</span><small>Keyboard, trackpad and clipboard</small></a><a href="#panels"><span>Panel switcher</span><small>Bring an open panel into view</small></a><a href="#vrTools"><span>VR tools</span><small>Performance HUD and VR utilities</small></a><a href="#comfort"><span>Family & comfort</span><small>Session reminders and breaks</small></a><a href="#macview" id="macToolLink" hidden><span>Mac in the headset</span><small>Share Mac windows and displays</small></a></div></section><section class="tool-group"><h2>Your Frame</h2><a class="workspace-link" href="#settings">Connection, display & preferences →</a></section><section class="tool-group"><h2>Assistant</h2><a class="workspace-link" href="/assistant">Open assistant & AI agents →</a><p class="sub">Use your own model endpoint or review a proposed MCP action.</p></section></div>
|
||||
<div class="grid-3" id="toolWorkspace">
|
||||
<section class="panel" id="vrTools">
|
||||
<div class="shelf-head"><h2>VR comfort and performance</h2><span class="spacer"></span><span class="sub" id="vrUpdated">Waiting for the Frame</span></div>
|
||||
@@ -1489,6 +1492,15 @@
|
||||
for the Frame (3.6 MB, 18 MB unpacked) into your home folder there and pairs with it. No internet needed, and nothing
|
||||
else to install. <a href="#" data-about>Licences</a></div>
|
||||
</div>
|
||||
<div class="shelf-head" style="margin-top:18px"><h2>Clipboard</h2></div>
|
||||
<textarea id="clipText" placeholder="Text to put on the Frame's clipboard…"></textarea>
|
||||
<div class="row" style="margin-top:8px">
|
||||
<button class="action small" id="clipSend">Send text</button>
|
||||
<button class="small" id="clipMac">Send this computer's clipboard</button>
|
||||
<button class="small" id="clipFrom">Copy the headset's clipboard here</button>
|
||||
</div>
|
||||
<div class="hint">Text goes both ways between here and the headset's desktop: copy in an app on the Frame, then
|
||||
Copy the headset's clipboard. Needs the desktop panel open in the headset. Text only, up to 1 MB.</div>
|
||||
</section><section id="androidSettings"> <h2 class="lib-section">Display and reports</h2>
|
||||
<div class="lib-manage">
|
||||
<section class="panel disp" id="display">
|
||||
@@ -1551,13 +1563,7 @@
|
||||
<option value="vr">VR app</option>
|
||||
</select>
|
||||
<div class="progress" id="prog"><i></i></div>
|
||||
<div class="shelf-head" style="margin-top:18px"><h2>Clipboard</h2></div>
|
||||
<textarea id="clipText" placeholder="Text to put on the Frame's clipboard…"></textarea>
|
||||
<div class="row" style="margin-top:8px">
|
||||
<button class="action small" id="clipSend">Send text</button>
|
||||
<button class="small" id="clipMac">Send this computer's clipboard</button>
|
||||
</div>
|
||||
<div class="hint">Clipboard needs the desktop panel open in the headset.</div>
|
||||
<div class="hint">Clipboard text, both ways, is in <a href="#pad">Type on the headset</a>.</div>
|
||||
</section>
|
||||
|
||||
<section class="panel" id="media">
|
||||
@@ -1609,6 +1615,21 @@
|
||||
<div id="steamGridStatus" class="hint" role="status"></div>
|
||||
<button id="refreshAndroidArt" class="small" style="margin-top:12px">Refresh artwork for installed apps and titles</button>
|
||||
</section>
|
||||
<section class="panel" id="autoSync">
|
||||
<div class="shelf-head"><h2>Copy to this computer</h2></div>
|
||||
<p class="sub">Copy new screenshots and clips to this computer automatically, about once a minute while a headset is connected.</p>
|
||||
<label class="popt"><input type="checkbox" id="syncShots"><b>Screenshots</b>
|
||||
<span class="sub">Into <code>~/Pictures/SteamFrame</code>, as Save does.</span></label>
|
||||
<label class="popt"><input type="checkbox" id="syncClips"><b>Steam clips</b>
|
||||
<span class="sub">Clips you save in Steam, as <code>.mp4</code> files in <code>~/Videos/SteamFrame</code>, once Steam has finished
|
||||
writing them. Steam's background recording isn't copied.</span></label>
|
||||
<div class="row"><button class="small" id="syncNow">Copy everything now</button>
|
||||
<button class="small action" id="syncResume" hidden>Resume</button></div>
|
||||
<div class="hint" id="syncStatus" role="status"></div>
|
||||
<div class="hint">Only what you take after turning it on is copied; Copy everything now copies the rest, once. A file you
|
||||
delete from this computer isn't copied again. It copies from the headset you're connected to, and waits while an
|
||||
install, an export or a recording is running.</div>
|
||||
</section>
|
||||
<section class="panel" id="power">
|
||||
<div class="shelf-head"><h2>Remote access</h2></div>
|
||||
<div class="actions">
|
||||
@@ -1696,7 +1717,7 @@
|
||||
</div>
|
||||
<div class="page" data-page="settings">
|
||||
<div class="workspace-heading"><div><a href="#settings" id="settingsBack" class="workspace-link" hidden>← All settings</a><h1 id="settingsTitle">Settings</h1><p id="settingsSubtitle">Connection, headset controls and Frame Control preferences.</p></div></div>
|
||||
<div id="settingsDirectory" class="quick-routes"><a href="#devices"><span>Devices & connection</span><small>Connect a Frame or switch headsets</small></a><a href="#control"><span>Control Center</span><small>Live metrics and searchable controls</small></a><a href="#home"><span>Frame activity</span><small>Readiness, running apps and downloads</small></a><a href="#display"><span>App display & reports</span><small>Resolution, scale and compatibility</small></a><a href="#artworkSettings"><span>Library artwork</span><small>Images and artwork sources</small></a><a href="#privacy"><span>Privacy & updates</span><small>Sharing preferences and app updates</small></a><a href="#power"><span>Remote & power</span><small>Remote access, sleep and restart</small></a></div>
|
||||
<div id="settingsDirectory" class="quick-routes"><a href="#devices"><span>Devices & connection</span><small>Connect a Frame or switch headsets</small></a><a href="#control"><span>Control Center</span><small>Live metrics and searchable controls</small></a><a href="#home"><span>Frame activity</span><small>Readiness, running apps and downloads</small></a><a href="#display"><span>App display & reports</span><small>Resolution, scale and compatibility</small></a><a href="#artworkSettings"><span>Library artwork</span><small>Images and artwork sources</small></a><a href="#autoSync" id="syncLink"><span>Copy to this computer</span><small>New screenshots and clips, automatically</small></a><a href="#privacy"><span>Privacy & updates</span><small>Sharing preferences and app updates</small></a><a href="#power"><span>Remote & power</span><small>Remote access, sleep and restart</small></a></div>
|
||||
<div id="settingsWorkspace" hidden></div>
|
||||
</div>
|
||||
|
||||
@@ -2024,11 +2045,13 @@ function applyHostWording(h) {
|
||||
document.body.classList.toggle("mobile", !!h.mobile);
|
||||
$("shotsFolder").hidden = !!h.mobile;
|
||||
$("recBtn").hidden = $("clips").hidden = !!h.mobile; // recordings are saved to a computer
|
||||
$("syncLink").hidden = !!h.mobile; // and so are automatic copies
|
||||
$("quest").hidden = !!h.mobile;
|
||||
$("metaLib").hidden = !!h.mobile; // the Quest plugs into a computer; the phone app's server runs on the Frame
|
||||
if (!h.mobile) $("shotsFolder").textContent = $("videosFolder").textContent = h.fileManager === "your file manager" ? "Open folder" : `Show in ${h.fileManager}`;
|
||||
$("shotsSaveNew").textContent = h.mobile ? `Save all to ${h.computer}` : `Save new to ${h.computer}`;
|
||||
$("clipMac").textContent = `Send ${h.computer} clipboard`;
|
||||
$("clipFrom").textContent = `Copy the headset's clipboard to this ${h.computer}`;
|
||||
$('mobileConnection').hidden = !h.mobile;
|
||||
$('desktopConnections').hidden = !!h.mobile;
|
||||
if (h.mobile) {
|
||||
@@ -2323,10 +2346,16 @@ function showNow(to) {
|
||||
showPage();
|
||||
}
|
||||
// Home's shortcuts to the things people come to do next.
|
||||
// Type on the headset: Home's button and the T key turn the keyboard on and put the cursor in its field.
|
||||
function typeOnHeadset() {
|
||||
showNow("pad");
|
||||
if (pad.state === "off" || pad.state === "error") padStart();
|
||||
$("padType").focus({ preventScroll: true });
|
||||
}
|
||||
document.querySelectorAll("[data-go]").forEach(b => b.onclick = () => {
|
||||
const to = b.dataset.go;
|
||||
if (to === "pad") return typeOnHeadset();
|
||||
showNow(to);
|
||||
if (to === "pad") { if (pad.state === "off" || pad.state === "error") padStart(); $("padType").focus({ preventScroll: true }); }
|
||||
});
|
||||
$("nowSend").onclick = () => $("fileInput").click();
|
||||
$("castBtn").onclick = () => {
|
||||
@@ -3368,6 +3397,15 @@ async function sendComputerClipboard() {
|
||||
return api("/api/clipboard", { text }, device);
|
||||
}
|
||||
$("clipMac").onclick = () => act($("clipMac").textContent, sendComputerClipboard, $("clipMac"));
|
||||
// The other way. The app (or the iPhone app) writes the clipboard itself; in a browser, the
|
||||
// server does, on the computer it runs on. The text is never logged.
|
||||
async function copyHeadsetClipboard() {
|
||||
if (!window.frameApp?.writeClipboard) return api("/api/clipboard", { toComputer: true });
|
||||
const { text, message } = await api("/api/clipboard", { read: true });
|
||||
await window.frameApp.writeClipboard(text);
|
||||
return { message };
|
||||
}
|
||||
$("clipFrom").onclick = () => act("Copy the headset's clipboard", copyHeadsetClipboard, $("clipFrom"));
|
||||
|
||||
// ---- file drop ----
|
||||
const drop = $("drop");
|
||||
@@ -5126,6 +5164,45 @@ $("shotsFolder").onclick = e => act($("shotsFolder").textContent, () => api("/ap
|
||||
// window is visible and the Frame is reachable, and again on coming back to it.
|
||||
setInterval(() => { if (!document.hidden && online) loadShots(true); }, SHOTS_POLL_MS);
|
||||
|
||||
// ---- Copying new screenshots and clips here on their own (ui/frame_autosync.py) ----
|
||||
const autoSync = { s: null, copied: null };
|
||||
const syncWhen = t => new Date(t * 1000).toLocaleString([], { dateStyle: "medium", timeStyle: "short" });
|
||||
function renderAutoSync(s) {
|
||||
autoSync.s = s;
|
||||
$("syncShots").checked = s.screenshots; $("syncClips").checked = s.clips;
|
||||
$("syncResume").hidden = !s.paused;
|
||||
const on = s.screenshots || s.clips, lines = [];
|
||||
if (s.paused) lines.push(s.paused);
|
||||
else if (s.error) lines.push(`Last problem: ${s.error}`);
|
||||
if (s.running || s.pending) lines.push("Copying…");
|
||||
if (s.copied_time) lines.push(`Last copied ${s.copied} file${s.copied === 1 ? "" : "s"} on ${syncWhen(s.copied_time)}.`);
|
||||
if (on && s.checked) lines.push(`Last checked ${syncWhen(s.checked)}.`);
|
||||
if (on && s.waiting) lines.push(`${s.waiting} clip${s.waiting === 1 ? " is" : "s are"} still being written; copied once Steam finishes.`);
|
||||
if (on && s.since) lines.push(`Copying what's new since ${syncWhen(s.since)}.`);
|
||||
$("syncStatus").textContent = lines.length ? lines.join(" ") : "Off.";
|
||||
for (const [id, key, what] of [["shotsSyncNote", "screenshots", "New screenshots"], ["clipsSyncNote", "clips", "New Steam clips"]]) {
|
||||
$(id).hidden = !s[key] || !!HOST.mobile;
|
||||
$(id).innerHTML = s.paused ? `${esc(s.paused)} <a href="#autoSync">Settings</a>`
|
||||
: `${what} are copied to this ${esc(HOST.computer)} automatically${s.copied_time ? `; last copy ${esc(syncWhen(s.copied_time))}` : ""}. <a href="#autoSync">Change</a>`;
|
||||
}
|
||||
// Something new arrived here: show it as saved.
|
||||
if (autoSync.copied !== null && s.copied_time !== autoSync.copied) { loadShots(true); if (!HOST.mobile) loadClips(); }
|
||||
autoSync.copied = s.copied_time;
|
||||
}
|
||||
async function loadAutoSync() {
|
||||
try { renderAutoSync(await api("/api/autosync")); } catch {} // not on the iPhone app's server
|
||||
}
|
||||
async function setAutoSync(body, label) {
|
||||
try { renderAutoSync(await api("/api/autosync", body)); }
|
||||
catch (e) { toast(`${label} failed: ${e.message}`, true); loadAutoSync(); }
|
||||
}
|
||||
$("syncShots").onchange = e => setAutoSync({ action: "settings", screenshots: e.target.checked }, "Saving");
|
||||
$("syncClips").onchange = e => setAutoSync({ action: "settings", clips: e.target.checked }, "Saving");
|
||||
$("syncNow").onclick = async e => { const r = await act("Copy everything now", () => api("/api/autosync", { action: "now" }), e.currentTarget); if (r) renderAutoSync(r); };
|
||||
$("syncResume").onclick = async e => { const r = await act("Resume copying", () => api("/api/autosync", { action: "resume" }), e.currentTarget); if (r) renderAutoSync(r); };
|
||||
loadAutoSync();
|
||||
setInterval(() => { const s = autoSync.s; if (!document.hidden && s && (s.screenshots || s.clips || s.pending || s.running)) loadAutoSync(); }, 20000);
|
||||
|
||||
// ---- Recording the headset view, and Steam's own clips (server.py, frame_clips.py) ----
|
||||
// A recording runs on the Frame until Stop; the server then copies the .mp4 here
|
||||
// and the page follows it by polling /api/record.
|
||||
@@ -5362,9 +5439,9 @@ const PAGES = ["apps", "games", "tools", "settings"];
|
||||
const SECONDARY_PAGES = ["home", "capture", "devices", "control"];
|
||||
const SECTION_PAGE = {library:"games", discover:"apps", android:"apps", view:"capture", shots:"capture", device:"home",
|
||||
vrTools:"tools", comfort:"tools", assistant:"tools", pad:"tools", sideloaded:"games", getgames:"games", steamStore:"games", androidLibrary:"apps", appStore:"apps", linuxApps:"apps",
|
||||
display:"settings", androidSettings:"settings", transfer:"tools", media:"tools", artworkSettings:"settings", power:"settings", macview:"tools", privacy:"settings", panels:"tools"};
|
||||
const TOOL_TITLES = {transfer:"Send to Frame", media:"Media player", artworkSettings:"Library artwork",
|
||||
pad:"Keyboard & trackpad", panels:"Panel switcher", vrTools:"VR tools", comfort:"Family & comfort", androidSettings:"App display & reports",
|
||||
display:"settings", androidSettings:"settings", transfer:"tools", media:"tools", artworkSettings:"settings", autoSync:"settings", power:"settings", macview:"tools", privacy:"settings", panels:"tools"};
|
||||
const TOOL_TITLES = {transfer:"Send to Frame", media:"Media player", artworkSettings:"Library artwork", autoSync:"Copy to this computer",
|
||||
pad:"Type on the headset", panels:"Panel switcher", vrTools:"VR tools", comfort:"Family & comfort", androidSettings:"App display & reports",
|
||||
power:"Remote & power", macview:"Mac in the headset", privacy:"Privacy & updates"};
|
||||
const workspace = {source:"all", scope:"installed", apps:"installed", scroll:new Map(), key:null, hash:null, y:0};
|
||||
let page = "apps";
|
||||
@@ -5796,6 +5873,10 @@ clientPreferences.ready.then(async () => {
|
||||
showPage();
|
||||
document.addEventListener("keydown", e => {
|
||||
if (e.metaKey || e.ctrlKey || e.altKey || /INPUT|TEXTAREA|SELECT/.test(document.activeElement.tagName) || document.querySelector("dialog[open]")) return;
|
||||
if ((e.key === "t" || e.key === "T") && !(ctrl.on && document.activeElement === $("viewer"))) {
|
||||
e.preventDefault(); // or the T lands in the field it focuses, and goes to the Frame
|
||||
return typeOnHeadset();
|
||||
}
|
||||
const n = [...PAGES, 'devices', 'control'][+e.key - 1];
|
||||
if (n) location.hash = n;
|
||||
});
|
||||
|
||||
+134
-15
@@ -50,6 +50,7 @@ from apk_sources import fdroid as apk_fdroid # noqa: E402
|
||||
import frame_apk_versions # noqa: E402
|
||||
import frame_catalog # noqa: E402
|
||||
import frame_clips # noqa: E402
|
||||
import frame_autosync # noqa: E402
|
||||
import frame_devices # noqa: E402
|
||||
import frame_steamgriddb
|
||||
import frame_comfort # noqa: E402
|
||||
@@ -818,6 +819,54 @@ def export_clip(body):
|
||||
return start_job(f"Export {name}", work)
|
||||
|
||||
|
||||
# Copying new screenshots and clips here on their own (frame_autosync.py). Each copy
|
||||
# counts as work on the headset it was listed on, so a switch can't send it elsewhere.
|
||||
|
||||
def _sync_device():
|
||||
if not LINK or LINK.snapshot().get("phase") != "connected":
|
||||
return None
|
||||
return LINK.active_device().get("id")
|
||||
|
||||
|
||||
def _sync_shots(device, ids):
|
||||
with working(device):
|
||||
return save_shots({"ids": ids})
|
||||
|
||||
|
||||
def _sync_clip(device, clip_id):
|
||||
with working(device):
|
||||
return frame_clips.export_clip(clip_id, _clips_frame, lambda cmd, timeout: ssh(cmd, timeout=timeout),
|
||||
fetch_file)
|
||||
|
||||
|
||||
def _sync_list(listing):
|
||||
def run():
|
||||
with working(_sync_device()):
|
||||
return listing()
|
||||
return run
|
||||
|
||||
|
||||
_stop_sync = threading.Event()
|
||||
autosync = frame_autosync.AutoSync(_sync_list(list_shots), _sync_shots, _sync_list(list_clips), _sync_clip,
|
||||
_sync_device, lambda: _work[0] > 0, offline=lambda e: unreachable(str(e)),
|
||||
shots_folder=SHOTS_DIR, clips_folder=frame_clips.VIDEOS_DIR)
|
||||
|
||||
|
||||
def auto_sync(body):
|
||||
"""{"action": "settings", "screenshots", "clips"} | {"action": "now"} | {"action": "resume"}."""
|
||||
_clips_here()
|
||||
action = body.get("action")
|
||||
if action == "settings":
|
||||
return autosync.update({k: body[k] for k in ("screenshots", "clips") if isinstance(body.get(k), bool)})
|
||||
if action == "now":
|
||||
if not _sync_device():
|
||||
raise Failure("Connect a headset first", 409)
|
||||
return dict(autosync.copy_all(), message="Copying everything that isn't on this computer yet…")
|
||||
if action == "resume":
|
||||
return dict(autosync.resume(), message="Copying again")
|
||||
raise Failure("action must be settings, now or resume", 400)
|
||||
|
||||
|
||||
def launch(body):
|
||||
appid = str(body.get("appid", ""))
|
||||
if not APPID.match(appid):
|
||||
@@ -928,20 +977,22 @@ def set_volume(body):
|
||||
return {"message": "Volume updated"}
|
||||
|
||||
|
||||
# Runs on the Frame, clipboard text on stdin. Verified 2026-09-25 (SteamOS 0.3.0
|
||||
# vr, build 20260922): the headset desktop is a nested Plasma Wayland session
|
||||
# inside gamescope with its own D-Bus bus, and wl-copy/xclip are not installed.
|
||||
# Klipper (org.kde.klipper, served by plasmashell) is reachable with qdbus6, so
|
||||
# borrow plasmashell's bus address. Same as scripts/paste-to-frame.sh.
|
||||
PASTE = r"""set -u
|
||||
text=$(cat; printf x); text=${text%x}
|
||||
pid=$(pgrep -u "$(id -u)" -x plasmashell | head -n 1)
|
||||
# The headset desktop's session bus. Verified 2026-09-25 (SteamOS 0.3.0 vr, build
|
||||
# 20260922): the headset desktop is a nested Plasma Wayland session inside
|
||||
# gamescope with its own D-Bus bus, and wl-copy/xclip are not installed. Klipper
|
||||
# (org.kde.klipper, served by plasmashell) is reachable with qdbus6, so borrow
|
||||
# plasmashell's bus address. Same as scripts/paste-to-frame.sh.
|
||||
DESKTOP_BUS = r"""pid=$(pgrep -u "$(id -u)" -x plasmashell | head -n 1)
|
||||
if [ -z "$pid" ]; then
|
||||
echo "The headset's desktop isn't open (plasmashell is not running). Open the desktop in the headset, then try again." >&2
|
||||
exit 2
|
||||
fi
|
||||
bus=$(tr '\0' '\n' < "/proc/$pid/environ" | sed -n 's/^DBUS_SESSION_BUS_ADDRESS=//p')
|
||||
if DBUS_SESSION_BUS_ADDRESS=$bus qdbus6 org.kde.klipper /klipper \
|
||||
"""
|
||||
# Runs on the Frame, clipboard text on stdin.
|
||||
PASTE = r"""set -u
|
||||
text=$(cat; printf x); text=${text%x}
|
||||
""" + DESKTOP_BUS + r"""if DBUS_SESSION_BUS_ADDRESS=$bus qdbus6 org.kde.klipper /klipper \
|
||||
org.kde.klipper.klipper.setClipboardContents "$text" >/dev/null; then
|
||||
echo "copied via Klipper (${#text} chars)"
|
||||
else
|
||||
@@ -949,12 +1000,77 @@ else
|
||||
exit 2
|
||||
fi
|
||||
"""
|
||||
DESKTOP_CLOSED = "plasmashell is not running" # what PASTE says when the headset's desktop isn't open
|
||||
DESKTOP_CLOSED = "plasmashell is not running" # what PASTE and COPY say when the headset's desktop isn't open
|
||||
# base64 keeps the script intact through every local shell's quoting rules.
|
||||
PASTE_CMD = 'bash -c "$(echo %s | base64 -d)"' % base64.b64encode(PASTE.encode()).decode()
|
||||
|
||||
# The other way: Klipper's getClipboardContents, printed by qdbus6 with a newline
|
||||
# after it, sent back as base64 so no shell or console encoding touches it.
|
||||
# Not tested on a headset: the method is Klipper's, the same interface PASTE uses.
|
||||
CLIPBOARD_LIMIT = 1_000_000 # bytes of UTF-8, about a 500-page book
|
||||
CLIPBOARD_TOO_BIG = "too much to copy"
|
||||
COPY = r"""set -u
|
||||
""" + DESKTOP_BUS + r"""out=$(mktemp) || exit 2
|
||||
trap 'rm -f "$out"' EXIT
|
||||
if ! DBUS_SESSION_BUS_ADDRESS=$bus qdbus6 org.kde.klipper /klipper \
|
||||
org.kde.klipper.klipper.getClipboardContents >"$out"; then
|
||||
echo "Klipper call failed (bus: ${bus:-none})" >&2
|
||||
exit 2
|
||||
fi
|
||||
if [ "$(wc -c <"$out")" -gt %d ]; then
|
||||
echo "The headset's clipboard holds %s (over 1 MB). Copy less, or send it as a file." >&2
|
||||
exit 3
|
||||
fi
|
||||
base64 -w 0 <"$out"
|
||||
""" % (CLIPBOARD_LIMIT + 1, CLIPBOARD_TOO_BIG)
|
||||
COPY_CMD = 'bash -c "$(echo %s | base64 -d)"' % base64.b64encode(COPY.encode()).decode()
|
||||
# Klipper's text for an image it holds, e.g. "▨ 640x480 32bpp" (HistoryImageItem::text in
|
||||
# Klipper's source; not seen on a headset).
|
||||
KLIPPER_IMAGE = re.compile(r"▨ \d+x\d+ \d+bpp")
|
||||
CLIPBOARD_EMPTY = "The headset's clipboard is empty"
|
||||
|
||||
|
||||
def desktop_failure(e):
|
||||
"""The headset's desktop being closed is the person's to change, not a fault: a 409 isn't reported as one."""
|
||||
if DESKTOP_CLOSED in str(e):
|
||||
return Failure(str(e), 409)
|
||||
if CLIPBOARD_TOO_BIG in str(e):
|
||||
return Failure(str(e), 413)
|
||||
return None
|
||||
|
||||
|
||||
def headset_clipboard():
|
||||
"""The text on the headset desktop's clipboard. Never logged: it can hold anything."""
|
||||
try:
|
||||
out = ssh(COPY_CMD, timeout=30)
|
||||
except Failure as e:
|
||||
raise desktop_failure(e) or e from None
|
||||
try:
|
||||
text = base64.b64decode(out.strip(), validate=True).decode("utf-8")
|
||||
except (ValueError, UnicodeDecodeError):
|
||||
raise Failure("The headset's clipboard couldn't be read as text", 502) from None
|
||||
text = text[:-1] if text.endswith("\n") else text # qdbus6's newline, not the clipboard's
|
||||
if KLIPPER_IMAGE.fullmatch(text):
|
||||
raise Failure("The headset's clipboard holds an image. Only text can be copied.", 400)
|
||||
if not text:
|
||||
raise Failure(CLIPBOARD_EMPTY + " (or holds something other than text)", 400)
|
||||
return text
|
||||
|
||||
|
||||
def clipboard(body):
|
||||
if body.get("read") is True:
|
||||
# The page puts it on the clipboard where it runs (the app, or the iPhone).
|
||||
text = headset_clipboard()
|
||||
return {"text": text, "message": f"Copied {len(text):,} characters from the headset's clipboard"}
|
||||
if body.get("toComputer") is True:
|
||||
if LOCAL:
|
||||
raise Failure("This server runs on the headset: copy from the Frame Control app instead", 400)
|
||||
text = headset_clipboard()
|
||||
try:
|
||||
frame_host.set_clipboard_text(text)
|
||||
except frame_host.HostError as e:
|
||||
raise Failure(str(e), 500)
|
||||
return {"message": f"Copied {len(text):,} characters from the headset to this computer's clipboard"}
|
||||
if body.get("fromMac") or body.get("fromComputer"):
|
||||
try:
|
||||
text = frame_host.clipboard_text()
|
||||
@@ -969,10 +1085,7 @@ def clipboard(body):
|
||||
try:
|
||||
return {"message": ssh(PASTE_CMD, stdin=text, timeout=30).strip()}
|
||||
except Failure as e:
|
||||
if DESKTOP_CLOSED in str(e):
|
||||
# The headset's state, for the person to change, not a fault: a 409 isn't reported as one.
|
||||
raise Failure(str(e), 409) from None
|
||||
raise
|
||||
raise desktop_failure(e) or e from None
|
||||
|
||||
|
||||
# ---- keyboard and pointer (KDE Connect on the Frame, see frame_input_agent.py) ----
|
||||
@@ -2785,7 +2898,7 @@ POST = {
|
||||
"/api/settings/artwork": frame_steamgriddb.save_settings,
|
||||
"/api/sources": source_manage, "/api/sources/install": source_install, "/api/android/display": android_display, "/api/android": android, "/api/quest": quest, "/api/meta": meta, "/api/queue": queue_action, "/api/titles": titles, "/api/launch": launch, "/api/steam": steam, "/api/mods": mods, "/api/volume": set_volume, "/api/clipboard": clipboard,
|
||||
"/api/flatpak": flatpak, "/api/open": open_thing, "/api/shots/save": save_shots,
|
||||
"/api/record": record, "/api/clips/export": export_clip,
|
||||
"/api/record": record, "/api/clips/export": export_clip, "/api/autosync": auto_sync,
|
||||
"/api/webinstall/check": webinstall_check, "/api/webinstall/start": webinstall_start,
|
||||
"/api/webinstall/cancel": webinstall_cancel,
|
||||
"/api/telemetry": frame_telemetry.update_settings, "/api/telemetry/event": frame_telemetry.page_event,
|
||||
@@ -3083,6 +3196,9 @@ class Handler(BaseHTTPRequestHandler):
|
||||
self.send_json(recorder.status())
|
||||
elif path == "/api/clips":
|
||||
self.send_json(list_clips())
|
||||
elif path == "/api/autosync":
|
||||
_clips_here()
|
||||
self.send_json(autosync.state())
|
||||
elif path == "/api/stream":
|
||||
self.stream_video(url.query)
|
||||
elif path == "/api/screenshot" and parse_qs(url.query).get("view") == ["panel"]:
|
||||
@@ -3373,6 +3489,8 @@ def main():
|
||||
frame_report.link = LINK # its connection summary goes in every report's diagnostics
|
||||
frame_report.start_ssh_check() # ...with which ssh this is, found once in the background
|
||||
LINK.start()
|
||||
if not PRIVATE: # one worker per user, in the app's server
|
||||
threading.Thread(target=autosync.run, args=(_stop_sync,), daemon=True).start()
|
||||
if not frame_host.WINDOWS:
|
||||
signal.signal(signal.SIGTERM, lambda *_: (_ for _ in ()).throw(KeyboardInterrupt))
|
||||
if args.exit_on_eof:
|
||||
@@ -3395,6 +3513,7 @@ def main():
|
||||
# mid-cleanup would abort it and leave the SSH master running.
|
||||
if not frame_host.WINDOWS:
|
||||
signal.signal(signal.SIGTERM, signal.SIG_IGN)
|
||||
_stop_sync.set()
|
||||
webinstall_shutdown()
|
||||
macview.shutdown() # close the headset's viewers before the agent goes
|
||||
# The master was started with -N, so it stays up until told to exit.
|
||||
|
||||
Reference in new issue
Block a user