08-18-2021, 01:21 PM
(This post was last modified: 08-19-2021, 04:34 PM by fbarbe.
Edit Reason: More complete guide
)
Here's an updated version of the script that also takes connectivity into account, and has a visual output with zenity.
To turn this script into an application that can be placed on the desktop and integrated in the system, you can create the following ludii.desktop file
Change Ludii.sh to the absolute path of your Ludii script and ludii.png to the absolute path of the Ludii icon (which can be downloaded here)
You can then make the desktop script executable either with chmod +x ludii.desktop or by right clicking and place it in your desktop and /usr/share/applications .
Enjoy!
Code:
#!/bin/sh
LUDII_PATH=./ #change this to the directory where you want to run Ludii
LUDII_SERVER_VERSION=$(curl -s -N https://ludii.games/download.php | grep -o -m 1 "Ludii.*\.jar")
LUDII_LOCAL_VERSION=$(ls $LUDII_PATH | grep -o -m 1 "Ludii.*\.jar")
if [ "${LUDII_SERVER_VERSION}" = "" ]; then
echo "Unable to determine latest Ludii version"
else if [ "${LUDII_SERVER_VERSION}" != "${LUDII_LOCAL_VERSION}" ]; then
echo "Found newer version of Ludii: $LUDII_SERVER_VERSION";
echo "Downloading newer version..."
wget --progress=bar:force -q "https://ludii.games/downloads/$LUDII_SERVER_VERSION" -P $LUDII_PATH | zenity --title="Downloading $LUDII_SERVER_VERSION" --progress;
if [ $? -eq 0 ]; then
echo "Removing old version..."
rm -f "$LUDII_PATH$LUDII_LOCAL_VERSION";
else
echo "Unable to retrieve from server (code $?)"
fi
else
echo "Your version is up to date"
fi
fi
LUDII_LOCAL_VERSION=$(ls $LUDII_PATH | grep -o -m 1 "Ludii.*\.jar")
if [ "${LUDII_LOCAL_VERSION}" != "" ]; then
echo "Launching $LUDII_LOCAL_VERSION"
chmod +x "$LUDII_PATH$LUDII_LOCAL_VERSION";
cd $LUDII_PATH;
java -jar "$LUDII_LOCAL_VERSION" > /dev/null &
else
echo "No ludii file found"
fi
To turn this script into an application that can be placed on the desktop and integrated in the system, you can create the following ludii.desktop file
Code:
[Desktop Entry]
Type=Application
Exec=sh Ludii.sh
StartupNotify=true
GenericName=Ludii
Icon=ludii.png
Name[en_GB]=Ludii
Change Ludii.sh to the absolute path of your Ludii script and ludii.png to the absolute path of the Ludii icon (which can be downloaded here)
You can then make the desktop script executable either with chmod +x ludii.desktop or by right clicking and place it in your desktop and /usr/share/applications .
Enjoy!