summaryrefslogtreecommitdiffstats
path: root/gamechesttui
blob: 553c8009e289024710d87b34bf6ab2c04903b621 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/bin/sh -eu

#set -x

GAMESAVES_PATH="$(gamechest showconfig | jq -r .gamesaves_path)"

main()
{
    # Game
    game="$(\
        gamechest list \
        | grep -i true \
        | cut -d ":" -f 1 \
        | cut -d " " -f 1 \
        | fzf-frecency gamechest-game \
            --style=full \
            --list-label="Installed games" \
    )"
    if [ -z "$game" ]; then
        # no game selected
        exit 0
    fi

    # Profile
    profile="$(\
        yq -r '.profiles[].name' < "$GAMESAVES_PATH/profiles.yaml" \
        | fzf-frecency gamechest-profile \
            --style=full \
            --list-label="Profiles" \
    )"
    if [ -z "$profile" ]; then
        # no profile selected
        exit 0
    fi

    echo "Running $game with $profile profile"
    exec gamechest run --profile_id=$profile $game
}

main