Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop client after exiting game #1721

Open
Necoro opened this issue Feb 14, 2013 · 9 comments

Comments

@Necoro
Copy link

commented Feb 14, 2013

When starting a game from the commandline via steam steam://rungameid/123456, steam does not exit when game is closed. In Issue #255, this was dubbed 'intended behavior'. Please add at least an option that closes steam afterwards, so one can build scripts around steam. This holds especially, since Steam does not use the systray but only this ubuntu-specific "indicator"-thingy, and hence besides killing there is no way of closing steam afterwards.

(Btw: On windows steam.exe -applaunch 123456 used to work in the correct manner. But now the -applaunch behavior seems to be removed completely :( )

@npic

This comment has been minimized.

Copy link

commented Jan 1, 2014

I just faced this and I totally agree with you. This "normal behavior" is weird and counter-intuitive for one who just wants to run a specific game. I suggest to add another steam:// endpoint (like "steam://rungameidandexit/123456"), so nobody's workflow will be broken.

@Enverex

This comment has been minimized.

Copy link

commented Jun 29, 2016

Been a few years now guys, any movement on this? It's a big issue when trying to use Steam games with a frontend as Steam forks the game and remains running forever, so the launcher never realises the game itself has finished.

@fbt

This comment has been minimized.

Copy link

commented Aug 7, 2016

Would also like a flag for this. Don't like to run the steam client when I don't need it, and closing it every time after -applaunch is tedious.

@nerfpops

This comment has been minimized.

Copy link

commented Oct 27, 2016

Pretty annoying on windows too. Would be great with a command line option here.

@ejthill

This comment has been minimized.

Copy link

commented Feb 24, 2017

Ran into this when I was googling the same issue. I'm using a "Attract-Mode" as my front end, and I want it to know when the app closes.

If you're on Linux, here's a hack I'm using to accomplish this. It's a bash script that will note the name of the current active window (your launcher application or terminal or whatever), launch the steam app, wait a configurable amount of time for it to actually open a new window, then check the name of the active window every second. Once the name of the active window matches your original launcher application (after the game exists), the script will exit.

Requirements
sudo apt-get install xdotool

Usage
./steamlaunch.sh <app_id> <launch_timeout>

./steamlaunch.sh content

app=$1
launchtimeout=$2
#If launchtimeout not specified, use default of 5
if [[ -z "$launchtimeout" ]]; then
  launchtimeout=5
fi
#Lookup current active window
launchwindow=$(xdotool getwindowfocus getwindowname)
#Launch Application
steam -silent -applaunch $app &
#Give steam time to start and launch a new window
sleep $launchtimeout
#Wait until the focus returns to the original window
while [ "$focus" != "$launchwindow" ]
do
  focus=$(xdotool getwindowfocus getwindowname)
  sleep 1
done
exit

This will keep the script "executing" until the game exits. If you want to completely kill steam, add the following to the end of the script right before "exit".
pgrep steam | while read pid; do kill $pid; done

Super hack? Yes. Does it work in my case? Yes.

I'm sure this won't handle everyones' use cases, but it may be a start. Hopefully this will be appropriately supported in the future.

@kisak-valve kisak-valve assigned ghost Apr 6, 2017
@ghost

This comment has been minimized.

Copy link

commented Jun 8, 2017

This is my solution.

#!/bin/bash
#
# script to exit steam after game exit
#
# sets function to run when game ends and this script is exiting,
# waits 5 seconds and kills steam
#
# put this script somewhere in PATH, call it steam-exit
# and put steam-exit %command% in games launch options
#
trap game_exit EXIT

function game_exit {
	sleep 5
	pkill steam
}

# execute game command
"$*"
@Spacehopper1234

This comment has been minimized.

Copy link

commented Jan 9, 2018

Just installed Steam recently, and it was annoying me. I made this batch file for BF1 a couple of years ago to shut down Origin after game exit, and it works for Steam also. Its not pretty, but it works.
Create batch file.
Add:-

@echo OFF
START "" "C:\Program Files (x86)\Steam\steamapps\common\YourGame\YourGame.exe"
TIMEOUT /t 20
:RUNNING
tasklist|findstr YourGame.exe > nul
if %errorlevel%==1 timeout /t 5 & taskkill /F /IM Steam.exe /T & GOTO ENDLOOP
timeout /t 2
GOTO RUNNING
:ENDLOOP

It waits 20 secs to connect to and update Steam, (or set longer if your'e having connection issues) and then just runs a loop to check if your game is still running, and then when it isnt, to kill Steam. Simples.
I create a shortcut to the batch file and set it to run minimised. (although i think you can use 'SET MIN' or something.

EDIT: Apologies, came here just looking to see if anyone else had same issue as me. Just noticed its a Linux forum :)

@sreksten

This comment has been minimized.

Copy link

commented Jan 29, 2018

Same here. I added the Steam client to EmulationStation, but until Steam closes I am not able to get back to Emulationstation after I finished playing the game.
This thread is nearly 5 years old, it is possible to have a switch that allows Steam to close automatically after a game exits?

@AndydeCleyre

This comment has been minimized.

Copy link

commented Aug 3, 2018

For those launching a game with primusrun or similar, the client keeps the video card engaged without much to indicate its presence.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
9 participants
You can’t perform that action at this time.