fusuma 0.7.2 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 23ebe4c1c6c7e8d235d7396d19b5c578d64d2347
4
- data.tar.gz: '08aea58d39bd8c9052151950ecd621a9422635ef'
3
+ metadata.gz: 006b0257ed698f1e84f48003c23dbe5090ff1a77
4
+ data.tar.gz: 8acb3579213176b578501b6c13be87ec2b2cef47
5
5
  SHA512:
6
- metadata.gz: 40a518e04442513efb8d161b2ad79b72f471d52f53631d030ae70433f18351d76eb40c9097e0d46713508487532bfc80a32d3907db31f7bc4d918a19bf59a3f9
7
- data.tar.gz: 3a79ce9faa1447b3c2b6528d194a167dc5150c4de9ea04b7d6e588428afc3485855e387386023ad5a7ef53808d917aca5f3873271b227145c3d4bd413454c00e
6
+ metadata.gz: cfcbbae537901fe01b32a655a236ba665317a0f6f56193d97a8b9834efab141a5405f0d0375a091b81a493d7438787080076896aa2f92c5993a3194c9a45177f
7
+ data.tar.gz: d4295e32fd124ff621d6cf180f0250fe0cedae70eb168f0e13da6117573d0270dec8ed3188b6907f93dd7df922e6c98cc37c4f70a00968529540c10623fea48a
data/README.md CHANGED
@@ -126,7 +126,9 @@ If the swipe's interval is `0.5`, shorten swipe-interval by half to recognize a
126
126
 
127
127
  * `-c`, `--config=path/to/file` : Use an alternative config file
128
128
  * `-d`, `--daemon` : Daemonize process
129
+ * `-l`, `--list-devices` : List available devices
129
130
  * `-v`, `--verbose` : Show details about the results of running fusuma
131
+ * `--device=event14` : Open the given device only
130
132
  * `--version` : Show fusuma version
131
133
 
132
134
  ## Contributing
data/exe/fusuma CHANGED
@@ -4,31 +4,37 @@ require 'optparse'
4
4
  require_relative '../lib/fusuma'
5
5
 
6
6
  option = {}
7
- OptionParser.new do |opt|
8
- opt.on('-c',
9
- '--config=path/to/file',
10
- 'Use an alternative config file') do |config_path|
11
- option[:config_path] = config_path
12
- end
13
-
14
- opt.on('-d',
15
- '--daemon',
16
- 'Daemonize process') do |daemon|
17
- option[:daemon] = daemon
18
- end
19
-
20
- opt.on('-v',
21
- '--verbose',
22
- 'Show details about the results of running fusuma') do |verbose|
23
- option[:verbose] = verbose
24
- end
25
-
26
- opt.on('--version',
27
- 'Show fusuma version') do |version|
28
- option[:version] = version
29
- end
30
-
31
- opt.parse!(ARGV)
7
+ opt = OptionParser.new
8
+
9
+ opt.on('-c', '--config=path/to/file',
10
+ 'Use an alternative config file') do |v|
11
+ option[:config_path] = v
12
+ end
13
+
14
+ opt.on('-d', '--daemon',
15
+ 'Daemonize process') do |v|
16
+ option[:daemon] = v
17
+ end
18
+
19
+ opt.on('-l', '--list-devices',
20
+ 'List available devices') do |v|
21
+ option[:list] = v
22
+ end
23
+
24
+ opt.on('--device=event14',
25
+ 'Open the given device only') do |v|
26
+ option[:device] = v
27
+ end
28
+
29
+ opt.on('-v', '--verbose',
30
+ 'Show details about the results of running fusuma') do |v|
31
+ option[:verbose] = v
32
32
  end
33
33
 
34
+ opt.on('--version', 'Show fusuma version') do |v|
35
+ option[:version] = v
36
+ end
37
+
38
+ opt.parse!(ARGV)
39
+
34
40
  Fusuma::Runner.run(option)
@@ -31,27 +31,40 @@ module Fusuma
31
31
  Signal.trap('TERM') { puts exit } # Trap `Kill `
32
32
  end
33
33
 
34
+ def read_options(option)
35
+ print_version && exit(0) if option[:version]
36
+ print_device_list if option[:list]
37
+ reload_custom_config(option[:config_path])
38
+ debug_mode if option[:verbose]
39
+ Device.given_device = option[:device]
40
+ Process.daemon if option[:daemon]
41
+ end
42
+
34
43
  def print_version
35
- puts '---------------------------------------------'
36
- puts "Fusuma: #{Fusuma::VERSION}"
37
- puts "libinput: #{LibinputCommands.new.version}"
38
- puts "OS: #{`uname -rsv`}"
39
- puts "Distribution: #{`cat /etc/issue`}"
40
- puts "Desktop session: #{`echo $DESKTOP_SESSION`}"
41
- puts '---------------------------------------------'
44
+ MultiLogger.info '---------------------------------------------'
45
+ MultiLogger.info "Fusuma: #{Fusuma::VERSION}"
46
+ MultiLogger.info "libinput: #{LibinputCommands.new.version}"
47
+ MultiLogger.info "OS: #{`uname -rsv`}".strip
48
+ MultiLogger.info "Distribution: #{`cat /etc/issue`}".strip
49
+ MultiLogger.info "Desktop session: #{`echo $DESKTOP_SESSION`}".strip
50
+ MultiLogger.info '---------------------------------------------'
42
51
  end
43
52
 
44
- def reload_custom_config(config_path)
53
+ def print_device_list
54
+ puts Device.names
55
+ exit(0)
56
+ end
57
+
58
+ def reload_custom_config(config_path = nil)
59
+ return unless config_path
45
60
  MultiLogger.info "use custom path: #{config_path}"
46
61
  Config.instance.custom_path = config_path
47
62
  Config.reload
48
63
  end
49
64
 
50
- def read_options(option)
51
- print_version if option[:version] || option[:verbose]
52
- reload_custom_config(option[:config_path]) if option[:config_path]
53
- MultiLogger.instance.debug_mode = true if option[:verbose]
54
- Process.daemon if option[:daemon]
65
+ def debug_mode
66
+ print_version
67
+ MultiLogger.instance.debug_mode = true
55
68
  end
56
69
  end
57
70
 
@@ -5,7 +5,7 @@ module Fusuma
5
5
  attr_writer :names
6
6
 
7
7
  def names
8
- return @names unless @names.nil?
8
+ return @names unless no_name?
9
9
  device_names = fetch_device_names
10
10
  MultiLogger.debug(device_names: device_names)
11
11
  raise 'Touchpad is not found' if device_names.empty?
@@ -15,8 +15,23 @@ module Fusuma
15
15
  exit 1
16
16
  end
17
17
 
18
+ # @params [String]
19
+ def given_device=(name)
20
+ return if name.nil?
21
+ if names.include? name
22
+ self.names = [name]
23
+ return
24
+ end
25
+ MultiLogger.error("Device #{name} is not found")
26
+ exit 1
27
+ end
28
+
18
29
  private
19
30
 
31
+ def no_name?
32
+ @names.nil? || @names.empty?
33
+ end
34
+
20
35
  # @return [Array]
21
36
  def fetch_device_names
22
37
  [].tap do |devices|
@@ -1,3 +1,3 @@
1
1
  module Fusuma
2
- VERSION = '0.7.2'.freeze
2
+ VERSION = '0.8.0'.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.7.2
4
+ version: 0.8.0
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-17 00:00:00.000000000 Z
11
+ date: 2018-06-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler