How do I merge two icon sets?

Solution 1:

I think the best way to merge icon sets is to create what I call a lightweight icon set. This icon set lives in your home directory so it won't be clobbered by system updates, but it links to the system icon sets, so it will be updated along with them. These themes won't be available to other users on your system.

Lightweight Icon Sets

Ubuntu's theme manager will look in ~/.icons and /usr/share/icons for icons sets. Anything in ~/.icons overrides /usr/share/icons. So you can copy an icon set from the system dir to your home dir to customize the icon and you only include the parts you want to change!

Generally, I think it's best to make your own icon sets that use the system ones. You can do this by creating an icon set, a index.theme file, and adding some icons. However, when you are combining different icon sets, you'll need to override their Inherits attribute so you can set your own order of precedence.

Creating an Icon Set to Merge Themes

Let's create a super-mono icon set:

# Create a new icon set
mkdir -p ~/.icons/super-mono

# Copy an existing icon config and modify it for our new icon set
cp /usr/share/icons/Faenza-Darkest/index.theme      ~/.icons/super-mono/.
sed -ie "s/Name=Faenza-Darkest/Name=super-mono/"    ~/.icons/super-mono/index.theme
sed -ie "s/Comment=.*$/Comment=Created with by me/" ~/.icons/super-mono/index.theme
sed -ie "s/Inherits=/Inherits=ubuntu-mono-dark,/"   ~/.icons/super-mono/index.theme

Now we have a new icon set in Appearance that is exactly like Faenza-Darkest.

To merge our two themes, we change super-mono theme to inherit from ubuntu-mono-dark and then Faenza.

sed -ie "s/Inherits=.*$/Inherits=ubuntu-mono-dark,Faenza/" ~/.icons/super-mono/index.theme

That should be enough for richzilla, just select super-mono in Appearance.

Adding Custom Icons

We can also add individual icons to this icon set:

ln -s /usr/share/icons/Faenza-Darkest/actions/22/gtk-paste.png ~/.icons/super-mono/actions/22/.

And now our super-mono theme combines ubuntu-mono-dark and Faenza, except it uses one icon from Faenza-Darkest. See later sections to use more than just a few icons.

It's important to see that I copied the index.theme from Faenza-Darkest and then used icons from Faenza-Darkest. The index.theme file says where the icons might be. If you want to pull individual icons from different icon sets, you'll need to merge their index.theme files. You can look at the files and you'll see a field called Directories that lists all folders containing icons. Then you'll see other fields that describe these folders. If you add an icon that isn't described by these fields, then that icon will be ignored. You can find more information in the index.theme spec.

Advanced: Selectively Combining Three Icon Sets

I also love ubuntu-mono icons. I love Faenza's app icons, but I don't like Faenza's mono icons (the indicators and buttons). I also like elementary's icons. So I want to combine these three icon sets. As far as I know, the best way to do this is by isolating the icons you like.

  1. Use ubuntu-mono-dark
  2. Use Faenza's app icons
  3. Otherwise use elementary's icons

To do this, we need to tell ubuntu-mono-dark to not inherit from anything (so we can also use Faenza and elementary).

# First, ubuntu-mono-dark
# Create a shadow of the system icon set
mkdir -p ~/.icons/ubuntu-mono-dark

# Copy an existing icon config and modify it for our shadow icon set
cp /usr/share/icons/ubuntu-mono-dark/index.theme   ~/.icons/ubuntu-mono-dark/.
sed -ie "s/Comment=.*$/Comment=A shadow to prevent inherits/" ~/.icons/ubuntu-mono-dark/index.theme
sed -ie "s/Inherits=.*$/Inherits=/"                ~/.icons/ubuntu-mono-dark/index.theme

You'll notice that the ubuntu-mono-dark icon set is now broken. It will be missing icons that are provided by Humanity-Dark and other icon sets it inherits from. This change will only affect your user.

Now we can make a new icon set that uses the app icons from Faenza.

# Create a new icon set
mkdir -p ~/.icons/Faenza-apps

# Copy the existing icon config and modify it for our new icon set
cp /usr/share/icons/Faenza/index.theme             ~/.icons/Faenza-apps/.
sed -ie "s/Name=Faenza/Name=Faenza-apps/"          ~/.icons/Faenza-apps/index.theme
sed -ie "s/Comment=.*$/Comment=Just Faenza app icons/" ~/.icons/Faenza-apps/index.theme
sed -ie "s/Inherits=.*$/Inherits=/"                ~/.icons/Faenza-apps/index.theme

# Use Faenza's app icons
ln -s /usr/share/icons/Faenza/apps/ ~/.icons/Faenza-apps/.

This Faenza-apps icon set is also broken. It only has icons for apps. All other icons are missing because we removed the Inherits.

Now we create the icon set we'll use. Our icon set will contain no icons, it just connects our other icon sets.

# Create a new icon set
mkdir -p ~/.icons/merge-mono-dark

# Copy an existing icon config and modify it for our new icon set
cp /usr/share/icons/Faenza/index.theme                 ~/.icons/merge-mono-dark/.
sed -ie "s/Name=Faenza/Name=merge-mono-dark/"          ~/.icons/merge-mono-dark/index.theme
sed -ie "s/Comment=.*$/Comment=Created with by me/"    ~/.icons/merge-mono-dark/index.theme
sed -ie "s/Inherits=.*$/Inherits=ubuntu-mono-dark,Faenza-apps,elementary-mono-dark/" ~/.icons/merge-mono-dark/index.theme

Now we should be able to select merge-mono-dark in Appearance and we'll have a beautiful new icon set! (Note: We shouldn't need to merge index.theme files because we're not adding icons from different icon sets to merge-mono-dark. Instead, we're using Inherits to automatically merge the icon sets.)


Explanation of some commands

I use a lot of Terminal commands to simplify this answer, but here's a description of what they do.

ln -s /usr/share/icons/Faenza-Darkest/actions/22/gtk-paste.png ~/.icons/Faenza-Alan/actions/22/.

This creates a pointer in your icon set to the system icon set's gtk-paste icon. That way no additional hard disk space is used and your icon set is updated along with the system's icon set. If you don't want that, then replace ln -s with cp -r.

sed -ie "s/dark/light/" ~/file

Means to replace all dark with light in ~/file.

sed -ie "s/Comment=.*$/Comment=Created with by me/" ~/.icons/super-mono/index.theme

The .*$ means to match any text (.*) to the end of the line ($).

sed -ie "s/Inherits=/Inherits=ubuntu-mono-dark,/"   ~/.icons/super-mono/index.theme

Here we're inserting ubuntu-mono-dark in front of the Inherits list because we're looking for Inherits= and replacing it with Inherits=ubuntu-mono-dark,

Anywhere I use sed, you could edit the file and apply edits manually instead.

Solution 2:

Edit this file below with your favourite text editor

/usr/share/icons/ubuntu-mono-(which mono set you want)/index.theme

and put Faenza at the start of the inherits line.