- sudo commands (ask for password)
-- config in different places
- adding/removing entries directly from the program
- keep previous buffers for oneshot commands
- custom key bindings (and informations in the window)
- Key to force window update
- Customization of window size
- ~Internationalization
-- Some bugs with scrolling
- Respect colors from command?
-bugs:
-monitor.rb:264:in `last': negative array size (ArgumentError)
- from monitor.rb:264:in `yield'
- from monitor.rb:157:in `print_buffer'
- from monitor.rb:95:in `move_resize'
- from monitor.rb:345:in `block in redraw_all'
- from monitor.rb:344:in `each'
- from monitor.rb:344:in `redraw_all'
- from monitor.rb:389:in `<main>'
+Bugs:
+- Some bugs with scrolling
+
require "ncurses"
require "inifile"
require "open3"
+require 'optparse'
+require 'ostruct'
class IO
def readline_nonblock
end
end
+class OptParse
+ def parse(args)
+
+ options = OpenStruct.new()
+ options.inifile = nil
+
+ opt_parser = OptionParser.new() do |opts|
+
+ opts.banner = "Usage: monitor [options]"
+ opts.separator ""
+
+ opts.on( '-f', "-f ini_file", "chose a different initialization file") do |ini|
+ options.inifile = ini
+ end
+ end
+ opt_parser.parse!(args)
+ return options
+ end
+end
+
class List_Win
def initialize(inifile)
@params = inifile
if(force or (Time.now - @last_update > @params['Periodic'].to_i))
@buffer.clear()
spawn_proc()
+ clear()
end
end
print_buffer()
end
end
-def read_ini()
- inifile = IniFile.load('monitorrc')
+def find_ini(option_inifile)
+ if(not option_inifile.nil?)
+ inifile = option_inifile
+ elsif(ENV.has_key?('MONITOR_RC'))
+ inifile = ENV['MONITOR_RC']
+ elsif(Process.uid == 0)
+ inifile = "/etc/monitor.rc"
+ else
+ inifile = ENV['HOME']+"/.monitorrc"
+ end
+ return inifile
+end
+
+def read_ini(ini)
+ inifile = IniFile.load(ini)
+ if(inifile.nil?)
+ puts "Initialization file not found or not readable"
+ exit
+ end
return inifile
end
list.refresh()
curr_bufwin.refresh()
end
+
+
+options = OptParse.new().parse(ARGV)
+inifile = read_ini(find_ini(options.inifile))
begin
# initialize ncurses
Ncurses.initscr
Ncurses.init_pair(10, Ncurses::COLOR_WHITE, Ncurses::COLOR_BLACK)
- inifile = read_ini()
-
list = List_Win.new(inifile)
bufwins = make_bufwins(inifile)
entry = 0