STEAM GROUP
Linux User Group s-lug
STEAM GROUP
Linux User Group s-lug
272
IN-GAME
2,135
ONLINE
Founded
April 16, 2010
Language
English
Nid Buni Jul 17, 2018 @ 7:27am
Nifty script for launching a random installed Steam game
Like the title says, I've put together a bash script to do that. Here is the code, for the curious:

#!/bin/bash

#cd ~/.steam/steamapps
cd ~/.local/share/Steam/steamapps
ls |sort -R |tail -1 |while read file; do
file=${file//[!0-9]/}
steam -gameidlaunch $file
done

Just open a text editor, enter the above code and save it as a .sh somewhere. Then, just make it executable (chmod +x filename.sh). Run it by clicking on it in a file browser, or by opening a terminal at its location and typing: ./filename.sh

EDIT: It has been pointed out to me that a user's steamapps folder could be in a different location than the one I put in this script initially. If yours isn't in ~/.local/share/Steam/steamapps, then uncomment that first cd line and comment out the second one. (Remove the "#" from the first and put one before the second.)

If you want to be able to do this easily from your application launcher menu, you can create a desktop file. Here's the one I made:

[Desktop Entry]
Categories=Game;
Comment=Play some game on Steam
Exec=~/.local/share/applications/random.sh
Icon=steam
Name=Launch a random Steam game
StartupNotify=true
Terminal=false
Type=Application

Open a text editor, put that stuff in there and save as a .desktop in ~/.local/share/applications. Then, make it executable, either by right-clicking and selecting "Properties" in a file manager, or by opening a terminal in that directory and typing "chmod +x filename.desktop" :spacebooze:
Last edited by Nid Buni; Jul 17, 2018 @ 7:50am
< >
Showing 1-4 of 4 comments
Cheeseness Jul 17, 2018 @ 7:31am 
Hey, this is a nifty little idea!

You might want to make note that Steam can end up symlinked to/installed in a couple of different locations. This path might be the best/most reliable one for anybody who doesn't have their steamapps folder in ~/.steam/
~/.local/share/Steam/steamapps/
Nid Buni Jul 17, 2018 @ 7:36am 
Thanks, your Cheeseness. I think I'll leave that to the user to decide. I have that folder, but there aren't actually any games installed there. Does the default location for installed games depend on whether you install Steam from the website or from the official repositories? I haven't opted into the beta or anything. I did notice that in my ~/.steam/steamapps folder there were acf files for games that were installed in my secondary library folder, so those games have an equal chance of being selected as well. Good on Valve for that!
Cheeseness Jul 17, 2018 @ 7:38am 
Originally posted by Little Dude:
Does the default location for installed games depend on whether you install Steam from the website or from the official repositories? I haven't opted into the beta or anything.
I don't think it does, but Valve did change the default once or twice point a while back. Existing installs didn't change, but new installs may be different.
Tele42 Jul 17, 2018 @ 7:42am 
Hello Little Dude, ~/.local/share/Steam is the default location, but Debian changes the folder layout in their packaging for steam because reasons. Ubuntu inherits the package from Debian.
< >
Showing 1-4 of 4 comments
Per page: 1530 50