linux - How to programmatically set custom folder icon in GNOME? -


because know simple api call handles setting custom folder icons in windows, looked api method set custom folder icons in linux.

but in this thread, saw there no such way. learnt each desktop environment has own way set custom folder icons. way of kde described there.

for gnome looked similar way; no file created when setting folder's icon properties panel. think there should registry-like file in somewhere in user home or /etc.

i glad, if kill pain. thanks.

i figured out how this! here's python script works in standard gnome environment:

#!/usr/bin/env python  import sys gi.repository import gio  if len(sys.argv) not in (2, 3):     print 'usage: {} folder [icon]'.format(sys.argv[0])     print 'leave out icon unset'     sys.exit(0)  folder = gio.file.new_for_path(sys.argv[1]) icon_file = gio.file.new_for_path(sys.argv[2]) if len(sys.argv) == 3 else none  # file info object  info = folder.query_info('metadata::custom-icon', 0, none)  if icon_file not none:     icon_uri = icon_file.get_uri()     info.set_attribute_string('metadata::custom-icon', icon_uri) else:     # change attribute type invalid unset     info.set_attribute('metadata::custom-icon',         gio.fileattributetype.invalid, '')  # write changes file folder.set_attributes_from_info(info, 0, none) 

Comments

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -