Skip to content
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

New Linux AppImage Launcher for gnomel #356

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
227 changes: 227 additions & 0 deletions Linux_Install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,227 @@
#!/bin/sh

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

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

echo "\nLinux_Install.sh ver. $VERSION for the Arduino IDE 2.0\n"

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


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

echo

###### 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}"
cd ..
rm -rf ${SCRIPT_PATH}
fi
fi

###### Perform local user only installation
if [ $MODE = U ]
then

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 or hit \"Super/Windows Key\")"
echo "Search for \"Arduino\" - you will see an Icon labeled \"2.0 $1\""
echo "click on this icon to run the IDE or right-click to add it to the Dock\n"

# 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}"
cd ..
rm -rf ${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 or hit \"Super/Windows Key\")"
echo "Search for \"Arduino\" - you will see an Icon labeled \"2.0 $1\""
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

exit
39 changes: 39 additions & 0 deletions Linux_Install_ReadME.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@

# Arduino IDE 2.x (beta) Linux Installer by Art Sayler - https://ArduinoShop.ca

This bash script installs the Arduino IDE 2.0 on the Linux Desktop..

-- May 5 2021 - tested on Gnome3 / Ubuntu 21.04 ( Hippo )
-- May 6 2021 - tested on Gnome3 / Ubuntu 20.10 ( Gorilla )
-- May 6 2021 - tested on Gnome3 / Debian 10 ( Buster )
-- May 7 2021 - tested on LXQt / Lubuntu 21.04 ( Hippo )

# Instructions

1). open a termina window from the directory where you installed IDE 2.0.

2). type ./Linux_Install.sh [option] where option is one of the following:
local - installs the IDE for the local user only ( default if no option is given ).
system - installs the IDE system wide for all users.
ulocal - uninstalls the IDE from the current user.
usystem - uninstalls the IDE system wide from all users.

3). go to "Show Applications" ( button in lower left corner - or hit Home/Windows key )

4). type Arduino in the search bar - you should see an icon for Arduino 2.0

5). click on the icon to run the IDE - or right-click to add it to the dock.

NoTE: for LXQt/Lubuntu - the IDE will be accessible from the menu under "Programming"
an icon will also appear on the desktop with a warning symbol
you can delete the icon or right-click to enable "trusted mode"


====================================================================================================================


This open source code was written by the Arduino team and is maintained on a daily basis with the help of the community. We invest a considerable amount of time in development, testing and optimization. Please consider donating to support our work, as well as buying original Arduino boards which is the best way to make sure our efforts can continue in the long term.

## License

The code contained in this repository and the executable distributions are licensed under the terms of the GNU AGPLv3. The executable distributions contain third-party code licensed under other compatible licenses such as GPLv2, MIT and BSD-3. If you have questions about licensing please contact us at license@arduino.cc
Binary file added arduino2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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