Skip to content

Instantly share code, notes, and snippets.

@daniel-barrows
Last active September 24, 2018 15:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save daniel-barrows/3a42d6ac96559534a7a52172083730c2 to your computer and use it in GitHub Desktop.
Save daniel-barrows/3a42d6ac96559534a7a52172083730c2 to your computer and use it in GitHub Desktop.
Output the filepath(s) of any GTK icon names provided as arguments.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# https://gist.github.com/daniel-barrows/3a42d6ac96559534a7a52172083730c2
__copyright__ = "2018 Daniel Barrows"
__license__ = "Public Domain"
__status__ = "production"
import sys
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
EXIT_FILE_NOT_FOUND = 2
return_code = 0
icon_theme = Gtk.IconTheme.get_default()
for icon_name in sys.argv[1:]:
icon_info = icon_theme.lookup_icon(icon_name, 48, 0)
if icon_info:
print(icon_info.get_filename())
else:
print("ERROR: No icon found named %s" % icon_name, file=sys.stderr)
return_code = return_code or EXIT_FILE_NOT_FOUND
exit(return_code)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment