about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--code/scheduler.rb13
-rwxr-xr-xranger.rb6
2 files changed, 10 insertions, 9 deletions
diff --git a/code/scheduler.rb b/code/scheduler.rb
index e35f28d6..1ca4915e 100644
--- a/code/scheduler.rb
+++ b/code/scheduler.rb
@@ -12,8 +12,15 @@ module Scheduler
 		@active = false
 
 		@thread ||= Thread.new do
-			if EVIL
+			## I have two ways of doing this. the first is somewhat better
+			## but leads to problems with ncurses:
+			## sometimes if you close the terminal window by clicking on
+			## the X or pressing alt+F4 or in any other way that the window
+			## manager provides, it will not properly exit and keep running
+			## in the background, using up 100% CPU.
+			if Option.evil
 				Thread.current.priority = PRIORITY
+
 				while true
 					Thread.stop
 					manage unless @scheduled.empty? or !@active
@@ -40,10 +47,8 @@ module Scheduler
 		dir.scheduled = true
 		unless @scheduled.include? dir
 			@scheduled << dir
-			if EVIL
-				@thread.run
-			end
 		end
+		@thread.run if Option.evil
 	end
 
 	private
diff --git a/ranger.rb b/ranger.rb
index 3dc05e6d..485305e8 100755
--- a/ranger.rb
+++ b/ranger.rb
@@ -4,11 +4,6 @@ version = '0.2.4'
 require 'pathname'
 $: << MYDIR = File.dirname(Pathname(__FILE__).realpath)
 
-## this switches on some features which may cause harm,
-## mainly by leaving this program running after you quit it from
-## your window manager, ie. clicking on the X or pressing ALT+F4
-EVIL = false
-
 if ARGV.size > 0
 	case ARGV.first
 	when '-k'
@@ -50,6 +45,7 @@ opt = {
 	:debug_file             => '/tmp/errorlog',
 	:colorscheme            => 'default',
 	:cd                     => ARGV.include?('--cd'),
+	:evil                   => false
 }
 
 class OptionClass < Struct.new(*opt.keys)
#n158'>158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197