about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2010-08-28 08:30:52 +0200
committerhut <hut@lavabit.com>2010-08-28 08:30:52 +0200
commita2853ab67f2e471d9a34b4c528db6ee2024ef874 (patch)
treecf2f7e32433cd49f592399e1624428e561a7c3e6
parent56f380c61f62a18b39375da7e7cd93d443be8aef (diff)
downloadranger-a2853ab67f2e471d9a34b4c528db6ee2024ef874.tar.gz
Changed default config dir to $XDG_CONFIG_HOME/ranger
-rw-r--r--HACKING4
-rw-r--r--README2
-rw-r--r--doc/colorschemes.txt4
-rw-r--r--doc/ranger.19
-rwxr-xr-xranger.py6
-rw-r--r--ranger/__init__.py5
-rw-r--r--ranger/__main__.py2
-rw-r--r--ranger/core/actions.py2
-rw-r--r--ranger/defaults/apps.py4
-rw-r--r--ranger/defaults/commands.py2
-rw-r--r--ranger/defaults/keys.py2
-rw-r--r--ranger/defaults/options.py2
-rw-r--r--ranger/gui/colorscheme.py6
13 files changed, 29 insertions, 21 deletions
diff --git a/HACKING b/HACKING
index 9c114e89..0424b047 100644
--- a/HACKING
+++ b/HACKING
@@ -56,13 +56,13 @@ assuming <self> is a "SettingsAware" object.
 
 * Changing commands, adding aliases:
 ranger/defaults/commands.py
-or ~/.ranger/commands.py
+or ~/.config/ranger/commands.py
 
 * Adding colorschemes:
 Copy ranger/colorschemes/default.py to ranger/colorschemes/myscheme.py
 and modify it according to your needs.  Alternatively, mimic the jungle
 colorscheme.  It subclasses the default scheme and just modifies a few things.
-In ranger/defaults/options.py (or ~/.ranger/options.py), change
+In ranger/defaults/options.py (or ~/.config/ranger/options.py), change
     colorscheme = 'default'
 to: colorscheme = 'myscheme'
 
diff --git a/README b/README
index dad70262..babcfbbb 100644
--- a/README
+++ b/README
@@ -75,7 +75,7 @@ parent directories and to the right there's a preview of the object you're
 pointing at.  Now use the Arrow Keys to navigate, Enter to open a file
 or type Q to quit.
 
-To customize ranger, copy the files from ranger/defaults/ to ~/.ranger/
+To customize ranger, copy the files from ranger/defaults/ to ~/.config/ranger/
 and modify them according to your wishes.
 
 
diff --git a/doc/colorschemes.txt b/doc/colorschemes.txt
index 905c7a3e..e7bc2c0a 100644
--- a/doc/colorschemes.txt
+++ b/doc/colorschemes.txt
@@ -65,7 +65,7 @@ Specify a Colorscheme
 ---------------------
 
 Colorschemes are searched for in these directories:
-~/.ranger/colorschemes/
+~/.config/ranger/colorschemes/
 /ranger/colorschemes/
 
 To specify which colorscheme to use, define the variable "colorscheme"
@@ -73,7 +73,7 @@ in your options.py:
 colorscheme = colorschemes.default
 
 This means, use the (one) colorscheme contained in
-either ~/.ranger/colorschemes/default.py or /ranger/colorschemes/default.py.
+either ~/.config/ranger/colorschemes/default.py or /ranger/colorschemes/default.py.
 
 You can define more than one colorscheme in a colorscheme file.  The
 one named "Scheme" will be chosen in that case.  If there is no colorscheme
diff --git a/doc/ranger.1 b/doc/ranger.1
index 3db90285..fab42496 100644
--- a/doc/ranger.1
+++ b/doc/ranger.1
@@ -38,7 +38,8 @@ Return the exit code 1 if ranger is used to run a file, for example with
 `ranger --fail-unless-cd filename`.  This can be useful for scripts.
 .TP
 -r \fIdir\fR, --confdir=\fIdir\fR
-Define a different configuration directory.  The default is $HOME/.ranger.
+Define a different configuration directory.  The default is
+$XDG_CONFIG_HOME/ranger (which defaults to ~/.config/ranger)
 .TP
 -m \fIn\fR, --mode=\fIn\fR
 When a filename is supplied, make it run in mode \fIn\fR. Check the
@@ -177,17 +178,17 @@ of your parent shell after exiting ranger:
 
 ranger() {
     command ranger --fail-unless-cd $@ &&
-    cd "$(grep \\^\\' ~/.ranger/bookmarks | cut -b3-)"
+    cd "$(grep \\^\\' ~/.config/ranger/bookmarks | cut -b3-)"
 }
 .\"-----------------------------------------
 .SH CONFIGURATION
 The files in
 .B ranger/defaults/
 can be copied into your configuration directory (by default, this is
-$HOME/.ranger) and customized according to your wishes.  
+~/.config/ranger) and customized according to your wishes.
 Most files don't have to be copied completely though: Just define those
 settings you want to add or change and they will override the defauls.
-Colorschemes can be placed in $HOME/.ranger/colorschemes.
+Colorschemes can be placed in ~/.config/ranger/colorschemes.
 .P
 All configuration is done in Python.
 Each configuration file should contain sufficient documentation.
diff --git a/ranger.py b/ranger.py
index f290d796..cc7f14ed 100755
--- a/ranger.py
+++ b/ranger.py
@@ -23,7 +23,11 @@
 # after you exit ranger by starting it with: source ranger ranger
 """":
 if [ $1 ]; then
-	$@ --fail-unless-cd && cd "$(grep \^\' ~/.ranger/bookmarks | cut -b3-)"
+	if [ -z $XDG_CONFIG_HOME ]; then
+		$@ --fail-unless-cd && cd "$(grep \^\' ~/.config/ranger/bookmarks | cut -b3-)"
+	else
+		$@ --fail-unless-cd && cd "$(grep \^\' "$XDG_CONFIG_HOME"/ranger/bookmarks | cut -b3-)"
+	fi
 else
 	echo "usage: source path/to/ranger.py path/to/ranger.py"
 fi
diff --git a/ranger/__init__.py b/ranger/__init__.py
index e0e8e1bf..57e0e5a2 100644
--- a/ranger/__init__.py
+++ b/ranger/__init__.py
@@ -31,7 +31,10 @@ Copyright (C) 2009, 2010  Roman Zimbelmann <romanz@lavabit.com>
 """
 
 USAGE = '%prog [options] [path/filename]'
