Skip to content

New Linux AppImage Launcher for gnomel #356

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Prev Previous commit
Next Next commit
added Linux_Install.sh and desktop.template
  • Loading branch information
ArduinoShop committed May 6, 2021
commit b4db350ffbc80bf42a177a959f120e73c959a2f2
238 changes: 238 additions & 0 deletions Linux_Install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,238 @@
#!/bin/sh

############################################################################
## Linux install script for Arduino IDE 2.0 - contributed by Art Sayler ##
## https://github.com/arduinoshop ##
##
##
############################################################################

echo "\nLinux install script for the Arduino IDE 2.0 ${SCRIPT_PATH}\n"

MODE=U
YN=n
RESOURCE_NAME=arduino-arduinoide2
RED='\033[0;31m'
NOCOLOR='\033[0m'

if [ -z $1 ]
then
echo no option selected - defaulting to single user instalation
echo "usage: ./Linux_Install.sh [local] | [ulocal]"
echo " local - installs IDE for user $USER only ( default if no option given )"
echo " ulocal - uninstall IDE from user $USER"
echo "usage: sudo ./Linux_Install.sh [system] | [usystem]"
echo " system - install IDE systemwide for all users"
echo " usystem - uninstall IDE systemwide from all users\n"
echo "Both local and system installations may be used on the same computer"
echo "for example - a stable release installed systemwide and a nightly for a development user\n"

MSG="Install IDE 2.0 for user $USER only?"

elif [ $1 = local ]
then
MSG="Install IDE 2.0 for user $USER only?"
elif [ $1 = ulocal ]
then
MSG="UnInstall IDE 2.0 from user $USER?"
MODE=u
elif [ $1 = usystem ]
then
MSG="UnInstall IDE 2.0 system wide (all users will be affected)?"
MODE=s
elif [ $1 = system ]
then
MSG="Install IDE 2.0 system wide (all users will have access)?"
MODE=S
fi

# Get absolute path from which this script file was executed
# (Could be changed to "pwd -P" to resolve symlinks to their target)
SCRIPT_PATH=$( pwd -P )
LIB_PATH=$SCRIPT_PATH
EXE_PATH=$SCRIPT_PATH
# echo S_PATH = $SCRIPT_PATH

