lib/fusuma.rb in fusuma-0.1.7 vs lib/fusuma.rb in fusuma-0.1.8
- old
+ new
@@ -3,44 +3,29 @@
require_relative 'fusuma/gesture_action'
require_relative 'fusuma/multi_logger'
require 'logger'
require 'open3'
require 'yaml'
-require 'optparse'
# for debug
# require 'pry-byebug'
# this is top level module
module Fusuma
# main class
class Runner
class << self
- def run(args = {})
- read_options(args)
- return if @stop
+ def run(option = {})
+ read_options(option)
instance = new
instance.read_libinput
end
- def read_options(args)
- debug = args.fetch(:v, false)
- help = args.fetch(:h, false)
+ def read_options(option)
+ debug = option.fetch(:verbose, false)
MultiLogger.instance.debug_mode = true if debug
- @stop = if help
- print_help
- true
- else
- false
- end
end
-
- def print_help
- puts 'Options:
- -h, print this help.
- -v, print to STDOUT with debug mode.'
- end
end
def read_libinput
Open3.popen3(libinput_command) do |_i, o, _e, _w|
o.each do |line|
@@ -95,15 +80,15 @@
end
end
def swipe(finger, direction)
shortcut = event_map['swipe'][finger.to_i][direction]['shortcut']
- `xdotool key #{shortcut}`
+ `xdotool key #{shortcut}` unless shortcut.nil?
end
def pinch(zoom)
shortcut = event_map['pinch'][zoom]['shortcut']
- `xdotool key #{shortcut}`
+ `xdotool key #{shortcut}` unless shortcut.nil?
end
def event_map
@event_map ||= YAML.load_file(config_file)
end