HOWTO: Mintify Icon Themes

Write tutorials for Linux Mint here
More tutorials on https://github.com/orgs/linuxmint/discu ... /tutorials and (archive) on https://community.linuxmint.com/tutorial
Forum rules
Don't add support questions to tutorials; start your own topic in the appropriate sub-forum instead. Before you post read forum rules
Post Reply
ranyardm

HOWTO: Mintify Icon Themes

Post by ranyardm »

Okay, it really bugs me when I'm looking at themes that the Ubuntu icon comes back, so I decided that I'd look at scripting a "fix icon theme" script. I know it's fixed in mintmenu 3.1 but I guess there's other things that will look for start-here.png and novell.png etc. so it may retain usefulness to fix here anyway.

Guess what, it worked! If only text attachments worked in phpBB I'd be able to post it here... and my mintupload isn't working either, *sigh*, http://www.bikerwitch.org.uk/files/mint ... n-theme.sh

Steps to use :
Download my script above and save somewhere you know where it is (/tmp/ or your home directory is good)
Open up "Appearance" from the Control Center or Preferences in the MintMenu
Drag your icon theme straight from firefox into the window (or download and install etc.)
Apply a theme other than the theme you want fixing and exit Appearance
Open a terminal and run the script mintify-icon-theme.sh themename (you may need sh before if you don't know how to make the script executable)
Re-open "Appearance" and viola, selecting the theme will maintain your mint logo!

What the script does :

Looks at the "Cassandra" icon set that is on Daryna also, copies the .png files to the same place in the user's theme and edits the theme index file to include any missing directory definitions (yes, most themes have wildly different indexes to what is really there!)

I hope this helps someone. Oh, and it's GPL/BSD/Copyleft/Any other reasonable license multi-licensed.
--
Martyn Ranyard
Husse

Re: HOWTO: Mintify Icon Themes

Post by Husse »

If only text attachments worked in phpBB I'd be able to post it here
You could include it in a code box such as

Code: Select all

#!/bin/bash

REPLACE_FILES="distributor-logo.png gnome-main-menu.png novell-button.png start-here.png"
SOURCE_THEME=Celena
DESTINATION_THEME=$1

if [ -z $DESTINATION_THEME ] || ! [ -d ~/.icons/$DESTINATION_THEME ]; then
  echo "Usage : [sh] mintify-icon-theme.sh \"[theme name to mintify]\""
  echo ""
  echo "Mintifyable themes : "
  echo ~/.icons/* | sed s/"\/[^ ]*\/"//g
  exit 0
fi

SOURCE_SIZES=/usr/share/icons/$SOURCE_THEME/[0-9]*x[0-9]*
SOURCE_SIZES=`echo $SOURCE_SIZES | sed s/"\/[^ ]*\/"//g | sed s/" "/"\n"/g | sort -r -n`

echo Source Sizes = $SOURCE_SIZES

for s in $SOURCE_SIZES; do 
  mkdir -p ~/.icons/$DESTINATION_THEME/$s/places
  for f in $REPLACE_FILES; do
    if [ -e /usr/share/icons/$SOURCE_THEME/$s/places/$f ]; then cp /usr/share/icons/$SOURCE_THEME/$s/places/$f ~/.icons/$DESTINATION_THEME/$s/places/; fi
  done
done

ORIGDIRS=`grep ^Directories ~/.icons/$DESTINATION_THEME/index.theme | sed s/^Directories=//`
for s in $SOURCE_SIZES; do
  if ! echo $ORIGDIRS | grep $s/places > /dev/null; then
    NEWDIRS=$NEWDIRS$s/places,
  fi
done

NEWDIRS=`echo $NEWDIRS | sed s/,\$//`
LINECOUNT=`wc -l ~/.icons/$DESTINATION_THEME/index.theme | sed s/" .*"//`
DIRECTORIES_LINE=`grep -n Directories= ~/.icons/$DESTINATION_THEME/index.theme | sed s/:.*//`

SOURCETHEMEINDEX=~/.icons/$DESTINATION_THEME/index.theme
MINTEDTHEMEINDEX=~/.icons/$DESTINATION_THEME/index.minted
echo Creating minted theme index...
head -n `expr $DIRECTORIES_LINE - 1` $SOURCETHEMEINDEX > $MINTEDTHEMEINDEX
echo "Directories=$ORIGDIRS,$NEWDIRS" | sed s/,\$// >> $MINTEDTHEMEINDEX
tail -n `expr $LINECOUNT - $DIRECTORIES_LINE` $SOURCETHEMEINDEX >> $MINTEDTHEMEINDEX
for s in $SOURCE_SIZES; do
  if ! grep "\[$s\/places\]" $SOURCETHEMEINDEX > /dev/null; then
    echo "" >> $MINTEDTHEMEINDEX
    echo "[$s/places]" >> $MINTEDTHEMEINDEX
    echo "Size="`echo $s | sed s/"x.*"//` >> $MINTEDTHEMEINDEX
    echo "Context=Places" >> $MINTEDTHEMEINDEX
    echo "Type=Scaled" >> $MINTEDTHEMEINDEX
  fi
done
echo Backing up original theme index...
mv ~/.icons/$DESTINATION_THEME/index.theme ~/.icons/$DESTINATION_THEME/index.theme.orig
echo Minting....
mv ~/.icons/$DESTINATION_THEME/index.minted ~/.icons/$DESTINATION_THEME/index.theme
echo Done.
Post Reply

Return to “Tutorials”