How to launch Steam games using Rofi | Hund

Hund

How to launch Steam games using Rofi

Thursday, September 30, 2021

I recently figured out how to launch my Steam games from the shell today. This means that I can now start my games via my application launcher Rofi.

Instructions

Start by right-clicking on a game in your Steam library. It will then create a .desktop-file with that game in the folder ~/.var/app/com.valvesoftware.Steam/Desktop/.

In that file, there’s a line that looks like this:

Exec=steam steam://rungameid/<ID>

Using that ID, you can then launch the game using this command:

com.valvesoftware.Steam steam://rungameid/<ID>

If you use Flatpak:

flatpak run com.valvesoftware.Steam steam://rungameid/<ID>

With all that prepared. You can now use this Rofi plugin that I created:

#!/bin/sh

DIR="/home/$( whoami )/.var/app/com.valvesoftware.Steam/Desktop"

handle_selection() {
  if [ "$1" ]; then
    ID="$(grep -oP '(?<=rungameid/).*' "$DIR"/"$1".desktop)"
    flatpak run com.valvesoftware.Steam steam://rungameid/"$ID" 
    notify-send "Steam" "Launching the game \"$1\""
  fi
}

handle_selection "$( cd "$DIR" || exit; ls -t  | sed 's/\.desktop//' | rofi -dmenu -i -p 'Launch game' -hlbg '#5FA5D7' -bc '#5FA5D7' -bw 3)"

Meta

Feedback

If you want to leave feedback, you can do so by either sending me a message via email, XMPP or via IRC.