fusuma 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a510876d65266f27fc0ec9b809912b28cb9528fa
4
- data.tar.gz: 36e206f619ae2689ed336f403c16c3afb32b9f82
3
+ metadata.gz: 5cffada31c25586ccf5d1c54eb347ac2b3cd93c2
4
+ data.tar.gz: 7644035ee0feabcb090ed5399620860a7cec1e20
5
5
  SHA512:
6
- metadata.gz: ca75e1cf8a7f0921018fd353b5db9a88c4544d6f5fb7d33372c3f6776a0fbdc45c2365087c7b0f1342dd3f20d88386ba53943a1630cc0436a3947fa1c172a083
7
- data.tar.gz: 1ddf273b0a1850ef257dd02826c8d62f765d19adf232c26fcf85452c8d61bb52f11a60ed45bd1168b5a0d45db4ccabdfd72ff03ca2e9924da4536462db9246f3
6
+ metadata.gz: 8aa3a21616162678ee8397deb0cd3168a4f6cf4ff132123330e4f5c9511cdc504457d76b7de919c698b86f8f0d5dca4438ebd6f25198f330e9f04ff166c56dfd
7
+ data.tar.gz: 390ef29b0020a6f1f76f1eba9ccf9b2345430b4ade22d2734affb5cad443910465a8ead153edcf60244b9efe732728102691956d4f7b79203a89f71f6246a181
data/README.md CHANGED
@@ -32,7 +32,6 @@ Install Fusuma:
32
32
 
33
33
  ## Customize
34
34
 
35
-
36
35
  You can customize the settings for gestues to put and edit `~/.config/fusuma/config.yml`.
37
36
 
38
37
  ### Sample (default keymap for Elementary OS)
@@ -64,6 +63,10 @@ pinch:
64
63
  shortcut: 'ctrl+minus'
