aboutsummaryrefslogtreecommitdiff
path: root/generate-multimc-desktop-files
diff options
context:
space:
mode:
authornea <romangraef@gmail.com>2022-03-25 17:03:40 +0100
committernea <romangraef@gmail.com>2022-03-25 17:03:40 +0100
commitb9c2cd251c4c5994484c6db8697bda9fc5b33cf1 (patch)
treece7e18ae6485a3b23d1503d079da5fa666ce7021 /generate-multimc-desktop-files
parentd9031203e22e4ef381c482b4594521323647487e (diff)
downloadscripts-master.tar.gz
scripts-master.tar.bz2
scripts-master.zip
gen polymcHEADmaster
Diffstat (limited to 'generate-multimc-desktop-files')
-rwxr-xr-xgenerate-multimc-desktop-files45
1 files changed, 29 insertions, 16 deletions
diff --git a/generate-multimc-desktop-files b/generate-multimc-desktop-files
index a16be8c..9c86270 100755
--- a/generate-multimc-desktop-files
+++ b/generate-multimc-desktop-files
@@ -4,10 +4,26 @@ 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")"
+
+
+create_desktop_file() {
+ cat <<EOF > "$HOME/.local/share/applications/multimc-$2-$3.desktop"
+[Desktop Entry]
+Name=MultiMC: $1
+Type=Application
+Categories=Game
+StartupWMClass=multimc
+Terminal=false
+Comment=Open MultiMC Instance
+GenericName=Minecraft
+Exec=$(which "$2") -l "$3"
+EOF
+}
+
+check_instance() {
+ if [[ (-d "$1") && (-f "$1/instance.cfg") ]]; then
+ echo "Scanning $1"
+ instanceid="$(basename -- "$1")"
name="$instanceid"
while IFS="=" read -r key value; do
case "$key" in
@@ -16,17 +32,14 @@ for instdir in ~/.local/share/multimc/instances/*; do
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
+ done <"$1/instance.cfg"
+ create_desktop_file "$name" "$2" "$instanceid"
fi
+}
+
+for instdir in ~/.local/share/multimc/instances/*; do
+ check_instance "$instdir" multimc
+done
+for instdir in ~/.local/share/PolyMC/instances/*; do
+ check_instance "$instdir" polymc
done