Improvement for portable ide (linux)

Hy, I use the arduino ide version 1.8.15.
I had extracted the tar onto an USB-Stick and added the "portable" folder.
That works (in principle) as expected.

What was not so good is:

  1. If the IDE was started by double clicking the (shell script) "arduino" there will be an open terminal window, which is (most of the time) useless.
  2. When I had used the IDE at one PC, then move to another one (with a different mount point for the stick), my setting get's lost. I found that this is, because the file "preferences.txt" uses absolute path's, if the IDE was started from a different mount point all entries pointing to the previous path will be deleted :frowning: That includes the board & board-settings, the recently used sketches and so on..

To overcome these "problems", I had added 3 files to the root of the portable installation (beside the arduino file).

Unfortunately, new users can't upload files here, so I will describe what I have done:

  1. To avoid the terminal, I start the IDE via a ".desktop" file.
  2. To have an Icon for that ".desktop" file the script ArduinoStart.sh will copy an icon onto the PC, which I had added to the root of the portable installation. So when You use this installation the first time on a PC, there might by no icon for this file, but as soon as you have started it once, the "starter" will be decorated by the arduino icon.
  3. The adjustment of the (mount-)path inside "preferences.txt" was although done by the script ArduinoStart.sh.

This modification works for me on 3 different PCs with 3 different Linux-Installations (Ubuntu 14.04 LTS - 20.04 LTS)
I hope that was interesting for other users.

Here are the contents of the files "ArduinoStart.desktop" & "ArduinoStart.sh", the 3. file "arduino.png" should be any icon (of size 48) that You want to be shown.

ArduinoStart.desktop:

#!/usr/bin/env xdg-open

[Desktop Entry]
Version=1.0
Type=Application
Terminal=false
Icon=arduino
Exec=bash -c "cd \"$(dirname "\"%k\"")\"; bash "./ArduinoStart.sh
Name=ArduinoStart

ArduinoStart.sh:

#!/usr/bin/env bash

APPDIR="$(dirname -- "$(readlink -f -- "${0}")" )"

cd ${APPDIR}

###############################################################
# Install Icon if not already installed
###############################################################
if [ ! -f ~/.local/share/icons/hicolor/48x48/apps/arduino.png ]; then
  xdg-icon-resource install --novendor --context apps --size 48 arduino.png
fi

###############################################################
# Adjust path inside "preferences.txt" to current mount path
###############################################################

# Escape '/' and '.' inside ${1} into '\/' and '\.'
Escape()
 { 
  RES=${1//\//\\\/}; 
  RES=${RES//\./\\\.};
  echo ${RES};
 }
LAST_MOUNT_PATH=$(sed -e '/^last.ide.1.8.15.hardwarepath=/!d;s/last\.ide\.1\.8\.15\.hardwarepath\=//g;s/\/hardware//g' portable/preferences.txt)
LAST_MOUNT_PATH=$(Escape $LAST_MOUNT_PATH)
CURRENT_MOUNT_PATH=$(Escape $APPDIR)
sed -i -e "s/${LAST_MOUNT_PATH}/${CURRENT_MOUNT_PATH}/g" portable/preferences.txt

###############################################################
# Start Arduiino
###############################################################
./arduino &
1 Like

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.