Screenshare: Vesktop cancel opens full picker, not a 30s window

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
rope 2026-10-12 20:12:17 +01:00
parent e6120f821a
commit a7c4513d4e
3 changed files with 44 additions and 9 deletions

View file

@ -7,9 +7,14 @@
gamescope
spotify
# Preselect the last stream's audio source (e.g. Hearthstone) when it's
# running again, instead of resetting to "None" every Go Live.
# running again, instead of resetting to "None" every Go Live; Cancel in
# the stream dialog makes the next share show the full window picker
# (see xdph.conf in settings/hyprland.nix).
(vesktop.overrideAttrs (old: {
patches = (old.patches or [ ]) ++ [ ../patches/vesktop-remember-stream-audio.patch ];
patches = (old.patches or [ ]) ++ [
../patches/vesktop-remember-stream-audio.patch
../patches/vesktop-cancel-shows-picker.patch
];
}))
lsfg-vk
lsfg-vk-ui

View file

@ -0,0 +1,30 @@
--- a/src/main/screenShare.ts
+++ b/src/main/screenShare.ts
@@ -5,6 +5,8 @@
*/
import { desktopCapturer, session, Streams } from "electron";
+import { writeFileSync } from "fs";
+import { join } from "path";
import type { StreamPick } from "renderer/components/ScreenSharePicker";
import { IpcCommands, IpcEvents } from "shared/IpcEvents";
@@ -55,7 +57,17 @@
skipPicker: true
}).catch(() => null);
- if (stream === null) return callback({});
+ if (stream === null) {
+ // Cancelled: tell the auto-picking XDPH picker (FredOS settings/hyprland.nix)
+ // to show the full picker on the next share.
+ try {
+ writeFileSync(
+ join(process.env.XDG_RUNTIME_DIR ?? "/tmp", "xdph-pick-manually"),
+ String(Math.floor(Date.now() / 1000))
+ );
+ } catch {}
+ return callback({});
+ }
}
callback(video ? { video: sources[0] } : {});

View file

@ -114,15 +114,17 @@ in
# list as id[HC>]class[HT>]title[HE>]address[HA>]… and reads back
# "[SELECTION]<flags>/window:<id>" (flag r = token allowed). Hearthstone
# wins, else any other Proton window (steam_app_*) that isn't a launcher
# or HDT. Escape hatch: share again within 30s (cancel, retry) and the
# normal picker shows.
# or HDT. Escape hatch: Cancel in Vesktop's dialog (Gaming's patched
# Vesktop writes the time to xdph-pick-manually) and the next share
# within a minute shows the normal picker.
xdg.configFile."hypr/xdph.conf".text = ''
screencopy {
allow_token_by_default = true
custom_picker_binary = ${pkgs.writeShellScript "share-picker-game-first" ''
stamp="''${XDG_RUNTIME_DIR:-/tmp}/xdph-autopick"
flag="''${XDG_RUNTIME_DIR:-/tmp}/xdph-pick-manually"
printf -v now '%(%s)T' -1
read -r last 2>/dev/null < "$stamp" || last=0
{ cancelled=$(< "$flag"); } 2>/dev/null # no trailing newline, so not `read`
echo 0 > "$flag"
game=$(printf '%s' "''${XDPH_WINDOW_SHARING_LIST-}" | ${pkgs.gawk}/bin/awk '
BEGIN { RS = "\\[HA>\\]"; FS = "\\[H[CTE]>\\]" }
@ -131,12 +133,10 @@ in
&& $3 !~ /^(Battle\.net|Hearthstone Deck Tracker|HearthstoneOverlay)/ { other = $1 }
END { print hs != "" ? hs : other }')
if [ -n "$game" ] && (( now - last > 30 )); then
echo "$now" > "$stamp"
if [ -n "$game" ] && (( now - ''${cancelled:-0} > 60 )); then
echo "[SELECTION]r/window:$game"
exit 0
fi
echo 0 > "$stamp"
exec ${pkgs.xdg-desktop-portal-hyprland}/bin/hyprland-share-picker "$@"
''}
}