Skip to content

Instantly share code, notes, and snippets.

@zyoutz
Last active March 2, 2021 10:12
Show Gist options
  • Save zyoutz/b39c9ca0e867f62c58ec5fc223ae1025 to your computer and use it in GitHub Desktop.
Save zyoutz/b39c9ca0e867f62c58ec5fc223ae1025 to your computer and use it in GitHub Desktop.
Set icons for JetBrains Toolbox installed Applications (eg. IntelliJ, Goland, etc) on Chrome OS

This gist is a simple bash script for properly setting the icons for JetBrains applications installed with JetBrains Toolbox app on Chrome OS using Crostini (Linux Apps). Prior to running this script, make sure to install the Linux version of JetBrains Toolbox on your Chromebook:

  1. Download JetBrains Toolbox and share Downloads for Linux use
  2. Extract content: sudo tar -xvf jetbrains-toolbox-1.16.6067.tar.gz -C /opt/
  3. Run toolbox: cd /opt/jetbrains-toolbox-1.16.6067/ ; ./jetbrains-toolbox
  4. Install the JetBrains applications you expect to use
  5. Run configuration script: ./configure.sh

Once run, icons should now properly load instead of the default penguin icon. Unfortunatley every time a new update is applied to your IDEs this may be necessary, but at least you can quickly run the script instead of manually updating the desktop files.

#!/bin/bash
# Set if .mime.list doesn't exist in user home
if [ -f "~/.mime.types" ]; then
echo "Copying /etc/mime.types to user home"
cp /etc/mime.types ~/.mime.types
fi
# Make icon directory for storing if doesn't exist
ICONS_DIR=~/.local/share/icons
#if [ ! -d ~/.local/share/icons ]; then
if [[ ! -d $ICONS_DIR ]]; then
echo "Creating icons directory: $ICONS_DIR"
mkdir $ICONS_DIR
fi
# Set png icon for each Jetbrain application installed
for f in ~/.local/share/applications/jetbrains-* ; do
filename="$(basename -- $f)"
if [[ $f =~ "toolbox" ]]; then
icon_path="$ICONS_DIR/toolbox.png"
if [[ ! -f $ICONS_DIR/toolbox.png ]]; then
echo "Adding toolbox.png icon included with gist" # No png included with toolbox installation
cp ./toolbox.png $icon_path
fi
echo "Updating icon for $filename to $icon_path"
sed -i "s|Icon=.*|Icon=$icon_path|" $f
continue
fi
# Get location of executable
exec="$(grep Exec $f | sed -e "s/^Exec=\"//" | sed -e "s/\".*//")"
# Replace extension with png
app_icon_path="${exec/".sh"/".png"}"
if [ -f $app_icon_path ]; then
# Copy to icons directory
cp $app_icon_path $ICONS_DIR
icon_name="$(basename -- $app_icon_path)"
icon_path="$ICONS_DIR/$icon_name"
echo "Updating icon for $filename to $icon_path"
sed -i "s|Icon=.*|Icon=$icon_path|" $f
fi
done
echo "Triggering refresh of icons"
sudo touch /usr/share/applications/.garcon_trigger
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment