about summary refs log tree commit diff stats
path: root/data/apps.rb
blob: 089aba40f2f691fcb801629d5e3ba141d424f356 (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
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
127
128
129
130
131
132
133
134
135
136
137
## This file defines programs, and HOW those
## programs are run.
##
## Look at the definition of "totem" for a
## fully documented example.


module Application
	## def totem(files) starts the definition of totem
	def totem(files)
		## this is the `case' statement.
		## it looks up the mode and does different
		## things depending on the mode.
		case files.mode

		## if the mode is 0 (default)
		when 0
			## start totem in fullscreen
			"totem --fullscreen #{files}"

		## if the mode is 1
		when 1
			## start totem normally
			"totem #{files}"
		end

		## the mode is a number which you type in
		## between two r's. for example, press:
		## r1r
		## to run the file in mode 1.
		## there are shortcuts: the key l runs in mode 0,
		## and L in mode 1.

		## the variable `files' is of a type RunContext,
		## see ranger/code/runcontext.rb for details.
	end


	def aunpack(files)
		case files.mode
		when 0; "aunpack #{files}"
		when 1; "aunpack -l #{files} | less"
		end
	end

	def gedit(files)
		"gedit #{files}"
	end

	def mplayer(files)
		case files.mode
		when 0; "mplayer -fs -sid 0 #{files}"
		when 1; "mplayer -fs -sid 0 -vfm ffmpeg -lavdopts lowres=1:fast:skiploopfilter=all:threads=8 #{files}"
		when 2; "mplayer -vm sdl -sid 0 #{files}"
		when 3; "mplayer -mixer software #{files}"
		when 4; "mplayer -vo caca #{files}"
		else nil end
	end

	def evince(files)
		"evince #{files}"
	end

	def feh(files)
		case files.mode
		when 0; "feh #{files}"
		when 1; "feh --bg-scale #{files.one}"
		when 2; "feh --bg-tile #{files.one}"
		when 3; "feh --bg-center #{files.one}"
		when 4; "gimp #{files}"
		when 5; "feh -F #{files}"
		else nil end
	end

	def interpreted_language(files)
		case files.mode
		when 1; run(files)
		when 0; vi(files)
		else nil end
	end

	def zsnes(files)
		"zsnes #{files.first}"
	end

	def run(files)
		files.first.executable? ? "#{files.one}" : nil
	end

	def vi_or_run(files)
		case files.mode
		when 1; run(files)
		when 0; vi(files)
		else nil end
	end

	def vi(files)
		files.dont_run_in_background

		commands = [
			'map h ZZ',
			'map q h',
			'map H :unmap h<CR>:unmap H<CR>:unmap q<CR>',
		].map {|x| "+'#{x}'"}.join(' ')

		"vi #{commands} #{files}"
	end

	def javac(files)
		"javac #{files}"
	end

	def java(files)
		"java #{files.files.map{|x| ~x.before_last('.')}.join(' ')}"
	end

	def firefox(files)
		"firefox #{files}"
	end

	def make(files)
		case files.mode
		when 0; "make"
		when 1; "make install"
		when 2; "make clear"
		else nil end
	end
	
	def rake(files)
		"rake"
	end

	## set the default editor for when pressing E
	alias editor vi

end