Aryeom is quite an advanced computer worker, yet there are times when she is lost as everyone else. This is when I come and help her. That’s part of my job!
She used to set custom icons in her Projects/
folders to recognize various status (not started, in-progress, done projects…) as well as unique icons for particular projects (ZeMarmot!). In GNOME Files/Nautilus, changing the default icon for any file is very easily done by a right click > Properties
, then choosing an image to make it an icon. This is a very cool process when done progressively (changing the icon of a project folder when it is added, in-progress or finished, for instance, which doesn’t happen every minute!).
Unfortunately Aryeom had the case when she relocated her icon folder to a better location. And then, disaster! The icons did not follow (they could have if they had been replicated as data somewhere, similarly to how thumbnails are saved in ~/.cache/thumbnails
; here that could have been under ~/.config
since you want to keep these as settings… it turns out they weren’t) and she suddenly got a Projects/
folder full of white squares instead of nice custom icons. Aryeom was pissed because she didn’t want to move back her custom icons folder to the old location, neither did she want to change manually each and every past project icon (she has a lot). So she just stopped marking project status with custom icons because while until now, that was an organization system she was really proud of, from this day on, she felt that became a waste of time.
Side note: that is one of these times when the software is actually working against the human being, instead of helping. This feature is cool, and some people want to use it. But then we are basically asking people to always keep the icon images to the same place, never reorganize, never rename, never move. If you ever do one of these actions, you lose your carefully organized icons (maybe hundreds through the years) in an instant with no easy way to salvage them.
This is just a note for people who will try to design a similar feature in the future: unless you don’t want people to use it, or only trained engineers who understand the inner-working of files and metadata, just think twice for the right implementation.
I didn’t do a thing about this problem for a few weeks, but today, I had a closer look. So it turns out that these icons are stored as GIO metadata. Not sure where this metadata is actually stored (well I didn’t search either!), but I found out how to query then change it.
- Query the metadata:
gio info /a/file/
- Change it:
gio set /a/file metadata::custom-icon "file://URI"
You’ll note that this path is set as a file URI, not as a shell path. And so I quickly set up a bash script (not bothering about any kind of portability, that was a quick and dirty script for single use) to quickly change all the folder icons with a single ./fixicons.sh ~/Desktop/Projects/*
call. Here it is:
#!/bin/bash for f in "$@" do icon=`gio info --attributes=metadata::custom-icon "$f"|grep metadata::custom-icon` if [ "$?" -eq 0 ]; then icon=`echo $icon |sed 's/^ *metadata::custom-icon: //'` icon=`echo $icon |sed 's$old/path/to/change/$new/path/$'` gio set "$f" metadata::custom-icon "$icon" fi done
I wrote it down here in case that helps any of you! Of course, up to everyone to customize it appropriately (in particular the regular expression of the second sed
, for the piece of the URI you want to transform).
I do quite regularly similar helping scripts, for myself, for Aryeom, sometimes just out of curiosity, other times to improve my daily digital work. Over the years, I have hundreds of such scripts, a pretty well set up environment (in some previous job, I was even doing some cool workshops for coworkers about customizing one’s working environment to automatize all the boring repetitive activities or the things you don’t want to remember).
Most of these scripts are not in a state to be “released” since they are just quick and dirty hardcoded stuff (rarely they would get so useful that I feel I should release them; that’s how crossroad initially started as just my script to cross-compile GIMP until it became a fully generic cross-compilation tool for any software, to crossbuild for Win32, Android, etc.).
So I figured that maybe I should try and give more of my scripts and tricks to the world other ways, at least as small posts through this website, if not as proper generic tools. 🙂
I hope you liked this one.
P.S.: I also just wrote a report for this issue to Nautilus.
Reminder: my Free Software coding can be funded on: Liberapay, Patreon or Tipeee through ZeMarmot project.
I wish they would bring emblems / tagging back to Nautilus
Icon settings should definitely move with files. This should be handled by nautilus, or whatever nautilus uses to copy / move files.
Agree with the other post that emblems were useful (even if the ones supplied were a bit silly).
The nautilius rewrites have introduced some nice features, but I hope we regain some of the old ones that we lost at some point too.