Skip to content

Commit e9fbbe3

Browse files
author
Jonathan Warren
committed
Merge pull request #261 from xj9/xdg
Fixed issue #157: Use $XDG_CONFIG_HOME
2 parents b83b46a + ad5517b commit e9fbbe3

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

src/shared.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,18 @@ def lookupAppdataFolder():
124124
elif 'win32' in sys.platform or 'win64' in sys.platform:
125125
dataFolder = path.join(environ['APPDATA'], APPNAME) + '\\'
126126
else:
127-
dataFolder = path.expanduser(path.join("~", "." + APPNAME + "/"))
127+
from shutil import move
128+
try:
129+
dataFolder = path.join(environ["XDG_CONFIG_HOME"], APPNAME)
130+
except KeyError:
131+
dataFolder = path.join(environ["HOME"], ".config", APPNAME)
132+
# Migrate existing data to the proper location if this is an existing install
133+
try:
134+
print "Moving data folder to ~/.config/%s" % APPNAME
135+
move(path.join(environ["HOME"], ".%s" % APPNAME), dataFolder)
136+
dataFolder = dataFolder + '/'
137+
except IOError:
138+
dataFolder = dataFolder + '/'
128139
return dataFolder
129140

130141
def isAddressInMyAddressBook(address):

0 commit comments

Comments
 (0)