Sunday, April 28, 2024
 Popular · Latest · Hot · Upcoming
27
rated 0 times [  27] [ 0]  / answers: 1 / hits: 9130  / 3 Years ago, sat, june 26, 2021, 10:32:15

If I select an icon in Nautilus and select Properties, I can click on the icon presented there. This gives me a file-chooser dialog to select a new icon image.



I would like to do this via a script of some sort so that I can assign the same icon to many files at once. Or take a list of icons and a list of files and assign them to each other.



Is there some way I can accomplish this? Something in bash or Python would be great, but I'll take what I can get.



Please note:




  • I am not asking how to change the icon for a file type.

  • I am not asking how to change an icon on the launcher.



enter image description here


More From » nautilus

 Answers
1


To change those icons from the command line, you can use the following command:



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


You can use this command in a bash script according to your needs.



If you run the command and the icon does not change immediately, you can install the xautomation package with:



sudo apt-get install xautomation


And finally, use the command "xte" to "sendkey" in bash like "F5" to refresh..

A little example would be:



#!/bin/bash
gvfs-set-attribute -t string /home/hermes/testicon metadata::custom-icon file:///home/hermes/Desktop/applet_blank.png
sleep 3
xte "key F5"


I hope this is useful for you.


[#34264] Monday, June 28, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
istmasted

Total Points: 287
Total Questions: 130
Total Answers: 153

Location: Burkina Faso
Member since Thu, Dec 23, 2021
2 Years ago
istmasted questions
;