From 21a399042f01a06c5920ac9cd44231721612083a Mon Sep 17 00:00:00 2001 From: George Vlahavas Date: Mon, 27 Mar 2017 14:01:05 +0300 Subject: [PATCH] Exit if no X session is found Catch the exception that is raised when an icon lookup is performed without an active X session and bail out. --- src/xdgmenumaker | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/xdgmenumaker b/src/xdgmenumaker index 3f4daf8..9a5a179 100755 --- a/src/xdgmenumaker +++ b/src/xdgmenumaker @@ -305,7 +305,10 @@ def icon_full_path(icon): return icon icon = icon_strip(icon) icon_theme = gtk.icon_theme_get_default() - icon = icon_theme.lookup_icon(icon, iconsize, gtk.ICON_LOOKUP_NO_SVG) + try: + icon = icon_theme.lookup_icon(icon, iconsize, gtk.ICON_LOOKUP_NO_SVG) + except AttributeError: + sys.exit('ERROR: You need to run xdgmenumaker inside an X session.') if icon: icon = icon.get_filename() if max_icon_size: