While you're here, please consider supporting GamingOnLinux on:
Reward Tiers: Patreon. Plain Donations: PayPal.
This ensures all of our main content remains totally free for everyone! Patreon supporters can also remove all adverts and sponsors! Supporting us helps bring good, fresh content. Without your continued support, we simply could not continue!
You can find even more ways to support us on this dedicated page any time. If you already are, thank you!
Reward Tiers: Patreon. Plain Donations: PayPal.
This ensures all of our main content remains totally free for everyone! Patreon supporters can also remove all adverts and sponsors! Supporting us helps bring good, fresh content. Without your continued support, we simply could not continue!
You can find even more ways to support us on this dedicated page any time. If you already are, thank you!
Login / Register
- Founder of Baldur's Gate 3 developer blasts publisher greed
- Proton 9.0 (Beta16) brings more regression fixes, updated Steamworks SDK
- Windows compatibility layer Wine 9.5 released
- Backpack Battles has sold 500,000 copies in two weeks on Steam
- System76 release upgraded Lemur Pro laptop, plus a desktop sale now on
- > See more over 30 days here
-
Take-Two Interactive buying Gearbox from Embracer, more…
- ToddL -
The Triple-i Initiative gaming showcase is coming April…
- ToddL -
Take-Two Interactive buying Gearbox from Embracer, more…
- Peak -
PUNKCAKE Délicieux just added Linux support to a whole…
- Pengling -
The Triple-i Initiative gaming showcase is coming April…
- Pengling - > See more comments
Latest Forum Posts
- How to find out if a game is native for sure?
- Install - Probably quite slow for the next 9 days
- redneckdrow - Logitech G29 steering wheel - Snowrunner support
- njasd2w - Weekend Players' Club 3/22/2024
- Pengling - Nintendo-style gaming, without Nintendo!
- Linux_Rocks - See more posts
I just made a little handy script I'm using lately, it is named xfreeze.sh
His function is to pause and resume whatever program running in a X11 window.
Not all games support a pause function when unfocused, and this is not good for power consumption.
In other ones you may want to just stop them for whatever reason (take some time to translate a string -eg: in gta5 when there are subtitles in foreing language while you're driving, cheating... whatever).
I just paused Horizon Chase Turbo to write this post and let my cpu and gpu rest for a while :)
Usage:
xfreeze.sh Action Target
Action:
ask: Ask to pause or continue execution (uses kdialog to ask you what to do)
switch: Switch execution state paused <-> running
Target:
active: Use the active window (pause or resume the active window)
select: Ask user to click on a window (expects you to click on the window you want to pause)
_
Dependancies:
Currenty, i've bound "xfreeze.sh switch active" to a SHIFT+PAUSE hotkey (use whatever tool your de provides to assign custom commands to shortcuts), so that while i'm playing, i hit SHIFT+PAUSE and have my game paused or resumed.
Beware that for how Xorg works, when not using a compositor, when a window is "paused" it does not update his content, so if you minimize the window and restore it while paused, it will be totally black. Also if it is partially obscured by another one, the latter will leave traces on it (win95 effect); resuming the window will make them go away.
Oh, it doesn't work for all the programs, because sometimes their window doesn't implement _NET_WM_PID and I wasn't able to resolve a window id to a pid in those cases, not even xkill is able to work on them, but fortunately they are rare.
Here it is:
#!/usr/bin/env bash
# xfreeze.sh [ask|switch] [active|select]
# ask = ask to pause or continue execution
# switch = switch execution state
# active = use the active window
# select = ask user to click on a window
if [ $2 = "active" ] ; then
PROC=$(xprop -id $(xprop -root | awk '/_NET_ACTIVE_WINDOW\(WINDOW\)/{print $NF}') | awk '/_NET_WM_PID\(CARDINAL\)/{print $NF}')
else
PROC=$(xdotool selectwindow getwindowpid)
fi
if [ $1 = "ask" ] ; then
kdialog --yesno $(</proc/$PROC/comm) --yes-label RESUME --no-label PAUSE
else
grep State: /proc/$PROC/status|grep stopped
fi
condition_continue=$?
echo $condition_continue
if [ $condition_continue = 0 ] ; then
echo cont
kill -CONT $PROC
else
echo stop
kill -STOP $PROC
fi
#cat /proc/$PROC/status #debug
Hope someone will find it useful,
back to Horizon Chase Turbo, cheers!
Last edited by kokoko3k on 22 July 2021 at 4:21 pm UTC