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

Improvement for portable ide (linux) #11621

Open
gneiss15 opened this issue Jun 30, 2021 · 0 comments
Open

Improvement for portable ide (linux) #11621

gneiss15 opened this issue Jun 30, 2021 · 0 comments
Labels
Component: IDE The Arduino IDE feature request A request to make an enhancement (not a bug fix) OS: Linux Specific to the Linux version of the Arduino IDE

Comments

@gneiss15
Copy link

I had already reported my idea for an improvement on the arduino forum.
see: https://forum.arduino.cc/t/improvement-for-portable-ide-linux/875534

Even if the part with "icon-copying' (see below) was something that may be 'bad' for some users, the rest should be helpful for all users of a portable installation for Linux.

Prerequisites:

  • 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 😦 That includes the board & board-settings, the recently used sketches and so on..

Here is what I have done to improve my portable installation:
To overcome these "problems", I had added 3 files to the root of the portable installation (beside the arduino file).

  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 &
@per1234 per1234 added Component: IDE The Arduino IDE feature request A request to make an enhancement (not a bug fix) OS: Linux Specific to the Linux version of the Arduino IDE labels Jun 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: IDE The Arduino IDE feature request A request to make an enhancement (not a bug fix) OS: Linux Specific to the Linux version of the Arduino IDE
Projects
None yet
Development

No branches or pull requests

2 participants