miércoles, 10 de abril de 2013

Your own Ubuntu / GNOME custom emblems

I love emblems. To me, they were a killer feature. Something that, when I started giving Ubuntu a try, led me to stick to it. Also something that made me prefer GNOME over KDE back in the day.

An often neglected features, the gnome environment was never a fan of motivating the user to use or even be aware of the feature. Things only got worse as Desktop Environments "evolved"s;. The GTK 3 generation - Unity, GNOME 3.0, Mint, etc, basically removed the feature of emblems. In reality, Nautilus still supports emblems as a tool for software to use them automatically (For example, Dropbox uses them so you can see if a file is updated, being updated or in conflict), but users cannot customize them anymore unless they mess with the command line or use third party tools. I recommend emblemize

Emblemize is great, but sometimes you might want to make your own custom emblems. Some icons that might be missing in the list of system icons. This command line tutorial should show how to add an icon that can be used as emblem and how to put it to a folder/file.

I suspect that this feature is nautilus-only. Nautilus forks probably have it too.

What I want to do

My home folder currently looks like this:

As you can see, almost everything has a descriptive icon with an emblem if needed. But the priv folder does not. The reason is that I am yet to find a good icon for it in Emblemize's list. I would like a lock icon.

How to do it

First of all, you need an icon to use as your emblem. You want a image format that supports transparency (png, SVG, gif), and an icon that has transparency. Optimally, the object in the image must touch the image's borders, else the emblem will look a bit small. I used google to find a "Tango lock icon". (Tango is the visual style most of the default icon themes in GNOME-based desktops are based on).Found a nice image, let us call it custom-emblem-lock.png. You can always make your icons yourself (I use inkscape), but generally google searches with the words Tango and icon give good results.

In order to add a custom emblem, we need two things:

We need to add the icon to the system. There are two methods, one involves editing the icon theme, but has the weakness that whenever you change your icon theme you might lose the emblem. The other is to add the icon to /usr/share/pixmaps. We will need the terminal for the second step, so we might as well use it for the first step. Open a terminal.

  • In the terminal, type this:
  • sudo cp /home/yourname/whatever/custom-emblem-lock.png /usr/share/pixmaps/

    Just make sure to replace "/home/yourname/whatever/custom-emblem-lock.png" with the complete path to the image icon. To make things simple, just save the image icon to your home folder. Then the complete path is just "/home/username/filename.png".

  • Open nautilus/your favorite file manager and head to /usr/share/pixmaps to verify that your icon is there.

If the extension of your icon image is png, it should now appear in Emblemize's window. But it might be hard to find it. I sometimes have to use files with different extensions. When you cannot find the image in Emblemize after placing it in /usr/share/pixmaps, you will need to continue to the next paragraph:

Now a bit of a harder part. The data that determines which file/folder has an emblem or not is saved in something called the metadata. We will use the gvfs-set-attribute command to set it manually, because Emblemize doesn't support you to input arbitrary strings as the name of the emblem (I wish it did). Go back to your terminal.

gvfs-set-attribute -t stringv "/home/vx/priv" metadata::emblems "custom-emblem-lock"

Of course, you should replace "/home/vx/priv" with the complete path to the file/folder you want to emblemize and "custom-emblem-lock" to the name of the image you moved to pixmaps. Note how this command does not include the file extension of the image. I put "custom-emblem-lock" instead of "custom-emblem-lock.png".

After running your command, nothing will happen. You need to refresh the nautilus window for the new emblem to show up.

I hope this was useful.

I fantasize of a program that allows you to create your own list of custom emblems, and then allows you to set them with just a popup menu in Nautilus.

It is difficult not to get overboard and enjoy emblems. This is a sample of my dev folder (Where I place all my programming projects).

I had to use this trick for three of these files. The folder that triggered this all was the xyedev foder, the one in which I develop (or used to develop) my free software game: Xye. I really wanted to see Xye's icon in it.