mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-20 05:16:01 +00:00
fix: compress only while the running game is focused
This commit is contained in:
1 parent
0a8358d11f
commit
73e158ab3b
2 files changed
+93
-12
No files matched your search
@@ -447,14 +447,30 @@ case $mode in
|
||||
step "zRAM compression: on"
|
||||
(
|
||||
bl_zram_scan() {
|
||||
_bl_game=0 _bl_pids=()
|
||||
_bl_game=0 _bl_pids=() _bl_apps=
|
||||
local _d _c _args _name _a _id
|
||||
for _d in /proc/[0-9]*; do
|
||||
# Under FEX the program is FEX's first argument.
|
||||
{ IFS= read -r -d '' _c && case ${_c##*/} in FEX|FEXInterpreter) IFS= read -r -d '' _c ;; esac; } \
|
||||
2>/dev/null < "$_d/cmdline" || continue
|
||||
case ${_c##*/} in
|
||||
reaper) _bl_game=1 ;;
|
||||
steam|steamwebhelper) _bl_pids+=("${_d#/proc/}") ;;
|
||||
_args=()
|
||||
# Under FEX the program is FEX's first argument. AppId= is its own argument.
|
||||
while IFS= read -r -d '' _c; do _args+=("$_c"); done 2>/dev/null < "$_d/cmdline" || true
|
||||
[ "${#_args[@]}" -gt 0 ] || continue
|
||||
_name=${_args[0]}
|
||||
if [ "${#_args[@]}" -gt 1 ]; then
|
||||
case ${_name##*/} in FEX|FEXInterpreter) _name=${_args[1]} ;; esac
|
||||
fi
|
||||
case ${_name##*/} in
|
||||
reaper)
|
||||
for _a in "${_args[@]}"; do
|
||||
case $_a in
|
||||
AppId=769) ;;
|
||||
AppId=[0-9]*)
|
||||
_id=${_a#AppId=}
|
||||
case $_id in *[!0-9]*) ;; *) _bl_game=1; _bl_apps="$_bl_apps $_id" ;; esac
|
||||
;;
|
||||
esac
|
||||
done
|
||||
;;
|
||||
steam|steamwebhelper) _bl_pids+=("${_d##*/}") ;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
@@ -475,14 +491,22 @@ case $mode in
|
||||
bl_zram_scan
|
||||
step "zRAM: done ($(bl_zram_usage))"
|
||||
}
|
||||
# The game process exists for the whole Proton launch. Compressing then stalls the
|
||||
# launch, so the clock starts only once the game window has focus, and waits 20 s more.
|
||||
# Proton's reaper exists before the game window does, and compressing then stalls the
|
||||
# launch. focusedApp uses the same 32-bit id as that reaper's AppId= (769 is Steam; a
|
||||
# shortcut's CGameID keeps this id in its high half). The clock starts on a match, then
|
||||
# waits 20 s more. Desktop Steam never writes focus.json, so the game process is enough.
|
||||
bl_game_focused() {
|
||||
[ -n "${BL_LAUNCH_DIR:-}" ] || return 1
|
||||
if [ "${BL_DESKTOP:-}" = 1 ] || [ -z "${BL_LAUNCH_DIR:-}" ]; then
|
||||
return 0
|
||||
fi
|
||||
local id
|
||||
id=$(sed -n 's/.*"focusedApp"[[:space:]]*:[[:space:]]*\([0-9][0-9]*\).*/\1/p' \
|
||||
"$BL_LAUNCH_DIR/agent/focus.json" 2>/dev/null | head -1)
|
||||
[ -n "$id" ] && [ "$id" != 769 ]
|
||||
[ -n "$id" ] || return 1
|
||||
case " ${_bl_apps-} " in
|
||||
*" $id "*) return 0 ;;
|
||||
esac
|
||||
return 1
|
||||
}
|
||||
_bl_since=-1 _bl_packed=-1
|
||||
while kill -0 $$ 2>/dev/null; do
|
||||
|
||||
Reference in new issue
Block a user