fest 1.3.12 → 1.4.12
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 +4 -4
- data/README.md +1 -1
- data/changelog.org +4 -0
- data/config/conditions.yml +15 -1
- data/config/custom.yml +1 -1
- data/config/default.yml +1 -1
- data/fest.gemspec +1 -1
- data/lib/fest.rb +8 -9
- data/lib/fest/volume.rb +21 -14
- data/spec/volume_spec.rb +44 -35
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 971b8a6270186dc0400dd8c2831878d736b6a698
|
|
4
|
+
data.tar.gz: 5000bd30c31c717c364ec41e100bcccae9a3c98e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 66cc10e14ab3435990869502e7ad6cce79be50163bac163c05708c7739aa9fef1fe1b6fc8f1f99592e6f169ea46b7c26614388bebd5c3017a21ba9dd55e14c11
|
|
7
|
+
data.tar.gz: 8f8233848deaa304ce77f950e276a0449ea421802cfb0849c5e6f75b5cd968b12f80520cb9334595096ef047d9902fde79197cf88c00b617b317a5ec59d5f7db
|
data/README.md
CHANGED
|
@@ -9,7 +9,7 @@ Ruby wrapper use [Festival](https://wiki.archlinux.org/index.php/Festival_%28%D0
|
|
|
9
9
|
|
|
10
10
|
## Requirements
|
|
11
11
|
|
|
12
|
-
- *nix* or OS X ...
|
|
12
|
+
- *nix* or OS X (pgrep tools) ...
|
|
13
13
|
- [Festival](https://wiki.archlinux.org/index.php/Festival_%28%D0%A0%D1%83%D1%81%D1%81%D0%BA%D0%B8%D0%B9%29) and necessary languages ...
|
|
14
14
|
- [Pulseaudio](https://wiki.archlinux.org/index.php/PulseAudio_%28%D0%A0%D1%83%D1%81%D1%81%D0%BA%D0%B8%D0%B9%29)
|
|
15
15
|
|
data/changelog.org
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
** 1.4.12 (Сб 03 окт 2015 13:08:17)
|
|
2
|
+
- manage volumes on inputs ... down ... up ...
|
|
3
|
+
- merge for default params with params ...
|
|
4
|
+
- add conditions ... flash and skype ...
|
|
1
5
|
** 1.3.12 (Пт 02 окт 2015 09:37:39)
|
|
2
6
|
- fix conditions ... delete xbacklight from dependence ...
|
|
3
7
|
** 1.3.11 (Чт 01 окт 2015 18:40:50)
|
data/config/conditions.yml
CHANGED
|
@@ -2,7 +2,21 @@
|
|
|
2
2
|
light:
|
|
3
3
|
- "brightness = `cat /sys/class/backlight/intel_backlight/brightness`.to_i"
|
|
4
4
|
- "exit if @backlight == 'nil' && brightness == 0"
|
|
5
|
+
flash:
|
|
6
|
+
- "displays = `xvinfo`.scan(/screen\\s#(\\d+)/i).flatten"
|
|
7
|
+
- "displays.each do |display|"
|
|
8
|
+
- " display = display.eql?('0') ? '' : '.' + display"
|
|
9
|
+
- " active = `DISPLAY=:0#{display} xprop -root '_NET_ACTIVE_WINDOW'`.scan(/\\w+/).last"
|
|
10
|
+
- " unless `xprop -id '#{active}' | grep '_NET_WM_STATE_FULLSCREEN'`.empty?"
|
|
11
|
+
- " title = `xprop -id '#{active}' | grep 'WM_CLASS(STRING)'`"
|
|
12
|
+
- " ['unknown', 'plugin-containe', 'exe'].each do |name|"
|
|
13
|
+
- " exit if title.scan(name).last == name"
|
|
14
|
+
- " end"
|
|
15
|
+
- " end"
|
|
16
|
+
- "end"
|
|
17
|
+
skype:
|
|
18
|
+
- "exit unless `pactl list sink-inputs | grep 'phone'`.empty?"
|
|
5
19
|
players:
|
|
6
20
|
- "%w(xbmc kodi vlc).each do |player|"
|
|
7
|
-
- "exit if `
|
|
21
|
+
- " exit if `pgrep -lfc '#{player}'`.to_i > 0"
|
|
8
22
|
- "end"
|
data/config/custom.yml
CHANGED
data/config/default.yml
CHANGED
data/fest.gemspec
CHANGED
data/lib/fest.rb
CHANGED
|
@@ -14,14 +14,13 @@ class Fest
|
|
|
14
14
|
unless string.nil? || string.empty?
|
|
15
15
|
check_conditions
|
|
16
16
|
make_wav(string)
|
|
17
|
-
expect_if_paplay_now
|
|
18
17
|
play_wav
|
|
18
|
+
delete_wav
|
|
19
19
|
end
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
def initialize(params = {})
|
|
23
|
-
params =
|
|
24
|
-
YAML.load_file("#{GEM_ROOT}/config/default.yml") if params == {}
|
|
23
|
+
params = YAML.load_file("#{GEM_ROOT}/config/default.yml").merge(params)
|
|
25
24
|
params.each do |key, value|
|
|
26
25
|
instance_variable_set(
|
|
27
26
|
"@#{key}",
|
|
@@ -45,20 +44,20 @@ class Fest
|
|
|
45
44
|
|
|
46
45
|
def expect_if_paplay_now
|
|
47
46
|
loop do
|
|
48
|
-
break if `
|
|
47
|
+
break if `pgrep -lfc 'paplay'`.to_i == 0
|
|
49
48
|
sleep 1
|
|
50
49
|
end
|
|
51
50
|
end
|
|
52
51
|
|
|
53
52
|
def play_wav
|
|
54
|
-
|
|
53
|
+
expect_if_paplay_now
|
|
54
|
+
current_volumes_on_inputs
|
|
55
|
+
volumes_for_inputs
|
|
55
56
|
optimize_volume
|
|
56
|
-
|
|
57
|
-
change_volume(@current_volume, @volume, @step)
|
|
57
|
+
change_volumes(@current_volumes, @volumes, @step)
|
|
58
58
|
system("paplay #{@path}/say_#{@index}.wav \
|
|
59
59
|
--volume='#{@optimize_volume * 655}' > /dev/null 2>&1")
|
|
60
|
-
|
|
61
|
-
delete_wav
|
|
60
|
+
change_volumes(@volumes, @current_volumes, @step)
|
|
62
61
|
end
|
|
63
62
|
|
|
64
63
|
def delete_wav
|
data/lib/fest/volume.rb
CHANGED
|
@@ -1,33 +1,40 @@
|
|
|
1
1
|
# coding: utf-8
|
|
2
|
-
#
|
|
3
2
|
module Volume
|
|
4
|
-
def
|
|
5
|
-
|
|
3
|
+
def current_volumes_on_inputs
|
|
4
|
+
info = `pactl list sink-inputs`
|
|
5
|
+
inputs = info.scan(/\A#|№(\d+)/).flatten
|
|
6
|
+
volumes = info.scan(/\W+:\s\w+\W+\w+:\s\d+\s\/\s+(\d+)%/).flatten
|
|
7
|
+
@current_volumes = inputs.zip(volumes.map(&:to_i)).to_h
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def volumes_for_inputs
|
|
11
|
+
@volumes = {}
|
|
12
|
+
@current_volumes.each do |input, volume|
|
|
13
|
+
@volumes.merge!({ input => (volume - volume / 10 * @step) })
|
|
14
|
+
end
|
|
15
|
+
@volumes
|
|
6
16
|
end
|
|
7
17
|
|
|
8
18
|
def optimize_volume
|
|
9
19
|
@optimize_volume = (
|
|
10
|
-
if @
|
|
20
|
+
if @common_volume > @max_volume
|
|
11
21
|
@max_volume
|
|
12
|
-
elsif @
|
|
22
|
+
elsif @common_volume < @min_volume
|
|
13
23
|
@min_volume
|
|
14
24
|
else
|
|
15
|
-
@
|
|
25
|
+
@common_volume
|
|
16
26
|
end
|
|
17
27
|
)
|
|
18
28
|
end
|
|
19
29
|
|
|
20
|
-
def
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
def change_volume(volume, break_volume, step)
|
|
25
|
-
change = volume > break_volume ? 'down' : 'up'
|
|
26
|
-
@inputs.each do |input|
|
|
30
|
+
def change_volumes(volumes, break_volumes, step)
|
|
31
|
+
volumes.each do |input, volume|
|
|
32
|
+
change = volume > break_volumes[input] ? 'down' : 'up'
|
|
27
33
|
loop do
|
|
28
34
|
system("pactl set-sink-input-volume #{input} '#{volume * 655}'")
|
|
29
35
|
change == 'up' ? volume += step : volume -= step
|
|
30
|
-
break if change == 'up' ? volume >
|
|
36
|
+
break if change == 'up' ? volume > break_volumes[input] :
|
|
37
|
+
volume < break_volumes[input]
|
|
31
38
|
end
|
|
32
39
|
end
|
|
33
40
|
end
|
data/spec/volume_spec.rb
CHANGED
|
@@ -7,7 +7,7 @@ RSpec.describe Fest do
|
|
|
7
7
|
@fest = Fest.new
|
|
8
8
|
params = YAML.load_file("#{GEM_ROOT}/config/default.yml")
|
|
9
9
|
@step = params['step']
|
|
10
|
-
@
|
|
10
|
+
@common_volume = eval(params['common_volume'].join('; '))
|
|
11
11
|
@max_volume = params['max_volume']
|
|
12
12
|
@min_volume = params['min_volume']
|
|
13
13
|
end
|
|
@@ -16,56 +16,65 @@ RSpec.describe Fest do
|
|
|
16
16
|
expect(@fest.class.included_modules.include?(Volume)).to be_truthy
|
|
17
17
|
end
|
|
18
18
|
|
|
19
|
-
it '
|
|
19
|
+
it 'common volume eq volume?' do
|
|
20
20
|
vol = `amixer | grep -o '[0-9]*' | sed "5 ! d"`.to_i
|
|
21
|
-
expect(@
|
|
21
|
+
expect(@common_volume).to eq(vol)
|
|
22
22
|
end
|
|
23
23
|
|
|
24
|
-
it '#
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
it '#current_volumes_on_inputs' do
|
|
25
|
+
info = `pactl list sink-inputs`
|
|
26
|
+
inputs = info.scan(/\A#|№(\d+)/).flatten
|
|
27
|
+
volumes = info.scan(/\W+:\s\w+\W+\w+:\s\d+\s\/\s+(\d+)%/).flatten
|
|
28
|
+
current_volumes = inputs.zip(volumes.map(&:to_i)).to_h
|
|
29
|
+
expect(@fest.current_volumes_on_inputs).to eq(current_volumes)
|
|
28
30
|
end
|
|
29
31
|
|
|
30
|
-
it '#
|
|
31
|
-
|
|
32
|
-
|
|
32
|
+
it '#volumes_for_inputs' do
|
|
33
|
+
current_volumes = @fest.current_volumes_on_inputs
|
|
34
|
+
volumes = {}
|
|
35
|
+
current_volumes.each do |input, volume|
|
|
36
|
+
volumes.merge!({ input => (volume - volume / 10 * @step) })
|
|
37
|
+
end
|
|
38
|
+
expect(@fest.volumes_for_inputs).to eq(volumes)
|
|
33
39
|
end
|
|
34
40
|
|
|
35
41
|
it '#optimize_volume' do
|
|
36
|
-
if @
|
|
37
|
-
expect(@fest.optimize_volume).to be < @
|
|
38
|
-
elsif @
|
|
39
|
-
expect(@fest.optimize_volume).to be > @
|
|
42
|
+
if @common_volume > @max_volume
|
|
43
|
+
expect(@fest.optimize_volume).to be < @common_volume
|
|
44
|
+
elsif @common_volume < @min_volume
|
|
45
|
+
expect(@fest.optimize_volume).to be > @common_volume
|
|
40
46
|
else
|
|
41
|
-
expect(@fest.optimize_volume).to eq(@
|
|
47
|
+
expect(@fest.optimize_volume).to eq(@common_volume)
|
|
42
48
|
end
|
|
43
49
|
end
|
|
44
50
|
|
|
45
|
-
it '#
|
|
46
|
-
@fest.
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
)
|
|
51
|
+
it '#change_volumes down' do
|
|
52
|
+
@fest.change_volumes(
|
|
53
|
+
@fest.current_volumes_on_inputs, @fest.volumes_for_inputs, @step)
|
|
54
|
+
|
|
55
|
+
info = `pactl list sink-inputs`
|
|
56
|
+
inputs = info.scan(/\A#|№(\d+)/).flatten
|
|
57
|
+
volumes = info.scan(/\W+:\s\w+\W+\w+:\s\d+\s\/\s+(\d+)%/).flatten
|
|
58
|
+
current_volumes = inputs.zip(volumes.map(&:to_i)).to_h
|
|
52
59
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
60
|
+
@fest.volumes_for_inputs.each do |input, volume|
|
|
61
|
+
expect(volume).to eq(current_volumes[input])
|
|
62
|
+
end
|
|
56
63
|
end
|
|
57
64
|
|
|
58
|
-
it '#
|
|
59
|
-
@fest.
|
|
60
|
-
@fest.
|
|
61
|
-
@fest.
|
|
62
|
-
@current_volume,
|
|
63
|
-
@step
|
|
64
|
-
)
|
|
65
|
+
it '#change_volumes up' do
|
|
66
|
+
@fest.current_volumes_on_inputs
|
|
67
|
+
@fest.change_volumes(
|
|
68
|
+
@fest.volumes_for_inputs, @fest.current_volumes_on_inputs, @step)
|
|
65
69
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
70
|
+
info = `pactl list sink-inputs`
|
|
71
|
+
inputs = info.scan(/\A#|№(\d+)/).flatten
|
|
72
|
+
volumes = info.scan(/\W+:\s\w+\W+\w+:\s\d+\s\/\s+(\d+)%/).flatten
|
|
73
|
+
current_volumes = inputs.zip(volumes.map(&:to_i)).to_h
|
|
74
|
+
|
|
75
|
+
@fest.current_volumes_on_inputs.each do |input, volume|
|
|
76
|
+
expect(volume).to eq(current_volumes[input])
|
|
77
|
+
end
|
|
69
78
|
end
|
|
70
79
|
end
|
|
71
80
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: fest
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.4.12
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Alexsey Ermolaev
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2015-10-
|
|
11
|
+
date: 2015-10-13 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rake
|