# Install by simply copying desktop file (fallback)
simple_install_f() {
echo
# Using Simple - MODE = $MODE
###### Remove local user installation

if [ $MODE = u ]
then
echo Uninstalling IDE 2.0 from user $USER
echo "Deleting ${HOME}/.local/share/applications/${RESOURCE_NAME}l.desktop"
rm ${HOME}/.local/share/applications/${RESOURCE_NAME}l.desktop

echo "Deleting ${HOME}/.local/lib/${RESOURCE_NAME}"
rm -rf ${HOME}/.local/lib/${RESOURCE_NAME}

echo "Deleting ${HOME}/.local/bin/${RESOURCE_NAME}"
rm ${HOME}/.local/bin/${RESOURCE_NAME}

echo "Installation directory and it's contents including this script can be removed"
read -p "Delete directory ${SCRIPT_PATH}? (YES for the affirmative)" YN
if [ -z $YN ]
then
echo exiting; exit
elif [ $YN = YES ]
then
echo "Removing Directory ${SCRIPT_PATH}"
fi
fi

###### Perform local user only installation
if [ $MODE = U ]
then
echo "For a more professional installation... and to remove clutter"
echo "in ${SCRIPT_PATH}\nyou have the option to move these files."
read -p "Move downloaded files to ~/.local/bin and lib ? (Y/N) " YN
if [ -z $YN ]
then
YN=n; echo "Installion files will not be copied."
fi

LIB_PATH=${HOME}/.local/lib/${RESOURCE_NAME}
EXE_PATH=${HOME}/.local/bin

if [ $YN = Y ] || [ $YN = y ]
then
mkdir -p $LIB_PATH
echo -n "Copying files... "
cp -rf * ${HOME}/.local/lib/${RESOURCE_NAME}
echo "Files copied...\n"
fi

mkdir -p "${HOME}/.local/bin"
rm -f ${HOME}/.local/bin/${RESOURCE_NAME}
ln -s ${HOME}/.local/lib/${RESOURCE_NAME}/arduino-ide ${HOME}/.local/bin/${RESOURCE_NAME}

# Create a temp dir accessible by all users
TMP_DIR=`mktemp --directory`

# Create *.desktop file using the existing template file

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the icon and desktop file should follow the proper app-id convention, like the one used for flathub.

See https://specifications.freedesktop.org/desktop-entry-spec/latest/ar01s02.html#desktop-file-id

The id should be cc.arduino.arduinoide2 as suggested for the flathub submission.
Note that if you app register an app-id for DBus use (like Qt or Gtk do) then that's the one that should be used and coordinate with the flathub submission (flathub/flathub#3176 ) to changed it there too.

With that the .desktop should be cc.arduino.arduinoide2.desktop and the icon should be cc.arduino.arduinoide2.png. Note: if you have a SVG icon it would be so much better.

A 48x48 icon is way too small. 128x128 is the current standard.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a note the flatpak pr request was updated to change the id to cc.arduino.IDE2 to match what is used here:

appId: 'cc.arduino.IDE2',

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

then that's what shall be used here too.

sed -e "s,<BINARY_LOCATION>,${EXE_PATH}/${RESOURCE_NAME},g" \
-e "s,<id>,local,g" \
-e "s,<ICON_NAME>,${LIB_PATH}/arduino2.png,g" "${SCRIPT_PATH}/desktop.template" > "${TMP_DIR}/${RESOURCE_NAME}l.desktop"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of using sed you should use destkop-file-edit. It's way easier to understand and exactly designed for that. There is also desktop-file-install to install it.


mkdir -p "${HOME}/.local/share/applications"
cp "${TMP_DIR}/${RESOURCE_NAME}l.desktop" "${HOME}/.local/share/applications/"
echo "Installing Launcher and Icon\n"

echo "Launcher and Icon Installed\n"
echo "Go to \"Show Application\" ( button in lower left / \"Windows Key\")"
echo "Search for \"Arduino\" - you will see an Icon labeled \"2.0 system\""
echo "click on this icon to run the IDE or right-click to add it to the Dock\n"

# mkdir -p "${HOME}/.local/share/metainfo"
# cp "${SCRIPT_PATH}/lib/appdata.xml" "${HOME}/.local/share/metainfo/${RESOURCE_NAME}.appdata.xml"

# Clean up temp dir
rm "${TMP_DIR}/${RESOURCE_NAME}l.desktop"
rmdir "${TMP_DIR}"
fi

######## System Wide Install / UnInstall
if [ $MODE = s ] || [ $MODE = S ]
then
if [ $USER != root ]
then
echo "$RED You must be SuperUser to make SystemWide changes$NOCOLOR\007"
echo "Use sudo ./Linux_Install.sh [option]\n"
exit
fi
fi

######## System Wide UnInstall

if [ $MODE = s ]
then
echo Uninstalling IDE 2.0 systemwide

if [ -f /usr/local/share/applications/${RESOURCE_NAME}.desktop ]
then
echo "Deleting /usr/local/share/applications/${RESOURCE_NAME}.desktop"
rm /usr/local/share/applications/${RESOURCE_NAME}.desktop
fi

if [ -f /usr/local/bin/${RESOURCE_NAME} ]
then
echo "Deleting /usr/local/bin/${RESOURCE_NAME}"
rm /usr/local/bin/${RESOURCE_NAME}
fi

if [ -d /usr/local/lib/${RESOURCE_NAME} ]
then
echo "Deleting Directory /usr/local/lib/${RESOURCE_NAME}"
rm -rf /usr/local/lib/${RESOURCE_NAME}
else
echo "/usr/local/lib/${RESOURCE_NAME} does not exist"
fi

echo "Installation directory and it's contents including this script can be removed"
read -p "Delete directory ${SCRIPT_PATH} (YES)? " YN
if [ -z $YN ]
then
echo "Directory ${SCRIPT_PATH} will not be removed"
elif [ $YN != YES ]
then
echo "Directory ${SCRIPT_PATH} will not be removed"
else
echo "Removing Directory ${SCRIPT_PATH}"
fi
fi

###### Perform SystemWide installation
if [ $MODE = S ]
then
echo -n "Copying downloaded files to /usr/local/lib... "
LIB_PATH=/usr/local/lib/${RESOURCE_NAME}
EXE_PATH=/usr/local/bin
mkdir -p $LIB_PATH
cp -rf * $LIB_PATH
rm -f $EXE_PATH/${RESOURCE_NAME}
ln -s $LIB_PATH/arduino-ide $EXE_PATH/${RESOURCE_NAME}
echo "Files copied...\n"

# Create a temp dir accessible by all users
TMP_DIR=`mktemp --directory`

# Create *.desktop file using the existing template file
sed -e "s,<BINARY_LOCATION>,${EXE_PATH}/${RESOURCE_NAME},g" \
-e "s,<id>,system,g" \
-e "s,<ICON_NAME>,${LIB_PATH}/arduino2.png,g" "${SCRIPT_PATH}/desktop.template" > "${TMP_DIR}/${RESOURCE_NAME}.desktop"

mkdir -p "${HOME}/.local/share/applications"
cp "${TMP_DIR}/${RESOURCE_NAME}.desktop" "/usr/local/share/applications/"
echo "Launcher and Icon Installed\n"
echo "Go to \"Show Application\" ( button in lower left / \"Windows Key\")"
echo "Search for \"Arduino\" - you will see an Icon labeled \"2.0 system\""
echo "click on this icon to run the IDE or right-click to add it to the Dock\n"

# mkdir -p "${HOME}/.local/share/metainfo"
# cp "${SCRIPT_PATH}/lib/appdata.xml" "${HOME}/.local/share/metainfo/${RESOURCE_NAME}.appdata.xml"

# Clean up temp dir
rm "${TMP_DIR}/${RESOURCE_NAME}.desktop"
rmdir "${TMP_DIR}"
fi
}

# --- main Script starts here ---

read -p "$MSG (Y/N) " YN

if [ -z $YN ]
then
echo OK - exiting
exit
elif [ $YN = n ]
then
echo OK - No is No... exiting
exit
fi

simple_install_f

exit
12 changes: 12 additions & 0 deletions desktop.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[Desktop Entry]
Type=Application
Name=IDE <id>
GenericName=Arduino IDE
Comment=Open-source electronics prototyping platform
Exec=<BINARY_LOCATION>
Icon=<ICON_NAME>
Terminal=false
Categories=Development;IDE;Electronics;
MimeType=text/x-arduino;
Keywords=embedded electronics;electronics;avr;microcontroller;
StartupWMClass=processing-app-Base