Files
lhns--steam-frame-nix/modules/screenshots/check.nix
T
Pierre Kisters 26641d76a0 SteamVR screenshots linked into ~/Pictures
Steam keeps VR screenshots (Steam button + trigger) in
~/.local/share/Steam/userdata/<account ID>/760/remote/250820/screenshots,
where Dolphin, Gwenview and the file pickers don't look.

screenshots (module screenshots, opt-in) links ~/Pictures/<name> (default
"SteamVR Screenshots") there. The account ID comes from steamUserId, or,
unset, at runtime: the Home Manager link points to
<runtimeDir>/steam-frame-nix/screenshots (tmpfs), which the oneshot user
service steam-frame-nix-screenshots points to the account last logged in
(loginusers.vdf MostRecent, else latest timestamp, else the only userdata
folder), on switch, at login and when loginusers.vdf or userdata changes.

install.sh cleanup knows the tmpfs link (--keep screenshots while used).
Flake checks: account detection on fake Steam dirs; cleanup of the link.
2026-09-30 22:54:13 +02:00

59 lines
2.0 KiB
Nix

# Checks of steam-frame-nix-screenshots (link.sh) on fake Steam and runtime
# dirs: account from loginusers.vdf (MostRecent, else latest timestamp),
# else the only userdata folder, else no link (an old one removed); an
# unchanged target isn't rewritten; no outer runtime dir is a no-op.
{ pkgs }:
let
script = import ./package.nix {
inherit (pkgs) lib; inherit pkgs;
runtimeDir = "/nonexistent"; steam = "/nonexistent";
};
in
pkgs.runCommand "screenshots-check" { nativeBuildInputs = [ script ]; } ''
set -euo pipefail
fail() { echo "FAIL: $*" >&2; exit 1; }
export STEAM_FRAME_NIX_RUNTIME_DIR=$PWD/run STEAM_FRAME_NIX_STEAM_DIR=$PWD/steam
S=$STEAM_FRAME_NIX_STEAM_DIR L=$STEAM_FRAME_NIX_RUNTIME_DIR/steam-frame-nix/screenshots
target() { echo "$S/userdata/$1/760/remote/250820/screenshots"; }
expect() { [ "$(readlink $L)" = "$(target $1)" ] || fail "$2: $(readlink $L || echo no link)"; }
steam-frame-nix-screenshots 2>&1 | grep -q "doesn't exist" || fail "no runtime dir"
[ ! -e run ] || fail "runtime dir created"
mkdir -p run $S/config $S/userdata/0 $S/userdata/80511808
# the only account folder ("0" is not an account)
steam-frame-nix-screenshots; expect 80511808 "userdata"
# MostRecent wins over a later timestamp
cat > $S/config/loginusers.vdf <<'VDF'
"users"
{
"76561198040777536"
{
"AccountName" "a"
"MostRecent" "1"
"timestamp" "100"
}
"76561197960265729"
{
"AccountName" "b"
"MostRecent" "0"
"timestamp" "200"
}
}
VDF
steam-frame-nix-screenshots; expect 80511808 "MostRecent"
# unchanged: not rewritten
res=$(steam-frame-nix-screenshots 2>&1); [ -z "$res" ] || fail "rewrote: $res"
# no MostRecent (current Steam): latest timestamp
sed -i '/MostRecent/d' $S/config/loginusers.vdf
steam-frame-nix-screenshots; expect 1 "timestamp"
# nothing to go by: link removed
rm $S/config/loginusers.vdf; mkdir $S/userdata/42
steam-frame-nix-screenshots 2>&1 | grep -q "no Steam account" || fail "no warning"
[ ! -L $L ] || fail "link kept"
touch $out
''