about summary refs log tree commit diff stats
path: root/data/types.rb
diff options
context:
space:
mode:
Diffstat (limited to 'data/types.rb')
-rw-r--r--data/types.rb35
1 files changed, 35 insertions, 0 deletions
diff --git a/data/types.rb b/data/types.rb
new file mode 100644
index 00000000..773df758
--- /dev/null
+++ b/data/types.rb
@@ -0,0 +1,35 @@
+class Directory::Entry
+	INTERPRETED_LANGUAGES = %w[haskell perl python ruby sh]
+	MOVIE_EXTENSIONS = %w[avi mpg mpeg mp4 mp5 ogv ogm wmv mkv flv fid vob div divx]
+
+	def get_handler
+		## directories or sockets don't have any handler
+		use.no_handler if dir? or socket?
+
+		## at first, look at the mime type
+		case @mimetype
+		when /^video|audio/
+			use.mplayer
+
+		when "application/pdf"
+			use.evince
+
+		when /^image/
+			use.feh
+
+		when /^(text|application).x-(#{INTERPRETED_LANGUAGES.join('|')})$/
+			use.interpreted_language
+
+		end
+
+		## second, look at the extension
+		case @ext
+		when 'swc', 'smc'
+			use.zsnes
+
+		end
+
+		use.vi
+	end
+end
+