Skip to content

Instantly share code, notes, and snippets.

@Nokius
Created September 30, 2016 14:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Nokius/bc50c5647d253bf3150c9fbc62602acf to your computer and use it in GitHub Desktop.
Save Nokius/bc50c5647d253bf3150c9fbc62602acf to your computer and use it in GitHub Desktop.
[SFOS] create z1.0-large icons
#!/bin/bash
# Check that we run this as root
whoami | grep -q root || { echo needs to run as root. quitting; exit; }
# check that proper scale is given as argument
if [[ ! "$1" =~ "^[0-2]\.[0-9]{1,2}$" ]] ; then
echo missing argument. tell which icon shaĺl be build for large screens quitting
exit
fi
ICONS=$1
echo converting z$ICONS to z$ICONS-large
# Check theme path
if [ -d "/usr/share/themes/sailfish-default/meegotouch/z$ICONS" ]; then
THEMEPATH=sailfish-default
elif [ -d "/usr/share/themes/jolla-ambient/meegotouch/z$ICONS" ]; then
THEMEPATH=jolla-ambient
else
echo theme path not found. quitting
exit
fi
echo Using $THEMEPATH
# copy
echo copying
cp -r /usr/share/themes/$THEMEPATH/meegotouch/z$ICONS /usr/share/themes/$THEMEPATH/meegotouch/z$ICONS-large
if [ -d "/usr/share/themes/$THEMEPATH/meegotouch/z$ICONS-large" ] ; then
echo "$THEMEPATH for z$ICONS-large created"
fi
#delete old icons
rm -r /usr/share/themes/$THEMEPATH/meegotouch/z$ICONS
echo ""
echo deleted z$ICONS folder
echo ""
# convert
echo ""
echo converting
echo ""
#Attention!
#Adjust the resulution for other icon resulutions
#z1.0-large z1.0
#40x40 64x64
#42x42 48x48
#60x60 96x96
#85x85 86x86
#128x128 144x144
cd /usr/share/themes/$THEMEPATH/meegotouch/z$ICONS-large/icons/
for f in *.png
do
FILE=$(identify $f)
NAME=$(echo $FILE | grep -o -P '(?<=).*(?=\sP)')
Height=$(echo $FILE | grep -o -P '(?<=PNG\s).*(?=x[0-9]+ )')
Width=$(echo $FILE | grep -o -P '(?<=[0-9]x).*(?=\s[0-9]+x)')
if [[ $Height -eq 64 && $Width -eq 64 ]]; then
convert $NAME -resize 40x40 $NAME
echo "$NAME resize to 40x40"
elif [[ $Height -eq 48 && $Width -eq 48 ]]; then
convert $NAME -resize 42x42 $NAME
echo "$NAME resize to 42x42"
elif [[ $Height -eq 96 && $Width -eq 96 ]]; then
convert $NAME -resize 60x60 $NAME
echo "$NAME resize to 60x60"
elif [[ $Height -eq 86 && $Width -eq 86 ]]; then
convert $NAME -resize 85x85 $NAME
echo "$NAME resize to 85x85"
elif [[ $Height -eq 144 && $Width -eq 144 ]]; then
convert $NAME -resize 128x128 $NAME
echo "$NAME resize to 128x128"
#else
echo "$NAME no changes needed"
fi
done
# setting new ICON-RES
echo ""
echo unlocking pixel-ratio
echo ""
rm -f /etc/dconf/db/vendor.d/locks/silica-configs.txt
dconf update
su -l nemo -c "dconf write /desktop/sailfish/silica/theme_icon_subdir $ICONS"
# restart lipstick
echo ""
echo restarting lipstick
echo ""
systemctl-user restart lipstick
echo ""
echo done
echo ""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment