Professional Documents
Culture Documents
#!/bin/sh
# This script adds a menu item, icons and mime type for Arduino for the current
# user. If possible, it will use the xdg-utils - or fall back to just creating
# and copying a desktop file to the user's dir.
# If called with the "-u" option, it will undo the changes.
# Get absolute path from which this script file was executed
# (Could be changed to "pwd -P" to resolve symlinks to their target)
SCRIPT_PATH=$( cd $(dirname $0) ; pwd )
cd "${SCRIPT_PATH}"
# Clean up
rm "${TMP_DIR}/${RESOURCE_NAME}.desktop"
rmdir "$TMP_DIR"
# Launching arduino-linux-setup.sh script
#./arduino-linux-setup.sh $(whoami)
mkdir -p "${HOME}/.local/share/applications"
cp "${TMP_DIR}/${RESOURCE_NAME}.desktop" "${HOME}/.local/share/applications/"
mkdir -p "${HOME}/.local/share/metainfo"
cp "${SCRIPT_PATH}/lib/appdata.xml" "${HOME}/.local/share/metainfo/$
{RESOURCE_NAME}.appdata.xml"
# Remove icons
xdg-icon-resource uninstall --size 16 ${RESOURCE_NAME}
xdg-icon-resource uninstall --size 24 ${RESOURCE_NAME}
xdg-icon-resource uninstall --size 32 ${RESOURCE_NAME}
xdg-icon-resource uninstall --size 48 ${RESOURCE_NAME}
xdg-icon-resource uninstall --size 64 ${RESOURCE_NAME}
xdg-icon-resource uninstall --size 72 ${RESOURCE_NAME}
xdg-icon-resource uninstall --size 96 ${RESOURCE_NAME}
xdg-icon-resource uninstall --size 128 ${RESOURCE_NAME}
xdg-icon-resource uninstall --size 256 ${RESOURCE_NAME}
if [ -f "${HOME}/.local/share/applications/${RESOURCE_NAME}.desktop" ]; then
rm "${HOME}/.local/share/applications/${RESOURCE_NAME}.desktop"
fi
if [ -f "${HOME}/.local/share/metainfo/${RESOURCE_NAME}.appdata.xml" ]; then
rm "${HOME}/.local/share/metainfo/${RESOURCE_NAME}.appdata.xml"
fi
if [ -f "${XDG_DESKTOP_DIR}/arduino.desktop" ]; then
rm "${XDG_DESKTOP_DIR}/arduino.desktop"
fi
if [ -f "${XDG_DESKTOP_DIR}/${RESOURCE_NAME}.desktop" ]; then
rm "${XDG_DESKTOP_DIR}/${RESOURCE_NAME}.desktop"
fi
if [ -d "${HOME}/.local/share/applications" ]; then
if command -v update-desktop-database > /dev/null; then
update-desktop-database "${HOME}/.local/share/applications"
fi
fi
if [ -d "${HOME}/.local/share/mime" ]; then
if command -v update-mime-database > /dev/null; then
update-mime-database "${HOME}/.local/share/mime"
fi
fi
exit 0