fusuma 0.7.1 → 0.7.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +4 -0
- data/Rakefile +3 -3
- data/bin/console +4 -4
- data/fusuma.gemspec +3 -4
- data/lib/fusuma.rb +13 -27
- data/lib/fusuma/device.rb +8 -11
- data/lib/fusuma/libinput_commands.rb +95 -0
- data/lib/fusuma/version.rb +1 -1
- metadata +25 -25
- data/LICENSE.txt +0 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 23ebe4c1c6c7e8d235d7396d19b5c578d64d2347
|
4
|
+
data.tar.gz: '08aea58d39bd8c9052151950ecd621a9422635ef'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 40a518e04442513efb8d161b2ad79b72f471d52f53631d030ae70433f18351d76eb40c9097e0d46713508487532bfc80a32d3907db31f7bc4d918a19bf59a3f9
|
7
|
+
data.tar.gz: 3a79ce9faa1447b3c2b6528d194a167dc5150c4de9ea04b7d6e588428afc3485855e387386023ad5a7ef53808d917aca5f3873271b227145c3d4bd413454c00e
|
data/.rubocop.yml
CHANGED
data/Rakefile
CHANGED
data/bin/console
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'fusuma'
|
5
5
|
|
6
6
|
# You can add fixtures and/or initialization code here to make experimenting
|
7
7
|
# with your gem easier. You can also use a different console, if you like.
|
8
8
|
|
9
9
|
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
-
require
|
11
|
-
require
|
10
|
+
require 'pry'
|
11
|
+
require 'pry-byebug'
|
12
12
|
Pry.start
|
data/fusuma.gemspec
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
# coding: utf-8
|
2
1
|
lib = File.expand_path('../lib', __FILE__)
|
3
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
3
|
require 'fusuma/version'
|
@@ -22,10 +21,10 @@ Gem::Specification.new do |spec|
|
|
22
21
|
spec.require_paths = ['lib']
|
23
22
|
|
24
23
|
spec.add_development_dependency 'bundler', '~> 1.13'
|
25
|
-
spec.add_development_dependency 'rake', '~> 12.3'
|
26
|
-
spec.add_development_dependency 'rspec', '~> 3.0'
|
27
24
|
spec.add_development_dependency 'pry'
|
28
25
|
spec.add_development_dependency 'pry-byebug'
|
29
|
-
spec.add_development_dependency '
|
26
|
+
spec.add_development_dependency 'rake', '~> 12.3'
|
30
27
|
spec.add_development_dependency 'reek'
|
28
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
29
|
+
spec.add_development_dependency 'rubocop'
|
31
30
|
end
|
data/lib/fusuma.rb
CHANGED
@@ -7,6 +7,7 @@ require_relative 'fusuma/pinch.rb'
|
|
7
7
|
require_relative 'fusuma/multi_logger'
|
8
8
|
require_relative 'fusuma/config.rb'
|
9
9
|
require_relative 'fusuma/device.rb'
|
10
|
+
require_relative 'fusuma/libinput_commands.rb'
|
10
11
|
require 'logger'
|
11
12
|
require 'open3'
|
12
13
|
require 'yaml'
|
@@ -20,7 +21,7 @@ module Fusuma
|
|
20
21
|
set_trap
|
21
22
|
read_options(option)
|
22
23
|
instance = new
|
23
|
-
instance.
|
24
|
+
instance.run
|
24
25
|
end
|
25
26
|
|
26
27
|
private
|
@@ -31,12 +32,13 @@ module Fusuma
|
|
31
32
|
end
|
32
33
|
|
33
34
|
def print_version
|
34
|
-
puts
|
35
|
+
puts '---------------------------------------------'
|
35
36
|
puts "Fusuma: #{Fusuma::VERSION}"
|
37
|
+
puts "libinput: #{LibinputCommands.new.version}"
|
36
38
|
puts "OS: #{`uname -rsv`}"
|
37
39
|
puts "Distribution: #{`cat /etc/issue`}"
|
38
40
|
puts "Desktop session: #{`echo $DESKTOP_SESSION`}"
|
39
|
-
puts
|
41
|
+
puts '---------------------------------------------'
|
40
42
|
end
|
41
43
|
|
42
44
|
def reload_custom_config(config_path)
|
@@ -53,31 +55,15 @@ module Fusuma
|
|
53
55
|
end
|
54
56
|
end
|
55
57
|
|
56
|
-
def
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
event_trigger.send_command unless event_trigger.nil?
|
65
|
-
end
|
58
|
+
def run
|
59
|
+
LibinputCommands.new.debug_events do |line|
|
60
|
+
gesture_action = GestureAction.initialize_by(line, Device.names)
|
61
|
+
next if gesture_action.nil?
|
62
|
+
@action_stack ||= ActionStack.new
|
63
|
+
@action_stack << gesture_action
|
64
|
+
event_trigger = @action_stack.generate_event_trigger
|
65
|
+
event_trigger.send_command unless event_trigger.nil?
|
66
66
|
end
|
67
67
|
end
|
68
|
-
|
69
|
-
private
|
70
|
-
|
71
|
-
def libinput_command
|
72
|
-
return @libinput_command if @libinput_command
|
73
|
-
prefix = 'stdbuf -oL --'
|
74
|
-
command = 'libinput-debug-events'
|
75
|
-
device_option = if Device.names.size == 1
|
76
|
-
"--device /dev/input/#{Device.names.first}"
|
77
|
-
end
|
78
|
-
@libinput_command = [prefix, command, device_option].join(' ')
|
79
|
-
MultiLogger.debug(libinput_command: @libinput_command)
|
80
|
-
@libinput_command
|
81
|
-
end
|
82
68
|
end
|
83
69
|
end
|
data/lib/fusuma/device.rb
CHANGED
@@ -17,21 +17,18 @@ module Fusuma
|
|
17
17
|
|
18
18
|
private
|
19
19
|
|
20
|
+
# @return [Array]
|
20
21
|
def fetch_device_names
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
22
|
+
[].tap do |devices|
|
23
|
+
current_device = nil
|
24
|
+
LibinputCommands.new.list_devices do |line|
|
25
|
+
current_device = extracted_input_device_from(line) || current_device
|
26
|
+
next unless natural_scroll_is_available?(line)
|
27
|
+
devices << current_device
|
28
|
+
end
|
26
29
|
end.compact
|
27
30
|
end
|
28
31
|
|
29
|
-
def list_devices_logs
|
30
|
-
Open3.popen3('libinput-list-devices') do |_i, o, _e, _w|
|
31
|
-
return o.to_a
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
32
|
def extracted_input_device_from(line)
|
36
33
|
return unless line =~ /^Kernel: /
|
37
34
|
line.match(/event[0-9]+/).to_s
|
@@ -0,0 +1,95 @@
|
|
1
|
+
module Fusuma
|
2
|
+
# libinput commands wrapper
|
3
|
+
class LibinputCommands
|
4
|
+
def initialize(*options)
|
5
|
+
@options = options
|
6
|
+
end
|
7
|
+
|
8
|
+
# `libinput-list-devices` and `libinput-debug-events` are deprecated,
|
9
|
+
# use `libinput list-devices` and `libinput debug-events` from 1.8.
|
10
|
+
NEW_CLI_OPTION_VERSION = 1.8
|
11
|
+
|
12
|
+
# @return [Boolean]
|
13
|
+
def new_cli_option_available?
|
14
|
+
Gem::Version.new(version) >= Gem::Version.new(NEW_CLI_OPTION_VERSION)
|
15
|
+
end
|
16
|
+
|
17
|
+
# @return [String]
|
18
|
+
def version
|
19
|
+
# versiom_command prints "1.6.3\n"
|
20
|
+
@version ||= `#{version_command}`.strip
|
21
|
+
end
|
22
|
+
|
23
|
+
# @yield [line] gives a line in libinput list-devices output to the block
|
24
|
+
def list_devices
|
25
|
+
cmd = list_devices_command
|
26
|
+
MultiLogger.debug(debug_events: cmd)
|
27
|
+
Open3.popen3(cmd) do |_i, o, _e, _w|
|
28
|
+
o.each { |line| yield(line) }
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
# @yield [line] gives a line in libinput debug-events output to the block
|
33
|
+
def debug_events
|
34
|
+
prefix = 'stdbuf -oL --'
|
35
|
+
options = [*@options, device_option]
|
36
|
+
cmd = "#{prefix} #{debug_events_command} #{options.join(' ')}".strip
|
37
|
+
MultiLogger.debug(debug_events: cmd)
|
38
|
+
Open3.popen3(cmd) do |_i, o, _e, _w|
|
39
|
+
o.each { |line| yield(line) }
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
# @return [String] command
|
44
|
+
# @raise [SystemExit]
|
45
|
+
def version_command
|
46
|
+
if which('libinput')
|
47
|
+
'libinput --version'
|
48
|
+
elsif which('libinput-list-devices')
|
49
|
+
'libinput-list-devices --version'
|
50
|
+
else
|
51
|
+
MultiLogger.error 'install libinput-tools'
|
52
|
+
exit 1
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def list_devices_command
|
57
|
+
if new_cli_option_available?
|
58
|
+
'libinput list-devices'
|
59
|
+
else
|
60
|
+
'libinput-list-devices'
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def debug_events_command
|
65
|
+
if new_cli_option_available?
|
66
|
+
'libinput debug-events'
|
67
|
+
else
|
68
|
+
'libinput-debug-events'
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
private
|
73
|
+
|
74
|
+
def device_option
|
75
|
+
"--device /dev/input/#{Device.names.first}" if Device.names.size == 1
|
76
|
+
end
|
77
|
+
|
78
|
+
# which in ruby: Checking if program exists in $PATH from ruby
|
79
|
+
# (https://stackoverflow.com/questions/2108727/which-in-ruby-checking-if-program-exists-in-path-from-ruby)
|
80
|
+
# Cross-platform way of finding an executable in the $PATH.
|
81
|
+
#
|
82
|
+
# which('ruby') #=> /usr/bin/ruby
|
83
|
+
# @return [String, nil]
|
84
|
+
def which(command)
|
85
|
+
exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
|
86
|
+
ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
|
87
|
+
exts.each do |ext|
|
88
|
+
exe = File.join(path, "#{command}#{ext}")
|
89
|
+
return exe if File.executable?(exe) && !File.directory?(exe)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
nil
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
data/lib/fusuma/version.rb
CHANGED
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.7.
|
4
|
+
version: 0.7.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- iberianpig
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-06-
|
11
|
+
date: 2018-06-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -25,49 +25,49 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.13'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: pry
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: pry-byebug
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: rake
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '12.3'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - "
|
66
|
+
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
68
|
+
version: '12.3'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: reek
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - ">="
|
@@ -81,21 +81,21 @@ dependencies:
|
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
84
|
+
name: rspec
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- - "
|
87
|
+
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '0'
|
89
|
+
version: '3.0'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- - "
|
94
|
+
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: '0'
|
96
|
+
version: '3.0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
98
|
+
name: rubocop
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
101
|
- - ">="
|
@@ -127,7 +127,6 @@ files:
|
|
127
127
|
- Gemfile
|
128
128
|
- ISSUE_TEMPLATE.md
|
129
129
|
- LICENSE
|
130
|
-
- LICENSE.txt
|
131
130
|
- README.md
|
132
131
|
- Rakefile
|
133
132
|
- bin/console
|
@@ -141,6 +140,7 @@ files:
|
|
141
140
|
- lib/fusuma/device.rb
|
142
141
|
- lib/fusuma/event_trigger.rb
|
143
142
|
- lib/fusuma/gesture_action.rb
|
143
|
+
- lib/fusuma/libinput_commands.rb
|
144
144
|
- lib/fusuma/multi_logger.rb
|
145
145
|
- lib/fusuma/pinch.rb
|
146
146
|
- lib/fusuma/swipe.rb
|
data/LICENSE.txt
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
The MIT License (MIT)
|
2
|
-
|
3
|
-
Copyright (c) 2016 iberianpig
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
7
|
-
in the Software without restriction, including without limitation the rights
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
10
|
-
furnished to do so, subject to the following conditions:
|
11
|
-
|
12
|
-
The above copyright notice and this permission notice shall be included in
|
13
|
-
all copies or substantial portions of the Software.
|
14
|
-
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
-
THE SOFTWARE.
|