| 1 | #!/bin/bash |
| 2 | set -eu |
| 3 | |
| 4 | # ------------------------------------------------------------------ |
| 5 | # Simple script that sets up desktop file for Castle Game Engine Editor |
| 6 | # in your home directory, so that you have a nice icon in your desktop |
| 7 | # (GNOME, MATE, KDE...) to start the editor. |
| 8 | # |
| 9 | # Relies on CASTLE_ENGINE_PATH being set |
| 10 | # (the current working directory then doesn't matter when you run this script, |
| 11 | # so you can do "cd ../doc/install/linux/ && ./install.sh" or you can do |
| 12 | # "../doc/install/linux/install.sh", it's all the same effect) |
| 13 | # or uses ../../../ . |
| 14 | # ------------------------------------------------------------------ |
| 15 | |
| 16 | if [ -z "${CASTLE_ENGINE_PATH:-}" ]; then |
| 17 | echo "Detecting CASTLE_ENGINE_PATH from current working dir." |
| 18 | CASTLE_ENGINE_PATH=`pwd` |
| 19 | CASTLE_ENGINE_PATH="`dirname \"${CASTLE_ENGINE_PATH}\"`" |
| 20 | CASTLE_ENGINE_PATH="`dirname \"${CASTLE_ENGINE_PATH}\"`" |
| 21 | CASTLE_ENGINE_PATH="`dirname \"${CASTLE_ENGINE_PATH}\"`" |
| 22 | fi |
| 23 | |
| 24 | echo "Setting up desktop file for Castle Game Engine in:" |
| 25 | echo " ${CASTLE_ENGINE_PATH}" |
| 26 | |
| 27 | DESKTOP_FILE="${CASTLE_ENGINE_PATH}/doc/install/linux/castle-editor.desktop" |
| 28 | if [ ! -f "${DESKTOP_FILE}" ]; then |
| 29 | echo "Error: Desktop file not found: ${DESKTOP_FILE}" |
| 30 | exit 1 |
| 31 | fi |
| 32 | |
| 33 | desktop-file-install --dir=${HOME}/.local/share/applications ${DESKTOP_FILE} |
| 34 | sed --in-place "s|Exec=.*|Exec=${CASTLE_ENGINE_PATH}/bin/castle-editor|g" ${HOME}/.local/share/applications/castle-editor.desktop |
| 35 | sed --in-place "s|Icon=.*|Icon=${CASTLE_ENGINE_PATH}/doc/pasdoc/logo/castle_game_engine_icon.svg|g" ${HOME}/.local/share/applications/castle-editor.desktop |
| 36 | |
| 37 | echo "Desktop file installed OK." |
| 38 | |
| 39 | # Debug: |
| 40 | #cat ${HOME}/.local/share/applications/castle-editor.desktop |