better installer and portable mode

This commit is contained in:
olcxja 2026-09-25 21:15:17 +02:00
commit 53a02cc7da
6 changed files with 97 additions and 79 deletions

41
tools/createshortcut.sh Normal file
View file

@ -0,0 +1,41 @@
#!/usr/bin/env bash
# PLWL portable shortcut creator — bundled inside the release tarball.
# Installs the icon into the user icon theme and creates a .desktop entry
# pointing at ./olcxja.plwl/olcxja.plwl in the folder this script lives in
# (portable mode — no files are copied anywhere).
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
APP_DIR="$HOME/.local/share/applications"
ICON_BASE="$HOME/.local/share/icons/hicolor"
ICON_SRC="$SCRIPT_DIR/olcxja.plwl.png"
EXE="$SCRIPT_DIR/olcxja.plwl/olcxja.plwl"
[ -f "$EXE" ] || { echo "createshortcut.sh: olcxja.plwl runtime not found in $SCRIPT_DIR" >&2; exit 1; }
chmod +x "$EXE" 2>/dev/null || true
echo "1. Installing icon..."
if [ -f "$ICON_SRC" ]; then
for dir in 16x16 32x32 48x48 256x256; do
mkdir -p "$ICON_BASE/$dir/apps"
cp "$ICON_SRC" "$ICON_BASE/$dir/apps/olcxja.plwl.png"
done
fi
echo "2. Creating shortcut..."
mkdir -p "$APP_DIR"
cat > "$APP_DIR/olcxja.plwl.desktop" << EOF
[Desktop Entry]
Type=Application
Name=PLWL
Comment=Portable Linux Wine Launcher
Exec="$EXE"
Icon=olcxja.plwl
Terminal=false
Categories=Game;
EOF
chmod +x "$APP_DIR/olcxja.plwl.desktop"
command -v update-desktop-database >/dev/null 2>&1 && update-desktop-database "$APP_DIR" 2>/dev/null || true
echo "Shortcut created: $APP_DIR/olcxja.plwl.desktop -> $EXE"

View file

@ -1,7 +1,5 @@
#!/usr/bin/env bash
# PLWL installer — bundled inside the release tarball (build/PLWL-<version>.tar.gz).
# Modeled after LarpixClient's install.sh: copies the app into ~/.local,
# registers a desktop shortcut and removes the extraction folder.
set -e
echo "WARNING: Make sure you don't run this script in a folder that contains anything more than PLWL"
@ -11,35 +9,59 @@ read -r -p "Press Enter to continue (or Ctrl+C, to cancel)..."
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
INSTALL_DIR="$HOME/.local/lib/PLWL"
BIN_DIR="$HOME/.local/bin"
INSTALL_DIR="$HOME/.local/bin/olcxja.plwl"
APP_DIR="$HOME/.local/share/applications"
ICON_BASE="$HOME/.local/share/icons/hicolor"
ICON_SRC="$SCRIPT_DIR/olcxja.plwl.png"
EXE="$INSTALL_DIR/olcxja.plwl/olcxja.plwl"
if [ "$SCRIPT_DIR" = "$INSTALL_DIR" ] || [ "$SCRIPT_DIR" = "$HOME" ] || [ "$SCRIPT_DIR" = "/" ]; then
echo "install.sh: refusing to run from '$SCRIPT_DIR'" >&2
exit 1
fi
case "$INSTALL_DIR/" in
"$SCRIPT_DIR"/*)
echo "install.sh: refusing to install into the extraction folder ('$SCRIPT_DIR')" >&2
exit 1
;;
esac
[ -f "$SCRIPT_DIR/olcxja.plwl/olcxja.plwl" ] || { echo "install.sh: olcxja.plwl runtime not found in $SCRIPT_DIR" >&2; exit 1; }
echo "1. Copying files..."
mkdir -p "$INSTALL_DIR" "$BIN_DIR" "$APP_DIR"
mkdir -p "$INSTALL_DIR" "$APP_DIR"
cp -r "$SCRIPT_DIR/." "$INSTALL_DIR/"
echo "2. Creating shortcut..."
sed -i "s|^Exec=.*|Exec=$BIN_DIR/plwl|" "$INSTALL_DIR/plwl.desktop"
mv "$INSTALL_DIR/plwl.desktop" "$APP_DIR/plwl.desktop"
chmod +x "$APP_DIR/plwl.desktop"
echo "2. Installing icon..."
if [ -f "$ICON_SRC" ]; then
for dir in 16x16 32x32 48x48 256x256; do
mkdir -p "$ICON_BASE/$dir/apps"
cp "$ICON_SRC" "$ICON_BASE/$dir/apps/olcxja.plwl.png"
done
fi
echo "3. Adding executable permissions..."
chmod +x "$INSTALL_DIR/plwl"
ln -sfn "$INSTALL_DIR/plwl" "$BIN_DIR/plwl"
echo "3. Creating shortcut..."
cat > "$APP_DIR/olcxja.plwl.desktop" << EOF
[Desktop Entry]
Type=Application
Name=PLWL
Comment=Portable Linux Wine Launcher
Exec="$EXE"
Icon=olcxja.plwl
Terminal=false
Categories=Game;
EOF
chmod +x "$APP_DIR/olcxja.plwl.desktop"
echo "4. Cleaning installation..."
rm -f "$INSTALL_DIR/install.sh"
echo "4. Adding executable permissions..."
chmod +x "$EXE"
echo "5. Cleaning installation..."
rm -f "$INSTALL_DIR/install.sh" "$INSTALL_DIR/createshortcut.sh"
command -v update-desktop-database >/dev/null 2>&1 && update-desktop-database "$APP_DIR" 2>/dev/null || true
echo "5. Installation completed. Cleaning up and launching..."
echo "6. Installation completed. Cleaning up and launching..."
rm -rf "${SCRIPT_DIR:?}"/*
nohup "$BIN_DIR/plwl" >/dev/null 2>&1 &
nohup "$EXE" >/dev/null 2>&1 &
disown 2>/dev/null || true
exit 0