alsa_aconnect 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/README.md +8 -3
- data/lib/alsa/aconnect.rb +0 -1
- data/lib/alsa/aconnect/cmd.rb +7 -3
- data/lib/alsa/aconnect/version.rb +1 -1
- metadata +1 -2
- data/lib/alsa/command.rb +0 -60
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 15f9788a8fe37cd553690282394fdac0bd2bf30de7dccffd6b83540013ba55f4
|
4
|
+
data.tar.gz: 01d4786195dccd53b11184be34d34eae6da37a2d0bab6e79ec0fc2125926d7b6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9ceb96edc8acb00da4bc75e8ce8c972cdd5486b39d6587b1513da9abc57edc3abd9625e25fa6d8297d63952053a61e68632b22cb412ae77c5ac992dcd6a5173e
|
7
|
+
data.tar.gz: 6309907438e7bdc992be734b2ef81c60ca2e510a2721bef9b0b14f796f6d58c5e0c035fa6b335a5a77b9f3974141de669d4f3f70c131ec02c92e15ae2d14d27d
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -24,16 +24,21 @@ Or install it yourself as:
|
|
24
24
|
require 'alsa/aconnect'
|
25
25
|
|
26
26
|
def print_client(client)
|
27
|
-
|
27
|
+
tags = {
|
28
|
+
type: client.type,
|
29
|
+
card: client.card,
|
30
|
+
pid: client.pid
|
31
|
+
}.compact.map { |k, v| "#{k}=#{v}" }.join(',')
|
32
|
+
lines = ["#{client.id} => #{client.name} [#{tags}]"]
|
28
33
|
client.ports.each do |port|
|
29
34
|
if port.connected_to_type
|
30
35
|
connected = "connected to #{port.connected_to_type} #{port.connected_to_client_id}:#{port.connected_to_port_id}"
|
31
36
|
else
|
32
37
|
connected = 'not connected'
|
33
38
|
end
|
34
|
-
|
39
|
+
lines.push " #{port.id} => #{port.name} (#{connected})"
|
35
40
|
end
|
36
|
-
puts ''
|
41
|
+
puts(*lines, '')
|
37
42
|
end
|
38
43
|
|
39
44
|
input_clients = ALSA::Aconnect.input_clients
|
data/lib/alsa/aconnect.rb
CHANGED
data/lib/alsa/aconnect/cmd.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'open3'
|
4
|
+
|
3
5
|
module ALSA
|
4
6
|
module Aconnect
|
5
7
|
class Cmd
|
@@ -15,10 +17,12 @@ module ALSA
|
|
15
17
|
end
|
16
18
|
|
17
19
|
def run
|
18
|
-
|
19
|
-
|
20
|
+
cmd = [@exec, *@arguments].compact.join(' ')
|
21
|
+
out, err, status = Open3.capture3(cmd)
|
22
|
+
code = status.exitstatus
|
23
|
+
raise Error.new code, err.join("\n") unless code.zero?
|
20
24
|
|
21
|
-
out
|
25
|
+
out
|
22
26
|
end
|
23
27
|
end
|
24
28
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: alsa_aconnect
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Denis Talakevich
|
@@ -37,7 +37,6 @@ files:
|
|
37
37
|
- lib/alsa/aconnect/parser.rb
|
38
38
|
- lib/alsa/aconnect/port.rb
|
39
39
|
- lib/alsa/aconnect/version.rb
|
40
|
-
- lib/alsa/command.rb
|
41
40
|
- lib/alsa_aconnect.rb
|
42
41
|
- man.txt
|
43
42
|
homepage: https://github.com/senid231/alsa_aconnect
|
data/lib/alsa/command.rb
DELETED
@@ -1,60 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'open3'
|
4
|
-
|
5
|
-
module ALSA
|
6
|
-
# Util class for shell commands execution
|
7
|
-
class Command
|
8
|
-
def self.run(command, *arguments, **options)
|
9
|
-
new(command, arguments, options).run
|
10
|
-
end
|
11
|
-
|
12
|
-
attr_reader :command, :arguments, :env, :out, :err
|
13
|
-
|
14
|
-
def initialize(command, arguments, env: {}, out: nil, err: nil)
|
15
|
-
@command = command
|
16
|
-
@arguments = arguments
|
17
|
-
@env = env
|
18
|
-
@out = out
|
19
|
-
@err = err
|
20
|
-
@out_buff = []
|
21
|
-
@err_buff = []
|
22
|
-
end
|
23
|
-
|
24
|
-
def run
|
25
|
-
env_line = env.map { |k, v| "#{k}=#{v}" }.join(' ')
|
26
|
-
command_line = ([env_line, command] + arguments).reject(&:empty?).join(' ')
|
27
|
-
|
28
|
-
code = raw_execute(command_line)
|
29
|
-
[code, @out_buff, @err_buff]
|
30
|
-
end
|
31
|
-
|
32
|
-
private
|
33
|
-
|
34
|
-
def raw_execute(command_line)
|
35
|
-
Open3.popen3(command_line) do |_stdin, stdout, stderr, wait_thread|
|
36
|
-
Thread.new do
|
37
|
-
begin
|
38
|
-
until (raw_line = stdout.gets).nil?
|
39
|
-
@out_buff.push(raw_line)
|
40
|
-
out&.call(raw_line)
|
41
|
-
end
|
42
|
-
rescue IOError => _e
|
43
|
-
# command process was closed and it's ok
|
44
|
-
end
|
45
|
-
end
|
46
|
-
Thread.new do
|
47
|
-
begin
|
48
|
-
until (raw_line = stderr.gets).nil?
|
49
|
-
@err_buff.push(raw_line)
|
50
|
-
err&.call(raw_line)
|
51
|
-
end
|
52
|
-
rescue IOError => _e
|
53
|
-
# command process was closed and it's ok
|
54
|
-
end
|
55
|
-
end
|
56
|
-
wait_thread.value
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|