fixed locating application icons when running in a custom prefix

This commit is contained in:
Daniel Pavel 2013-01-08 00:40:54 +02:00
parent 316e91cfcf
commit 653d370a85
1 changed files with 6 additions and 2 deletions

View File

@ -10,15 +10,19 @@ def _look_for_application_icons():
import os as _os
import sys as _sys
# print ("path[0] = %s" % _sys.path[0])
prefix_share = _path.normpath(_path.join(_path.realpath(_sys.path[0]), '..'))
src_share = _path.normpath(_path.join(_path.realpath(_sys.path[0]), '..', 'share'))
local_share = _os.environ.get('XDG_DATA_HOME', _path.expanduser('~/.local/share'))
data_dirs = _os.environ.get('XDG_DATA_DIRS', '/usr/local/share:/usr/share')
share_solaar = list(_path.join(x, 'solaar') for x in [src_share, local_share] + data_dirs.split(':'))
share_solaar = [prefix_share] + list(_path.join(x, 'solaar') for x in [src_share, local_share] + data_dirs.split(':'))
for location in share_solaar:
solaar_png = _path.join(location, 'icons', 'solaar.png')
# print ("checking %s" % location)
solaar_png = _path.join(location, 'icons', 'solaar-mask.png')
if _path.exists(solaar_png):
_os.environ['XDG_DATA_DIRS'] = location + ':' + data_dirs
# print ('XDG_DATA_DIRS=%s' % _os.environ['XDG_DATA_DIRS'])
break
del _sys