install_or_remove_menuitem.sh 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #!/bin/bash
  2. # Adds a custom menuitem for AssaultCube to your Desktop's launcher.
  3. CUBE_DIR=$(dirname "$(readlink -f "${0}")")
  4. CUBE_EXEC=assaultcube.sh
  5. LAUNCHERPATH="${HOME}/.local/share/applications/"
  6. LAUNCHERFILE=assaultcube_dev.desktop
  7. LAUNCHERTITLE="Assaultcube v1.2dev"
  8. # Remove existing menuitem, if it exists:
  9. EXISTINGEXEC=`find "${LAUNCHERPATH}" -name "assaultcube*" | xargs`
  10. if [ "$EXISTINGEXEC" != "" ]; then
  11. echo "The following menuitem(s) currently exist:"
  12. echo "$EXISTINGEXEC"
  13. read -p "Would you like them all to be deleted? (y/N): " -r REPLY
  14. if [ "$REPLY" = "y" ] || [ "$REPLY" = "yes" ] || [ "$REPLY" = "Y" ] || [ "$REPLY" = "YES" ]; then
  15. find "${LAUNCHERPATH}" -name "assaultcube*" -delete
  16. echo "Deleted menuitems as requested." && echo ""
  17. exit 0
  18. else
  19. echo "The existing menuitems will remain." && echo ""
  20. fi
  21. fi
  22. mkdir -p "${LAUNCHERPATH}"
  23. cat > "${LAUNCHERPATH}"${LAUNCHERFILE} << EOF
  24. [Desktop Entry]
  25. Version=1.0
  26. Type=Application
  27. Name=$LAUNCHERTITLE
  28. Keywords=assaultcube;game;fps;
  29. GenericName=First Person Shooter Game
  30. Categories=Game;ActionGame;Shooter;
  31. Terminal=false
  32. StartupNotify=false
  33. Exec=$CUBE_DIR/$CUBE_EXEC
  34. Icon=$CUBE_DIR/packages/misc/icon.png
  35. Comment=A multiplayer, first-person shooter game, based on the CUBE engine. Fast, arcade gameplay.
  36. EOF
  37. chmod +x "${LAUNCHERPATH}"${LAUNCHERFILE}
  38. if [ -x "${LAUNCHERPATH}"${LAUNCHERFILE} ]; then
  39. echo "An AssaultCube menuitem has been successfully created at"
  40. echo "${LAUNCHERPATH}"${LAUNCHERFILE}
  41. exit 0
  42. else
  43. echo "For some reason, we're unable to install an AssaultCube menuitem."
  44. exit 1
  45. fi