summary refs log tree commit diff stats
path: root/ranger
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2010-06-04 16:52:30 +0200
committerhut <hut@lavabit.com>2010-06-04 16:52:30 +0200
commitdd7f4e5c27fc04cb2abb93e659c3ec1c4411a662 (patch)
treee6822b7d7d6e1e538ba9ed0094114a661b2d33da /ranger
parent43e0f44a4788f3251d5f2ad7c1bfeff014353aba (diff)
downloadranger-dd7f4e5c27fc04cb2abb93e659c3ec1c4411a662.tar.gz
added preview_script option
Diffstat (limited to 'ranger')
-rw-r--r--ranger/api/options.py1
-rw-r--r--ranger/defaults/options.py3
-rw-r--r--ranger/fsobject/file.py15
-rw-r--r--ranger/shared/settings.py1
4 files changed, 14 insertions, 6 deletions
diff --git a/ranger/api/options.py b/ranger/api/options.py
index ee947b39..aee6150b 100644
--- a/ranger/api/options.py
+++ b/ranger/api/options.py
@@ -17,3 +17,4 @@ import re
 from re import compile as regexp
 from ranger.api import *
 from ranger.gui import color
+from ranger import relpath, relpath_conf
diff --git a/ranger/defaults/options.py b/ranger/defaults/options.py
index 23752d97..feb02a58 100644
--- a/ranger/defaults/options.py
+++ b/ranger/defaults/options.py
@@ -39,6 +39,9 @@ hidden_filter = regexp(
 	r'^\.|\.(?:pyc|pyo|bak|swp)$|~$|lost\+found')
 show_hidden = False
 
+# Which script is used to generate file previews?
+preview_script = relpath('ext/preview.sh')  # relative to rangers path
+
 # Show dotfiles in the bookmark preview box?
 show_hidden_bookmarks = True
 
diff --git a/ranger/fsobject/file.py b/ranger/fsobject/file.py
index 25902f57..cd5b37ff 100644
--- a/ranger/fsobject/file.py
+++ b/ranger/fsobject/file.py
@@ -92,10 +92,13 @@ class File(FileSystemObject):
 		return True
 
 	def get_preview_source(self):
-		try:
-			p = Popen([relpath('ext/preview.sh'), self.path],
-					stdout=PIPE, stderr=devnull)
-			if not p.poll():
+		if self.fm.settings.preview_script:
+			try:
+				p = Popen([self.fm.settings.preview_script, self.path],
+						stdout=PIPE, stderr=devnull)
+				if p.poll():  # nonzero exit code
+					return None
 				return p.stdout
-		except:
-			return open(self.path, 'r')
+			except:
+				pass
+		return open(self.path, 'r')
diff --git a/ranger/shared/settings.py b/ranger/shared/settings.py
index f5d8614f..24aea39c 100644
--- a/ranger/shared/settings.py
+++ b/ranger/shared/settings.py
@@ -41,6 +41,7 @@ ALLOWED_SETTINGS = {
 	'tilde_in_titlebar': bool,
 	'max_history_size': (int, type(None)),
 	'max_console_history_size': (int, type(None)),
+	'preview_script': (str, type(None)),
 	'scroll_offset': int,
 	'preview_files': bool,
 	'preview_directories': bool,
a614f048 ^





f07bb12f ^




a614f048 ^









































34a60763 ^
f07bb12f ^
62cd83ba ^


f07bb12f ^








62cd83ba ^
f07bb12f ^







a614f048 ^

f07bb12f ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126