2

Actually, I'm talking about icons for Nautilus Scripts, and I have many of them. Although I prefer menus without icons, I cannot prevent icons from being displayed in Nautilus context menu items Open With and Scripts.

Particularly, having the same script icon displayed for all of them does not look good at all. So, if I cannot prevent them, at least I'd like them use icons better related with the function of each script.

It's easy to assign a custom icon for a single file through File Properties but I have a total of 82 Nautilus Scripts at the moment!

When you enter gvfs-info /path/to/file command in terminal, you can see a line like this: metadata::custom-icon: file:///usr/share/icons/NITRUX-Buttons/apps/scalable/accessories-text-editor.svg

I wonder if it is possible at all to edit this line (where ever it is) in a batch / from command line?

2 Answers 2

1

I couldn't see it in the list shown as I was writing this question, but later I saw a similar question and the answer I was looking for in the list of Related questions on the right:

How can I programmatically change a file's icon?

It seems basically the command for this is:

gvfs-set-attribute -t string /path/to/your/file metadata::custom-icon file:///path/to/your/icon.png

Notes:

1. This doesn't seem to work for Nautilus Scripts in Ubuntu versions before 12.10.

2. This doesn't seem to work for Nautilus Scripts when running Nautilus as root either.

0

Using the ideas exposed here, changing the icon from Nautilus or Nemo would take this:

#!/bin/bash
# Written by Alfonso R. Reyes
# make hard links for multiple file selection
# be careful of not moving the hard link to a different file system
HARDLINK_ICON=${HOME}/.local/share/icons/mine/folder-green-activities-icon.png
for arg 
do
    # make a hard link of the selected file
    if [[ -f "$arg" ]] 
    then
        HARDLINK_NAME="Hard Link to $arg"
        ln "$arg" "${HARDLINK_NAME}"
        gio set -t string "${HARDLINK_NAME}" metadata::custom-icon file:///${HARDLINK_ICON}
    fi
done

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .