diff options
author | hut <hut@lavabit.com> | 2009-06-13 02:20:46 +0200 |
---|---|---|
committer | hut <hut@lavabit.com> | 2009-06-13 02:20:46 +0200 |
commit | 2887ca25fb58362d5d644ecda5f0bc51c80ec404 (patch) | |
tree | b066f5542d97b1a4a9134d0910692b873fe32363 /data | |
parent | 325ec37f65172b5b640d998eba300d86d1ddbfa5 (diff) | |
download | ranger-2887ca25fb58362d5d644ecda5f0bc51c80ec404.tar.gz |
rewrite of the way files are executed, easier config
Diffstat (limited to 'data')
-rw-r--r-- | data/apps.rb | 58 | ||||
-rw-r--r-- | data/types.rb | 35 |
2 files changed, 93 insertions, 0 deletions
diff --git a/data/apps.rb b/data/apps.rb new file mode 100644 index 00000000..6ba7f44b --- /dev/null +++ b/data/apps.rb @@ -0,0 +1,58 @@ +module Application + def mplayer(rc) + check rc + + rc.default_flags = 'd' + + if rc.no_mode? + rc.mode = (rc.name =~ /720p/) ? 2 : 1 + end + + case rc.mode + when 1; "mplayer -fs -sid 0 #{~rc}" + when 2; "mplayer -sid 0 #{~rc}" + when 3; "mplayer -vm sdl -sid 0 #{~rc}" + else nil end + end + + def evince(rc) + check rc + "evince #{~rc}" + end + + def feh(rc) + check rc + case rc.mode + when 4; "feh --bg-scale #{~rc.first}" + when 5; "feh --bg-tile #{~rc.first}" + when 6; "feh --bg-center #{~rc.first}" + when 2; "gimp #{~rc}" + when 1; "feh -F #{~rc}" + else "feh #{~rc}" + end + end + + def interpreted_language(rc) + check rc + case rc.mode + when 1; "./#{~rc.first}" + when 0; vi(rc) + else nil end + end + + def zsnes(rc) + check rc + "zsnes #{~rc.first}" + end + + def vi(rc) + commands = [ + 'map h :quit<cr>', + 'map q h', + 'map H :unmap h<CR>:unmap H<CR>:unmap q<CR>', + ].map {|x| "+'#{x}'"}.join(' ') + + "vi #{commands} #{~rc}" + end +end + 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 + |