4

I'm trying to figure out how to change icons for individual drives.

As you can see the last three are indistinguishable until hovered:

img here

muru
  • 207,228
Pranav
  • 45

2 Answers2

6

Use x-gvfs-icon in /etc/fstab

The trick with autorun.inf suggested by pLumo seems not to work anymore, but one can set icons via the x-gvfs-icon option in /etc/fstab.

For this option only icons that are provided through an icon theme can be used.

Set x-gvfs-icon with gnome-disks

If you want to be on the safe side, make a backup copy of your /etc/fstab first:

sudo cp /etc/fstab /etc/fstab.backup

Open gnome-disks (it is under Activities -> Utilities - Disks). Find the partition for which you want to change the icon, select it (it must be highlighted) and click on the gear icon ("Additional partition options").

In the menu, that pops up select "Edit Mount Options...".

In the dialog you must first switch off "User Session Defaults". Then under "Icon Name" you can place a name known to the icon theme. For a first test you could put gnome-cd, which will get you an CD-icon. How to find icon names and how to add custom ones I will explain in the following two sections.

Before clicking "OK", ensure yourself, that the other options are correct, for example "Mount at system startup". When you click "OK", enter your password, which will then save those settings in /etc/fstab. Usually gnome-disks provides you with good default options, but still you have to handle them with care.

The new entry in /etc/fstab that has been created for us could for example look like this:

/dev/disk/by-uuid/<the-uuid> /mnt/<the-uuid> auto nosuid,nodev,nofail,x-gvfs-show,x-gvfs-icon=<name-of-the-icon>,noauto 0 0

gnome-disks

Find some icon names in the theme

Icons are located under /usr/share/icons/<theme-name>/<size>/<topic>, so for example to look up 48x48 device icons in the Yaru theme one can do:

ls /usr/share/icons/Yaru/48x48/devices/

The name for x-gvfs-icon is simply without the file ending.

How to create a small custom icon theme

This are a few steps to create custom icons that can be used for x-gvfs-icon option.

I assume in this description that you have put an icon called mydrive.png into ~/Downloads. Formats accepted are PNG or SVG, ICO did not work for me. The size should be somewhere between 32 and 128 pixels for PNG.

  1. prepare the folders

    sudo bash
    cd /usr/share/icons/
    mkdir -p custom/any/devices
    

    I assume that you do not want to maintain different sizes, so I just used any for the size.

  2. create the index.theme file

    nano custom/index.theme
    

    and put the following content into it:

    [Icon Theme]
    Name=Custom
    Comment=Icons added by the user
    Directories=any/devices
    

    [any/devices] Context=Devices Size=48 Type=Fixed

    Note that the "Size" parameter is just a hint for GTK, the actual size of the file can differ.

  3. copy a new icon

    cp ~/Downloads/mydrive.png /usr/share/icons/custom/any/devices
    
  4. link to the new theme from existing themes

    Here if you are using different theme now, you must replace Yaru with the name of your theme. I edit Humanity here too, because it is a fallback for many themes.

    Edit (nano ... or gedit ...) the files

    /usr/share/icons/Yaru/index.theme
    /usr/share/icons/Humanity/index.theme
    

    and add ...,custom to the Inherits= option. That gives for Yaru:

    Inherits=Humanity,hicolor,custom
    

    and for Humanity:

    Inherits=Adwaita,hicolor,custom
    

    Exit the super user bash with exit.

Done! Now the name mydrive can be used as "Icon Name" in gnome-disks!

After copying new icons, a restart of Gnome (logoff + logon) might be required!

muru
  • 207,228
1

If your mounts/drives happen to be locations which already have a special icon in your theme, such as Pictures, Music, Videos, etc, then you can use the "gnome-disk-utility" package to set it to one of those without adding a new icon to your theme.

  1. open gnome-disks. You can click your way there from the file manager (nautilus), by clicking on "Other Locations" from the sidebar, right clicking a volume and choosing "Properties", then "Open in Disks"

nautilus file manager with a volume's "properties" modal window shown

  1. find the volume you want to adjust, and select "edit mount options".

gnome-disks with context menu of a volume shown

  1. enter the icon you want to use in "Icon Name", then click "OK". A list of all installed icon names by theme (set using gnome-tweaks) can be found by poking around in /usr/share/icons/THEME/; you can browse around there or cut and paste this block into a terminal to get a list of icons by theme:
cd /usr/share/icons
find . -type f |
    perl -lnaF/ -E '($icon_name=$F[4])=~s/\.\w+$//;
        next unless $icon_name =~ /folder-/;
        say "$F[1]: \"$icon_name\""
    ' | sort -u

Currently the icons found in most themes are: folder-documents folder-download folder-dropbox folder-music folder-new folder-open folder-pictures folder-publicshare folder-remote folder-templates folder-videos

gnome-disks mount options dialog, with the icon name field set to 'folder-videos' and the volume name field set to 'Vids'

  1. You should now see the icon change in the dock. If you changed the display name on the mount options, it will update the next time you log in (or restart gnome-shell):

dock with mouse hovered over the modified volume, showing the updated icon and the modified volume name in the tool tip

The name change seems to take effect immediately if you don't set it under "mount options", but instead adjust it on the volume label using "Edit Filesystem" from gnome-disks. Setting it on the command line using tune2fs -L "New Label" /dev/DEVICE also works and is equivalent for an ext2/3/4 filesystem, but requires restarting gnome-shell.

NotTheDr01ds
  • 22,082
samv
  • 11
  • 3