xinput_wrapper 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ae4fcf42fbfa6e86aacfc6b9419f13719318a1e9
4
+ data.tar.gz: e5b1e93f433bbea0c0656a9aab67fb178782418f
5
+ SHA512:
6
+ metadata.gz: d1fee6164dc00a35d1d4348e90740efa3ec3747ed0de9ac213b2037bd1af9a5cd3ddf51a4daa7f66c8b9a475f2274cb52d2961302587edee5dfea4dc07c4bdd3
7
+ data.tar.gz: e33f39f7468246891e5334a4d218775eb551f6e7eb323d64c6db7a78fb4f3f941f064e6a67be903a67c761527993c1ceb6b04e1f9287faaa8e3dfa49faea9049
checksums.yaml.gz.sig ADDED
@@ -0,0 +1 @@
1
+ ��i���P�k�� ����,�#\�����t_f��q�S]s�C]���;A�Ŋ��x`�|Ь[��� Wcb����<Cdg]���`�����D����l���7Ҳ03�i2���|���ċ�m�m\l`8�h�+�iS��Yf&�'4e��y�_wD^�_98���$� �K��6���fμ�H��nF(���i{C�#Ե�o # Z�C�F�2*t���^wj�����ow\��f��3%p\����d1����Q��cr�Dr�
data.tar.gz.sig ADDED
@@ -0,0 +1,2 @@
1
+ Fe�t,�,���s)t�d��M2�}�&8��Qt��h�y0��b���ϻJ��9���$|�L�N�g}& �V|��m�M4�ad~@Qr��W���Q�"���K�t;��{��bW��R��I�(9j �!�Gê�J�,��P���qҼ9b̄-+ �g���2�o��7�i��_.*����J���<ʄL;�dο���1�Cn6��@�̘7
2
+ �UQ
@@ -0,0 +1,71 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # file: xinput_wrapper.rb
4
+
5
+
6
+ require 'sps-pub'
7
+ require 'secret_knock'
8
+
9
+
10
+ class XInputWrapper
11
+
12
+ def initialize(device: '3', host: 'sps', port: '59000',
13
+ topic: 'input/keyboard', verbose: true, lookup: nil)
14
+
15
+ @lookup = {
16
+ 37 => :control,
17
+ 50 => :lshift,
18
+ 133 => :super
19
+ }.merge(lookup)
20
+
21
+ @device, @topic, @verbose = device, topic, verbose
22
+ @sps = SPSPub.new host: host, port: port
23
+ @sk = SecretKnock.new short_delay: 0.25, long_delay: 0.5,
24
+ external: self, verbose: verbose
25
+ end
26
+
27
+ def knock()
28
+ puts 'knock' if @verbose
29
+ end
30
+
31
+ def message(msg)
32
+ return if msg.strip.empty?
33
+ @sps.notice "%s: %s" % [@topic, msg]
34
+ end
35
+
36
+ def listen()
37
+
38
+ command = "xinput test-xi2 --root #{@device}"
39
+ @sk.detect timeout: 0.7
40
+ sk = @sk
41
+ type = 0
42
+
43
+ IO.popen(command).each_line do |x|
44
+
45
+ #print "GOT ", x
46
+ raw_type = x[/EVENT type (\d+)/,1]
47
+
48
+ type = raw_type.to_i unless raw_type.nil?
49
+
50
+ # type = 13 means a key has been pressed
51
+ if type == 13 then
52
+
53
+ keycode = x[/detail: (\d+)/,1].to_i
54
+
55
+ puts 'keycode: ' + keycode.to_s if keycode > 0 and @verbose
56
+
57
+ case @lookup[keycode]
58
+ when :lshift
59
+ puts 'left shift' if @verbose
60
+ when :control
61
+ puts 'control' if @verbose
62
+ sk.knock
63
+ when :super
64
+ puts 'super key pressed' if @verbose
65
+ message 'super key pressed'
66
+ end
67
+
68
+ end
69
+ end
70
+ end
71
+ end
metadata ADDED
@@ -0,0 +1,109 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: xinput_wrapper
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - James Robertson
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain:
11
+ - |
12
+ -----BEGIN CERTIFICATE-----
13
+ MIIDljCCAn6gAwIBAgIBATANBgkqhkiG9w0BAQUFADBIMRIwEAYDVQQDDAlnZW1t
14
+ YXN0ZXIxHjAcBgoJkiaJk/IsZAEZFg5qYW1lc3JvYmVydHNvbjESMBAGCgmSJomT
15
+ 8ixkARkWAmV1MB4XDTE3MDgxMzExMjA0OFoX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 0ymew047+vZ5lDTOdEUMd+CsRmgoJBLRWXaTiHO05e7v3xtW9wDxP01a+FGQiYcj
32
+ 5bdH23akkNF4CA==
33
+ -----END CERTIFICATE-----
34
+ date: 2017-08-13 00:00:00.000000000 Z
35
+ dependencies:
36
+ - !ruby/object:Gem::Dependency
37
+ name: sps-pub
38
+ requirement: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - "~>"
41
+ - !ruby/object:Gem::Version
42
+ version: '0.5'
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ version: 0.5.5
46
+ type: :runtime
47
+ prerelease: false
48
+ version_requirements: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - "~>"
51
+ - !ruby/object:Gem::Version
52
+ version: '0.5'
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: 0.5.5
56
+ - !ruby/object:Gem::Dependency
57
+ name: secret_knock
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - "~>"
61
+ - !ruby/object:Gem::Version
62
+ version: '0.3'
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ version: 0.3.0
66
+ type: :runtime
67
+ prerelease: false
68
+ version_requirements: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - "~>"
71
+ - !ruby/object:Gem::Version
72
+ version: '0.3'
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: 0.3.0
76
+ description:
77
+ email: james@jamesrobertson.eu
78
+ executables: []
79
+ extensions: []
80
+ extra_rdoc_files: []
81
+ files:
82
+ - lib/xinput_wrapper.rb
83
+ homepage: https://github.com/jrobertson/xinput_wrapper
84
+ licenses:
85
+ - MIT
86
+ metadata: {}
87
+ post_install_message:
88
+ rdoc_options: []
89
+ require_paths:
90
+ - lib
91
+ required_ruby_version: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ required_rubygems_version: !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ version: '0'
101
+ requirements: []
102
+ rubyforge_project:
103
+ rubygems_version: 2.6.8
104
+ signing_key:
105
+ specification_version: 4
106
+ summary: A wrapper for the Linux utility xinput. Publishes an SPS message whenever
107
+ the super key is pressed as well as publishing a deciphered message when the control
108
+ key is pressed more than once
109
+ test_files: []
metadata.gz.sig ADDED
Binary file