Skip to content

Instantly share code, notes, and snippets.

@4piu
Last active October 25, 2019 07:57
Show Gist options
  • Save 4piu/ebd1d13275affeac099d9adc221d571f to your computer and use it in GitHub Desktop.
Save 4piu/ebd1d13275affeac099d9adc221d571f to your computer and use it in GitHub Desktop.
This script converts and changes the Jetbrains app icons in desktop file to png, in order to fix missing icon in the Application laucher of KDE Plasma
#!/bin/bash
# This script converts and changes the Jetbrains app icons to png in order to fix missing icon in the Application laucher of KDE Plasma
IFS=$(echo -en "\n\b")
DESKTOP=~/.local/share/applications/jetbrains-*.desktop
if ! [ -x "$(command -v convert)" ]; then
echo 'Error: ImageMagick is not installed. ' >&2
exit 1
fi
for file in $DESKTOP
do
echo -e "\nProcessing $(basename ${file})"
svg=`grep -Poi '(?<=Icon=).+' ${file}`
if [[ ${svg##*.} != "svg" ]]; then
echo "Not SVG icon, skipped: ${svg}"
continue
fi
png=${svg%%.svg}.png
if [[ -f "${png}" ]]; then
echo "'Image convert skipped: file exists '${png}'"
else
echo "Converting '${svg}' to '${png}'"
convert -density 1200 -resize 200 -background none ${svg} ${png}
fi
sed -i "s|${svg}|${png}|g" ${file}
done
echo -e "\nJob done. "
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment