Skip to content

Instantly share code, notes, and snippets.

@wwwehr
Last active December 12, 2023 22:40
Show Gist options
  • Save wwwehr/dbcb3e7b47c63602a6ebff886ea87cd7 to your computer and use it in GitHub Desktop.
Save wwwehr/dbcb3e7b47c63602a6ebff886ea87cd7 to your computer and use it in GitHub Desktop.
Melodics URL xdg-open handler for Linux + Lutris
#!/bin/bash
set -e
set -o pipefail
LAUNCH_HANDLER="run-melodics-with-scheme.sh"
XDG_DESKTOP_FILE="melodics-launcher.desktop"
GAME_ID=$(lutris -l | grep -i melodics | awk '{print $1}')
DYN_SCRIPT=$(mktemp)
lutris -b "$DYN_SCRIPT" "$GAME_ID"
awk 'NR>1{print prev} {prev=$0} END{print $0 " \"$1\""}' "$DYN_SCRIPT" >"$LAUNCH_HANDLER"
chmod +x "$LAUNCH_HANDLER"
cat <<EOF >"$XDG_DESKTOP_FILE"
[Desktop Entry]
Name=Medlodics Launcher
Exec=$(realpath $LAUNCH_HANDLER) %u
Type=Application
Terminal=false
MimeType=x-scheme-handler/melodics;
EOF
xdg-desktop-menu install "$XDG_DESKTOP_FILE"
xdg-mime default "$XDG_DESKTOP_FILE" x-scheme-handler/melodics
echo "🥁 Login callback handler installed! Lutris + Melodics is READY TO ROCK 🎹"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment