summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--ranger/defaults/rifle.conf11
-rwxr-xr-xranger/ext/rifle.py19
2 files changed, 21 insertions, 9 deletions
diff --git a/ranger/defaults/rifle.conf b/ranger/defaults/rifle.conf
index 51c93bb7..9b049cea 100644
--- a/ranger/defaults/rifle.conf
+++ b/ranger/defaults/rifle.conf
@@ -18,6 +18,7 @@
 #   name <regexp> | The regexp matches the basename of $1
 #   path <regexp> | The regexp matches the absolute path of $1
 #   has <program> | The program is installed (i.e. located in $PATH)
+#   number <n>    | change the number of this command to n
 #   terminal      | stdin, stderr and stdout are connected to a terminal
 #   X             | $DISPLAY is not empty (i.e. Xorg runs)
 #
@@ -133,7 +134,7 @@ ext pdf, has evince,   X, flag f = evince -- "$@"
 ext pdf, has okular,   X, flag f = okular -- "$@"
 ext pdf, has epdfview, X, flag f = epdfview -- "$@"
 
-ext od[tspfg]|sxc|xlsx?|xlt|xlw|gnm|gnumeric, has gnumeric,    X, flag f = gnumeric -- "$@"
+ext           sxc|xlsx?|xlt|xlw|gnm|gnumeric, has gnumeric,    X, flag f = gnumeric -- "$@"
 ext od[tspfg]|sxc|xlsx?|xlt|xlw|gnm|gnumeric, has kspread,     X, flag f = kspread -- "$@"
 ext od[tspfg]|sxc|xlsx?|xlt|xlw|gnm|gnumeric, has libreoffice, X, flag f = libreoffice -- "$@"
 ext od[tspfg]|sxc|xlsx?|xlt|xlw|gnm|gnumeric, has soffice,     X, flag f = soffice -- "$@"
@@ -162,10 +163,10 @@ ext tar|gz, has tar = tar vvxf "$@"
 #-------------------------------------------
 # Misc
 #-------------------------------------------
-label wallpaper, mime ^image, X = feh --bg-scale "$1"
-label wallpaper, mime ^image, X = feh --bg-tile "$1"
-label wallpaper, mime ^image, X = feh --bg-center "$1"
-label wallpaper, mime ^image, X = feh --bg-fill "$1"
+label wallpaper, number 11, mime ^image, X = feh --bg-scale "$1"
+label wallpaper, number 12, mime ^image, X = feh --bg-tile "$1"
+label wallpaper, number 13, mime ^image, X = feh --bg-center "$1"
+label wallpaper, number 14, mime ^image, X = feh --bg-fill "$1"
 
 # Define the editor for non-text files + pager as last action
 label editor, !mime ^text, !ext xml|csv|tex  = "$EDITOR" -- "$@"
diff --git a/ranger/ext/rifle.py b/ranger/ext/rifle.py
index b98c35d3..50d14c4b 100755
--- a/ranger/ext/rifle.py
+++ b/ranger/ext/rifle.py
@@ -139,6 +139,10 @@ class Rifle(object):
 			return argument in get_executables()
 		if function == 'terminal':
 			return _is_terminal()
+		if function == 'number':
+			if argument.isdigit():
+				self._skip = int(argument)
+			return True
 		if function == 'label':
 			self._app_label = argument
 			if label:
@@ -208,14 +212,18 @@ class Rifle(object):
 		result = []
 		t = time.time()
 		for cmd, tests in self.rules:
+			self._skip = None
 			self._app_flags = ''
 			self._app_label = None
 			for test in tests:
 				if not self._eval_condition(test, files, None):
 					break
 			else:
+				if self._skip is None:
+					count += 1
+				else:
+					count = self._skip
 				result.append((count, cmd, self._app_label, self._app_flags))
-				count += 1
 		return result
 
 	def execute(self, files, way=0, label=None, flags=None, mimetype=None):
@@ -235,22 +243,25 @@ class Rifle(object):
 		"""
 		self._mimetype = mimetype
 		command = None
-		count = 0
+		count = -1
 		# Determine command
 		for cmd, tests in self.rules:
+			self._skip = None
 			self._app_flags = ''
 			self._app_label = None
 			for test in tests:
 				if not self._eval_condition(test, files, label):
 					break
 			else:
+				if self._skip is None:
+					count += 1
+				else:
+					count = self._skip
 				if label and label == self._app_label or \
 					not label and count == way:
 					cmd = self.hook_command_preprocessing(cmd)
 					command = self._build_command(files, cmd, flags)
 					break
-				else:
-					count += 1
 		# Execute command
 		if command is None:
 			if count <= 0 or way <= 0: