diff --git a/hosts/FredOS-Gaming.nix b/hosts/FredOS-Gaming.nix index 4e1f8ed..265661c 100644 --- a/hosts/FredOS-Gaming.nix +++ b/hosts/FredOS-Gaming.nix @@ -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 diff --git a/patches/vesktop-cancel-shows-picker.patch b/patches/vesktop-cancel-shows-picker.patch new file mode 100644 index 0000000..330e708 --- /dev/null +++ b/patches/vesktop-cancel-shows-picker.patch @@ -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] } : {}); diff --git a/settings/hyprland.nix b/settings/hyprland.nix index eedc533..cb481a1 100644 --- a/settings/hyprland.nix +++ b/settings/hyprland.nix @@ -114,15 +114,17 @@ in # list as id[HC>]class[HT>]title[HE>]address[HA>]… and reads back # "[SELECTION]/window:" (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 "$@" ''} }