Last active
September 24, 2018 15:05
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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