summaryrefslogtreecommitdiffstats
path: root/gamechesttui
blob: 412ea333c73d7e0206d5fa5141ba3768e58c1b0f (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
41
42
#!/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 \
            --border --border-label=' Gamechest ' \
            --color 'border:#6699cc,label:#99ccff' \
    )"
    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 \
            --border --border-label=' Gamechest ' \
            --color 'border:#6699cc,label:#99ccff' \
    )"
    if [ -z "$profile" ]; then
        # no profile selected
        exit 0
    fi

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

main