-DEFAULT_CONFDIR = '~/.ranger'
+if 'XDG_CONFIG_HOME' in os.environ and os.environ['XDG_CONFIG_HOME']:
+	DEFAULT_CONFDIR = os.environ['XDG_CONFIG_HOME'] + '/ranger'
+else:
+	DEFAULT_CONFDIR = '~/.config/ranger'
 RANGERDIR = os.path.dirname(__file__)
 LOGFILE = '/tmp/errorlog'
 arg = OpenStruct(
diff --git a/ranger/__main__.py b/ranger/__main__.py
index b3a41776..28284ef5 100644
--- a/ranger/__main__.py
+++ b/ranger/__main__.py
@@ -113,7 +113,7 @@ def load_settings(fm, clean):
 			pass
 		# COMPAT WARNING
 		if hasattr(keys, 'initialize_commands'):
-			print("Warning: the syntax for ~/.ranger/keys.py has changed.")
+			print("Warning: the syntax for ~/.config/ranger/keys.py has changed.")
 			print("Your custom keys are not loaded."\
 					"  Please update your configuration.")
 		allow_access_to_confdir(ranger.arg.confdir, False)
diff --git a/ranger/core/actions.py b/ranger/core/actions.py
index d12d9c6c..a5ee0d4d 100644
--- a/ranger/core/actions.py
+++ b/ranger/core/actions.py
@@ -423,7 +423,7 @@ class Actions(FileManagerAware, EnvironmentAware, SettingsAware):
 	# --------------------------
 	# -- Tags
 	# --------------------------
-	# Tags are saved in ~/.ranger/tagged and simply mark if a
+	# Tags are saved in ~/.config/ranger/tagged and simply mark if a
 	# file is important to you in any context.
 
 	def tag_toggle(self, movedown=None):
diff --git a/ranger/defaults/apps.py b/ranger/defaults/apps.py
index 48735196..47eff0c9 100644
--- a/ranger/defaults/apps.py
+++ b/ranger/defaults/apps.py
@@ -17,13 +17,13 @@
 This is the default ranger configuration file for filetype detection
 and application handling.
 
-You can place this file in your ~/.ranger/ directory and it will be used
+You can place this file in your ~/.config/ranger/ directory and it will be used
 instead of this one.  Though, to minimize your effort when upgrading ranger,
 you may want to subclass CustomApplications rather than making a full copy.
             
 This example modifies the behaviour of "feh" and adds a custom media player:
 
-#### start of the ~/.ranger/apps.py example
+#### start of the ~/.config/ranger/apps.py example
 	from ranger.defaults.apps import CustomApplications as DefaultApps
 	from ranger.api.apps import *
 			
diff --git a/ranger/defaults/commands.py b/ranger/defaults/commands.py
index f1c92274..b6bf7e2b 100644
--- a/ranger/defaults/commands.py
+++ b/ranger/defaults/commands.py
@@ -32,7 +32,7 @@ The return value for quick() can be:
 The return value for execute() doesn't matter.
 
 If you want to add custom commands, you can create a file
-~/.ranger/commands.py, add the line:
+~/.config/ranger/commands.py, add the line:
 	from ranger.api.commands import *
 
 and write some command definitions, for example:
diff --git a/ranger/defaults/keys.py b/ranger/defaults/keys.py
index e72f4c91..7d8ccc4a 100644
--- a/ranger/defaults/keys.py
+++ b/ranger/defaults/keys.py
@@ -58,7 +58,7 @@ dgg       => fm.cut(foo=bar, dirarg=Direction(to=0))
 5dgg      => fm.cut(foo=bar, narg=5, dirarg=Direction(to=0))
 5d3gg     => fm.cut(foo=bar, narg=5, dirarg=Direction(to=3))
 
-Example ~/.ranger/keys.py
+Example ~/.config/ranger/keys.py
 -------------------------
 from ranger.api.keys import *
 
diff --git a/ranger/defaults/options.py b/ranger/defaults/options.py
index d3c420af..126d4bad 100644
--- a/ranger/defaults/options.py
+++ b/ranger/defaults/options.py
@@ -17,7 +17,7 @@
 This is the default configuration file of ranger.
 
 There are two ways of customizing ranger.  The first and recommended
-method is creating a file at ~/.ranger/options.py and adding
+method is creating a file at ~/.config/ranger/options.py and adding
 those lines you want to change.  It might look like this:
 
 from ranger.api.options import *
diff --git a/ranger/gui/colorscheme.py b/ranger/gui/colorscheme.py
index 501b8788..5b317acb 100644
--- a/ranger/gui/colorscheme.py
+++ b/ranger/gui/colorscheme.py
@@ -24,7 +24,7 @@ The values are specified in ranger.gui.color.
 A colorscheme must...
 
 1. be inside either of these directories:
-~/.ranger/colorschemes/
+~/.config/ranger/colorschemes/
 path/to/ranger/colorschemes/
 
 2. be a subclass of ranger.gui.colorscheme.ColorScheme
@@ -121,7 +121,7 @@ class ColorScheme(SettingsAware):
 		return fg, -1, attr
 
 def _colorscheme_name_to_class(signal):
-	# Find the colorscheme.  First look for it at ~/.ranger/colorschemes,
+	# Find the colorscheme.  First look for it at ~/.config/ranger/colorschemes,
 	# then at RANGERDIR/colorschemes.  If the file contains a class
 	# named Scheme, it is used.  Otherwise, an arbitrary other class
 	# is picked.
@@ -139,7 +139,7 @@ def _colorscheme_name_to_class(signal):
 		except:
 			return False
 
-	# create ~/.ranger/colorschemes/__init__.py if it doesn't exist
+	# create ~/.config/ranger/colorschemes/__init__.py if it doesn't exist
 	if usecustom:
 		if os.path.exists(ranger.relpath_conf('colorschemes')):
 			initpy = ranger.relpath_conf('colorschemes', '__init__.py')