summaryrefslogtreecommitdiff
path: root/bin/menuscripts/mgame
blob: cd7a7b04b2cb5ffa3fa364b60ab4db9bf9c28537 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/bin/sh

steam_games()
{
    # List every manifest file and get the id of the games from the file names and the name of the
    # game from the file.
    find ~/.local/share/Steam/steamapps \
        -maxdepth 1 -type f -iname 'appmanifest_*.acf' |
        while read -r File; do
            Name="$(grep '"name"' "$File" | cut -f 4 -d '"')"
            FileBaseName="${File%.acf}"
            SteamID="${FileBaseName##*appmanifest_}"
            printf '%s %s\n' "$SteamID" "$Name"
        done
}

Choice="$(steam_games | cut -f 2- -d' ' | dmenu -c -i -x)"
[ "$Choice" ] || exit 1
ID="$(steam_games | grep "[0-9]\+ $Choice" | cut -f 1 -d ' ')"

setsid steam steam://rungameid/"$ID"