Package: mirage
Version: 0.9.3-4
Severity: wishlist
mirage is currently using ~/.config/mirage/ directory to store its
configuration files, which is in the spirit of XDG Base Directory
Specification [1]. The attached patches makes mirage to actually follow
the specification, i.e. to respect the $XDG_CONFIG_HOME variable.
[1] http://standards.freedesktop.org/basedir-spec/basedir-spec-0.6.html
--
Jakub Wilk
diff --git a/mirage.py b/mirage.py
--- a/mirage.py
+++ b/mirage.py
@@ -53,6 +53,8 @@
if gtk.pygtk_version < (2, 6, 0):
sys.stderr.write("Mirage requires PyGTK 2.6.0 or newer.\n")
sys.exit(1)
+
+config_dir = (os.getenv('XDG_CONFIG_HOME') or os.path.expanduser('~/.config')) + '/mirage'
def valid_int(inputstring):
try:
@@ -204,8 +206,8 @@
# Load config from disk:
conf = ConfigParser.ConfigParser()
- if os.path.isfile(os.path.expanduser('~/.config/mirage/miragerc')):
- conf.read(os.path.expanduser('~/.config/mirage/miragerc'))
+ if os.path.isfile(config_dir + '/miragerc'):
+ conf.read(config_dir + '/miragerc')
elif os.path.isfile(os.path.expanduser('~/.miragerc')):
conf.read(os.path.expanduser('~/.miragerc'))
os.remove(os.path.expanduser('~/.miragerc'))
@@ -297,8 +299,8 @@
self.curr_slideshow_random = self.slideshow_random
# Read accel_map file, if it exists
- if os.path.isfile(os.path.expanduser('~/.config/mirage/accel_map')):
- gtk.accel_map_load(os.path.expanduser('~/.config/mirage/accel_map'))
+ if os.path.isfile(config_dir + '/accel_map'):
+ gtk.accel_map_load(config_dir + '/accel_map')
self.blank_image = gtk.gdk.pixbuf_new_from_file(self.find_path("mirage_blank.png"))
@@ -1465,14 +1467,12 @@
for i in range(len(self.recentfiles)):
conf.set('recent', 'num[' + str(i) + ']', len(self.recentfiles[i]))
conf.set('recent', 'urls[' + str(i) + ',0]', self.recentfiles[i])
- if not os.path.exists(os.path.expanduser('~/.config/')):
- os.mkdir(os.path.expanduser('~/.config/'))
- if not os.path.exists(os.path.expanduser('~/.config/mirage/')):
- os.mkdir(os.path.expanduser('~/.config/mirage/'))
- conf.write(file(os.path.expanduser('~/.config/mirage/miragerc'), 'w'))
+ if not os.path.exists(config_dir):
+ os.makedirs(config_dir)
+ conf.write(file(config_dir + '/miragerc', 'w'))
# Also, save accel_map:
- gtk.accel_map_save(os.path.expanduser('~/.config/mirage/accel_map'))
+ gtk.accel_map_save(config_dir + '/accel_map')
return