summary refs log tree commit diff stats
path: root/ranger/defaults/apps.py
blob: 041b85c8c15abe19f10430e60fed39138ec325a2 (plain) (blame)
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
from ranger.applications import Applications as SuperClass
from ranger.helper import popen as run

class CustomApplications(SuperClass):
	# How to determine the default application? {{{
	def app_default(self, **kw):
		f = kw['mainfile']

		if f.extension is not None and f.extension in ('pdf'):
			return self.app_evince(**kw)

		if f.container:
			return self.app_aunpack(**kw)

		if f.video or f.audio:
			if f.video:
				kw['flags'] += 'd'
			return self.app_mplayer(**kw)
		
		if f.image:
			return self.app_feh(**kw)

		if f.document:
			return self.app_editor(**kw)
	# }}}

	def app_pager(self, **kw):
		return run('less', *kw['files'], **kw)

	def app_vim(self, **kw):
		return run('vim', *kw['files'], **kw)

	app_editor = app_vim

	def app_mplayer(self, **kw):
		if kw['mode'] == 1:
			return run('mplayer', *kw['files'], **kw)

		elif kw['mode'] == 2:
			return run('mplayer', '-fs',
					'-sid', '0',
					'-vfm', 'ffmpeg',
					'-lavdopts', 'lowres=1:fast:skiploopfilter=all:threads=8',
					*kw['files'], **kw)

		else:
			return run('mplayer', '-fs', *kw['files'], **kw)

	def app_feh(self, **kw):
		return run('feh', *kw['files'], **kw)

	def app_aunpack(self, **kw):
		m = kw['mode']
		if m == 0:
			kw['flags'] += 'p'
			return run('aunpack', '-l', *kw['files'], **kw)
		elif m == 1:
			return run('aunpack', *kw['files'], **kw)
	
	def app_evince(self, **kw):
		return run('evince', *kw['files'], **kw)