65
64
  ```
66
65
 
66
+ ## Options
67
+
68
+ * `-v` : Enable debug mode.
69
+
67
70
  ## Contributing
68
71
 
69
72
  Bug reports and pull requests are welcome on GitHub at https://github.com/iberianpig/fusuma. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
data/exe/fusuma CHANGED
@@ -2,4 +2,5 @@
2
2
 
3
3
  require_relative '../lib/fusuma'
4
4
 
5
- Fusuma.run
5
+ options = ARGV.getopts('v')
6
+ Fusuma::Runner.run(v: options['v'])
@@ -1,23 +1,31 @@
1
1
  require_relative 'fusuma/version'
2
2
  require_relative 'fusuma/action_stack'
3
3
  require_relative 'fusuma/gesture_action'
4
+ require_relative 'fusuma/multi_logger'
4
5
  require 'logger'
5
6
  require 'open3'
6
7
  require 'yaml'
8
+ require 'optparse'
9
+
10
+ # for debug
11
+ # require 'pry-byebug'
7
12
 
8
13
  # this is top level module
9
14
  module Fusuma
10
- class << self
11
- def run
12
- read_libinput
15
+ # main class
16
+ class Runner
17
+ def self.run(args = {})
18
+ debug = args.fetch(:v, false)
19
+ MultiLogger.instance.debug_mode = true if debug
20
+ instance = new
21
+ MultiLogger.debug('Enable debug lines')
22
+ instance.read_libinput
13
23
  end
14
24
 
15
- private
16
-
17
25
  def read_libinput
18
26
  Open3.popen3(libinput_command) do |_i, o, _e, _w|
19
27
  o.each do |line|
20
- gesture_action = GestureAction.initialize_by_libinput(line, device_name)
28
+ gesture_action = GestureAction.initialize_by(line, device_name)
21
29
  next if gesture_action.nil?
22
30
  @action_stack ||= ActionStack.new
23
31
  @action_stack.push gesture_action
@@ -27,15 +35,20 @@ module Fusuma
27
35
  end
28
36
  end
29
37
 
38
+ private
39
+
30
40
  def libinput_command
31
41
  @libinput_command ||= "stdbuf -oL -- libinput-debug-events --device \
32
42
  /dev/input/#{device_name}"
43
+ MultiLogger.debug(libinput_command: @libinput_command)
44
+ @libinput_command
33
45
  end
34
46
 
35
47
  def device_name
36
48
  return @device_name unless @device_name.nil?
37
49
  Open3.popen3('libinput-list-devices') do |_i, o, _e, _w|
38
50
  o.each do |line|
51
+ MultiLogger.debug(line)
39
52
  extracted_input_device_from(line)
40
53
  next unless touch_is_available?(line)
41
54
  return @device_name
@@ -8,10 +8,12 @@ module Fusuma
8
8
  # return { finger:, direction:, action: } or nil
9
9
  def gesture_info
10
10
  return unless enough_actions?
11
+ MultiLogger.debug(enough_actions?: enough_actions?)
11
12
  direction = detect_direction
12
13
  finger = detect_finger
13
14
  action = detect_action
14
15
  clear
16
+ MultiLogger.debug(finger: finger, direction: direction, action: action)
15
17
  GestureInfo.new(finger, direction, action)
16
18
  end
17
19
 
@@ -13,13 +13,13 @@ module Fusuma
13
13
  :move_x, :move_y, :pinch
14
14
 
15
15
  class << self
16
- def initialize_by_libinput(line, device_name)
16
+ def initialize_by(line, device_name)
17
17
  return unless line.to_s =~ /^#{device_name}/
18
18
  return if line.to_s =~ /_BEGIN/
19
19
  return unless line.to_s =~ /GESTURE_SWIPE|GESTURE_PINCH/
20
20
  time, action, finger, directions = gesture_action_arguments(line)
21
- logger.debug(line)
22
- logger.debug(directions)
21
+ MultiLogger.debug(time: time, action: action,
22
+ finger: finger, directions: directions)
23
23
  GestureAction.new(time, action, finger, directions)
24
24
  end
25
25
 
@@ -27,7 +27,8 @@ module Fusuma
27
27
 
28
28
  def gesture_action_arguments(libinput_line)
29
29
  action, time, finger_directions = parse_libinput(libinput_line)
30
- finger, move_x, move_y, pinch = parse_finger_directions(finger_directions)
30
+ finger, move_x, move_y, pinch =
31
+ parse_finger_directions(finger_directions)
31
32
  directions = { move: { x: move_x, y: move_y }, pinch: pinch }
32
33
  [time, action, finger, directions]
33
34
  end
@@ -43,14 +44,6 @@ module Fusuma
43
44
  finger_directions_line.tr('/', ' ').split
44
45
  [finger_num, move_x, move_y, pinch]
45
46
  end
46
-
47
- def logger
48
- @logger ||= begin
49
- log = Logger.new(STDOUT)
50
- log.level = Logger::WARN
51
- log
52
- end
53
- end
54
47
  end
55
48
  end
56
49
  end
@@ -0,0 +1,58 @@
1
+ # module as namespace
2
+ module Fusuma
3
+ require 'logger'
4
+ require 'singleton'
5
+ # logger separate between stdout and strerr
6
+ class MultiLogger < Logger
7
+ include Singleton
8
+ def initialize
9
+ super(STDOUT)
10
+ @err_logger = Logger.new(STDERR)
11
+ @debug_mode = false
12
+ end
13
+ attr_reader :err_logger
14
+ attr_accessor :debug_mode
15
+
16
+ def info(msg)
17
+ return unless debug_mode?
18
+ super(msg)
19
+ end
20
+
21
+ def debug(msg)
22
+ return unless debug_mode?
23
+ super(msg)
24
+ end
25
+
26
+ def warn(msg)
27
+ return unless debug_mode?
28
+ err_logger.warn(msg)
29
+ end
30
+
31
+ def error(msg)
32
+ return unless debug_mode?
33
+ err_logger.error(msg)
34
+ end
35
+
36
+ def debug_mode?
37
+ debug_mode
38
+ end
39
+
40
+ class << self
41
+ def info(msg)
42
+ instance.info(msg)
43
+ end
44
+
45
+ def debug(msg)
46
+ instance.debug(msg)
47
+ end
48
+
49
+ def warn(msg)
50
+ instance.warn(msg)
51
+ end
52
+
53
+ def error(msg)
54
+ instance.error(msg)
55
+ end
56
+ end
57
+ end
58
+ end
@@ -1,3 +1,3 @@
1
1
  module Fusuma
2
- VERSION = "0.1.4"
2
+ VERSION = '0.1.5'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fusuma
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - iberianpig
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-11-17 00:00:00.000000000 Z
11
+ date: 2016-12-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -94,6 +94,7 @@ files:
94
94
  - lib/fusuma/action_stack.rb
95
95
  - lib/fusuma/config.yml
96
96
  - lib/fusuma/gesture_action.rb
97
+ - lib/fusuma/multi_logger.rb
97
98
  - lib/fusuma/version.rb
98
99
  homepage: https://github.com/iberianpig/fusuma
99
100
  licenses: