I work on a large (42″) 4k display .. yes, not really a monitor, but a nice HD TV with HDMI inputs. I absolutely love it as my primary work display.
My one issue is that within Eclipse, the icons are typically very tiny, with good way to scale them. I did come across this post here, but all of the solutions did not work for me (Ubuntu 21.10). With the swt settings changes, I had grossly malformed screens (black bars everywhere, making the UI completely unusable). The one solution in that post that did work, mostly, was the python scripting to actually scale up the icons. I got tired of launching a python shell to do this, though, and I wanted to poke at bash shell scripting again, so I came up with the following 2 scripts.
The first is “scaleImages.sh”; run from the root directory of your Eclipse install, this will scale the images by the configured percentage. Any image that is modified is backed up first (being moved to a renamed file, <original name>-orig.png). The script has commented out code to scale images that already have a 2x scaled version, too — for me, it didn’t make sense to scale those, but I wanted to leave it in the script just in case. The script also supports a list of exclusions, so images that already appear to be large enough (there are a few) aren’t resized (for these particular icons, I think a larger size looks terrible).
#!/bin/bash
function contains() {
array=${@:1:$#-1}
[[ "$array" =~ "${@: -1}" ]] && echo 0 || echo 1
}
scaledPercent="100%"
normalPercent="200%"
excludes=()
excludes+=( "new_wiz.png" )
excludes+=( "boot-icon.png" )
excludes+=( "opentype.png" )
excludes+=( "open-task.png" )
excludes+=( "search.png" )
excludes+=( "save_edit.png" )
excludes+=( "saveall_edit.png" )
excludes+=( "link_to_editor.png" )
excludes+=( "collapseall.png" )
excludes+=( "link_to_editor.png" )
excludes+=( "filter_ps.png" )
#echo ${excludes[@]}
#echo $(contains "${excludes[@]}" "new_wiz.png")
#echo $(contains ${excludes[@]} bar)
#exit 1;
for orig in $( find . -name "*.png" )
do
# echo $orig
backup=`echo $orig | sed 's/\.png/-orig\.png/'`
scaled=`echo $orig | sed 's/\.png/@2x\.png/'`
base=`basename $orig`
echo -n $orig $base" "
shouldExclude=$(contains ${excludes[@]} $base)
echo -n "shouldExclude = "$shouldExclude" "
if [ $shouldExclude -eq 1 ]
then
if test -x $scaled
then
# If a scaled version of the file exists, only scale by a smaller percentage
echo " ... has enlarged, skipping scaling"
# echo " ... has enlarged, scaling that by $scaledPercent"
# convert $backup -resize $scaledPercent $orig
else
# Back up the file
mv $orig $backup
# Scaled version of the file doesn't exist, so scale by a higher percentage
echo " ... no enlargement, scaling orig by $normalPercent"
convert $backup -resize $normalPercent $orig
fi
else
echo "... excluding because it's in the exclude list"
fi
done
The next script is the necessary “reversal” script. If you should need to revert the images back to the original, just run this script. Any file with “-orig.png” will be moved back to it’s original name, restoring the Eclipse icons to their original size.
#!/bin/bash
for orig in $( find . -name "*-orig.png" )
do
echo $orig
new=`echo $orig | sed 's/-orig\.png/\.png/'`
mv $orig $new
done
And there you have it. Perfect? No … probably far from it. I could do this in a single script, and restore via a command-line argument. This is good enough for now, though.