aboutsummaryrefslogtreecommitdiff
path: root/generate-multimc-desktop-files
blob: a16be8c28125de72f1ef0f4616a2c285016809f9 (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
#!/bin/bash

echo "Deleting old .desktop files"
rm ~/.local/share/applications/multimc-*.desktop

echo "Seeking instances"
for instdir in ~/.local/share/multimc/instances/*; do
  if [[ (-d "$instdir") && (-f "$instdir/instance.cfg") ]]; then
    echo "Scanning $instdir"
    instanceid="$(basename -- "$instdir")"
    name="$instanceid"
    while IFS="=" read -r key value; do
      case "$key" in
      name)
        echo "Instance Name: $value"
        name="$value"
        ;;
      esac
    done <"$instdir/instance.cfg"
    cat <<EOF > "$HOME/.local/share/applications/multimc-$instanceid.desktop"
[Desktop Entry]
Name=MultiMC: $name
Type=Application
Categories=Game
StartupWMClass=multic
Terminal=false
Comment=Open MultiMC Instancew
GenericName=Minecraft
Exec=$(which multimc) -l "$instanceid"
EOF
  fi
done