From 32bacf7b37593027d60ed6318ef71713e42d7f97 Mon Sep 17 00:00:00 2001 From: hut Date: Thu, 4 Jun 2009 08:13:22 -0700 Subject: Initial commit --- ChangeLog | 9 ++--- Readme | 0 code/keys.rb | 29 ++--------------- code/types.rb | 39 +++++++++------------- fm | 103 ---------------------------------------------------------- ranger.rb | 103 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 126 insertions(+), 157 deletions(-) delete mode 100644 Readme delete mode 100755 fm create mode 100755 ranger.rb diff --git a/ChangeLog b/ChangeLog index 6c2edddd..f8e1ecd0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,7 +3,8 @@ Version 0.2.1 2009-05-09 hut Oh no. I neglegted to write change logs... in a nutshell, i changed: New Hotkey: [r]...flags...[r] which runs the selected file with flags - like [d] to detach the process or [t] to run it in a seperate terminal + like [d] to detach the process or [t] to run it in a seperate terminal. + This example would be [r][d][t][r] For that I also changed Action.run() 2009-04-27 hut @@ -15,8 +16,8 @@ Version 0.2.1 2009-04-18 hut Found reproducable bug which leaves it (after closing) running and using up - 99% CPU. It happens when the window managers way of closing windows by - pressing the X button or pressing Alt+F4 is used to quit. + 99% CPU. It happens if you close the window by pressing the X button, + the quit hotkey, or whatever. New Hotkeys: [S-TAB] is a shortcut for [`][`] and [TAB] for [`][9] Better distinguishable columns MIME support, allowing sorting by MIME-filetype @@ -29,7 +30,7 @@ Version 0.2.1 Replaced system() calls with cp or mv with the use of FileUtils Modified FileUtils for showing its progress the progressbar Fixed threading problem which made it impossible to stop copying/moving - Fixed priority problems, fluent UI while copying. + Fixed priority problems, faster UI while copying. TODO: enqueue file operations for better performance diff --git a/Readme b/Readme deleted file mode 100644 index e69de29b..00000000 diff --git a/code/keys.rb b/code/keys.rb index edcbab53..362adb34 100644 --- a/code/keys.rb +++ b/code/keys.rb @@ -5,7 +5,7 @@ module Fm g d df y c Z delet cu ter ta S ? ?g ?f :q - /[m`']/ /[fF/!q].*/ + /[m`']/ /[fF/!].*/ /[ri]\d*\w*[^ri]/ /(cw|cd|mv).*/ /b(l(o(c(k(.*)?)?)?)?)?/ @@ -166,31 +166,6 @@ module Fm when 'R' @pwd.refresh! - when '@', '.' - if defined? @record - @buffer = '' - memo = '' - @record.each_char do |c| - if memo.empty? - if c == '<' - memo << c - else - press c - end - else - memo << c - if c == '>' - press memo - memo.clear - end - end - end - end - - when /^q.+q$/ - @record = @buffer[1...-1] - @buffer = '' - when 'x' @bars.first.kill unless @bars.empty? @@ -567,7 +542,7 @@ module Fm # Action.run(:all=>true) # end - when 'ZZ', '', ':q' + when 'ZZ', '', ':q', 'Q' exit when '' diff --git a/code/types.rb b/code/types.rb index 96d67d06..adb03219 100644 --- a/code/types.rb +++ b/code/types.rb @@ -13,10 +13,10 @@ module Fm str = files.map{|x| x.sh}.join(' ') type = files.first.mimetype name = files.first.basename -# mode = hash.mode + mode = hash.mode use = lambda do |sym| - hash.exec = App.send(sym, hash, name, str, files) + hash.exec = App.send(sym, mode, name, str, files) end case type @@ -37,8 +37,8 @@ module Fm end module App - def image(hash, name, str, file) - case hash.mode + def image(mode, name, str, file) + case mode when 4; "feh --bg-scale #{str}" when 5; "feh --bg-tile #{str}" when 6; "feh --bg-center #{str}" @@ -47,35 +47,27 @@ module Fm else "feh #{str}" end end - def evince(hash, name, str, file) + def evince(mode, name, str, file) "evince #{str}" end - def mplayer(*args) - hash = args[0] = args[0].dup - str = args[2] + def mplayer(mode, name, str, files) + rest = name, str, files - if hash.detach - flags = '-msglevel all=-1' - else - flags = '' - end - - case hash.mode + case mode when nil if name =~ /720p/ - hash.mode = 1 + mplayer(1, *rest) else - hash.mode = 0 + mplayer(0, *rest) end - mplayer(*args) when 0 - return "mplayer #{flags} -fs -sid 0 #{str}" + return "mplayer -fs -sid 0 #{str}" when 1 - return "mplayer #{flags} -vm sdl -sid 0 #{str}" + return "mplayer -vm sdl -sid 0 #{str}" end end - def zsnes(hash, name, str, files) - case hash.mode + def zsnes(mode, name, str, files) + case mode when 1 return "zsnes -ad sdl -o #{str}" else @@ -136,7 +128,8 @@ module Fm return "aplay -q #{file.sh}" when /\.m3u$/i - return "/home/hut/bin/loadplaylist #{file.sh}" +# return "mpc play #{File.expand_path(file)[13..-1].sh}", false + return "/home/hut/bin/loadplaylist.rb #{file.sh}" # return "cmus-remote -c && cmus-remote -P #{file} && cmus-remote -C 'set play_library=false' && sleep 0.3 && cmus-remote -n", false end diff --git a/fm b/fm deleted file mode 100755 index 5aa8bae3..00000000 --- a/fm +++ /dev/null @@ -1,103 +0,0 @@ -#!/usr/bin/ruby -Ku - -# Log details -# 0 = do not log -# 1 = log fatalities -# 2 = log errors -# 3 = log everything -LOG_LEVEL = 3 -#LOG_LEVEL = 0 - - -def File::resolve_symlink( path = __FILE__ ) - path = readlink(path) while symlink?(path) - expand_path(path) -end - -def require_from_here ( *list ) - require File.join( FM_DIR, *list ) -end - -def fj( *args ) File.join( *args ) end - -$: << FM_DIR = File::dirname(File::resolve_symlink) - -#SCREENSAVER = fj FM_DIR, 'code', 'screensaver', 'clock.rb' - -PID = Process.pid - -if ARGV.size > 0 - case ARGV.first - when '-k' - exec "killall -9 fm" - end - pwd = ARGV.first - if pwd =~ /^file:\/\// - pwd = $' - end - - unless File.exists?(pwd) - pwd = nil - end - -else - pwd = nil -end - -#require 'ftools' -require 'pp' -require 'ostruct' -class OpenStruct; def __table__() @table end end -require 'thread' - -require_from_here 'interface/ncurses.rb' -require_from_here 'code/extensions/basic.rb' -require_from_here 'code/extensions/fileutils.rb' -require_from_here 'code/fm.rb' -require_from_here 'code/keys.rb' -require_from_here 'code/types.rb' -require_from_here 'code/bars.rb' -require_from_here 'code/action.rb' -require_from_here 'code/draw.rb' -require_from_here 'code/directory.rb' -require_from_here 'code/debug.rb' - -# Screensaver -require_from_here 'code/screensaver/clock.rb' - -unless ARGV.empty? or File.directory?(pwd) - exec(Fm.getfilehandler_frompath(pwd)) -end - -include Interface -include Debug - -ERROR_STREAM = File.open('/tmp/errorlog', 'a') - -#def log(obj) -# $stdout = ERROR_STREAM -# pp caller -# pp obj -# $stdout.flush -# $stdout = STDOUT -# obj -#end - -begin - Fm.initialize( pwd ) - Fm.main_loop -ensure - log "exiting!" - log "" - closei if Interface.running? - Fm.dump - ERROR_STREAM.close - - # Kill all other threads - for thr in Thread.list - unless thr == Thread.current - thr.kill - end - end -end - diff --git a/ranger.rb b/ranger.rb new file mode 100755 index 00000000..d98e2f39 --- /dev/null +++ b/ranger.rb @@ -0,0 +1,103 @@ +#!/usr/bin/ruby -Ku + +# Log details +# 0 = do not log +# 1 = log fatalities +# 2 = log errors +# 3 = log everything +LOG_LEVEL = 3 +#LOG_LEVEL = 0 + +require 'pathname' + +def File::resolve_symlink( path = __FILE__ ) + Pathname.new(path).realpath +end + +def require_from_here ( *list ) + require File.join( FM_DIR, *list ) +end + +def fj( *args ) File.join( *args ) end + +$: << FM_DIR = File::dirname(File::resolve_symlink) + +#SCREENSAVER = fj FM_DIR, 'code', 'screensaver', 'clock.rb' + +PID = Process.pid + +if ARGV.size > 0 + case ARGV.first + when '-k' + exec "killall -9 fm" + end + pwd = ARGV.first + if pwd =~ /^file:\/\// + pwd = $' + end + + unless File.exists?(pwd) + pwd = nil + end + +else + pwd = nil +end + +#require 'ftools' +require 'pp' +require 'ostruct' +class OpenStruct; def __table__() @table end end +require 'thread' + +require_from_here 'interface/ncurses.rb' +require_from_here 'code/extensions/basic.rb' +require_from_here 'code/extensions/fileutils.rb' +require_from_here 'code/fm.rb' +require_from_here 'code/keys.rb' +require_from_here 'code/types.rb' +require_from_here 'code/bars.rb' +require_from_here 'code/action.rb' +require_from_here 'code/draw.rb' +require_from_here 'code/directory.rb' +require_from_here 'code/debug.rb' + +# Screensaver +require_from_here 'code/screensaver/clock.rb' + +unless ARGV.empty? or File.directory?(pwd) + exec(Fm.getfilehandler_frompath(pwd)) +end + +include Interface +include Debug + +ERROR_STREAM = File.open('/tmp/errorlog', 'a') + +#def log(obj) +# $stdout = ERROR_STREAM +# pp caller +# pp obj +# $stdout.flush +# $stdout = STDOUT +# obj +#end + +begin + Fm.initialize( pwd ) + Fm.main_loop +ensure + log "exiting!" + log "" + closei if Interface.running? + Fm.dump + ERROR_STREAM.close + + # Kill all other threads + for thr in Thread.list + unless thr == Thread.current + thr.kill + end + end +end + -- cgit 1.4.1-2-gfad0 mp;id=d7494165ec7ae507c7340dcaad2e2c95fda5ee11'>d7494165 ^
1
2
3
4
5
6
7
8
9